-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
7,769 additions
and
5,789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Leaderboard Positions - **Part 1**: 1214, **Part 2**: 3999 | ||
|
||
Holy hell! I wish I can go out on a limb and say that was the hardest puzzle of the year, but it was only Day 5 :(. | ||
|
||
For this puzzle, we are given a mapping of seeds to soil to fertilizer to blah blah blah. It doesn't matter about what names they map to, we just have to map seed numbers 7 times using the ranges defined in the input. For part 1, we take the `seeds` list at the top of the input, go through all the mappings, and find the smallest value. To do this, we can simply go through all the mapping's ranges, see if the seed number if between it; if it is, then we map the seed number and continue with the next. If no range is found, we leave it be. We do this process for each mapping and we are left with 7-mapped numbers that we can find the minimum of. For part 2, we treat those list of seed numbers as two digits per entry: one is the start, the second is the range. For example... | ||
|
||
``` | ||
[79] [14] [55] [13] | ||
is now | ||
[79 14] [55 13] | ||
``` | ||
|
||
Theses ranges are also treated like `[79, 93)` (`79 + 14 = 93`), so 93 doesn't get mapped in this first range. If you look at my code, I just subtract 1 from all the ends and it seemed to work (probably a more elegant way to handle it). So when we go through all the mappings this time, I separated the ranges between `mapped` and `unmapped`. All the `unmapped` are checked for any range collisions; if they do collide, split the ranges so that only the numbers in the mapping range get mapped, and continue. This allows us to turn this billion-operation problem into a few thousand, which the computer can handle easily. | ||
|
||
*NOTE: I originally went with a brute force solution the night of the puzzle's opening, and I was lucky to find the minimum in the second range of seed numbers, so I didn't have to run my solution for hours.* | ||
|
||
I think that I will look back at this puzzle because it was harder than most of 2020 and 2015 (the ones that I have redone to train for 2023) and it is ONLY DAY 5!!! Until then, I look forward to the rest of 2023. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Leaderboard Positions - **Part 1**: 303, **Part 2**: 178 | ||
|
||
It seems to be that the even days are the easier problems and the odd days are the harder problems (with the even days getting easier and the odd days get harder). I did absolutely wonderful this day, the best I did so far, but it makes me wary of the Day 7 (oh no). | ||
|
||
Anyways, for this puzzle we need to see which of our boats beats the record distances given to us based on how long we hold on to the accelerator. For example, if our time is `15 seconds` and our record distance of `40 units`. We can hold it for `7 seconds`, which allows the boat to go at `7 units/sec`, but then we only have `8 seconds` to race. That will allow it to go `56 units (7 units/sec * 8 sec)`, which beats the record. | ||
|
||
For part 1, we need to go through all pairs of times and distances; for each we need to find how many ways we can beat the record and then multiply them all together. This just consists of doing a for loop on each pair that checks if `i * (time - i)` is greater than the record. Since the numbers are very small (especially compared to Day 5), this is really fast. | ||
|
||
For part 2, we do the same thing except we combine our numbers in the input. This was a very simple process, and the same procedure works. Doing 50 million operations is still pretty fast, so I only changed the parsing. | ||
|
||
This is a fun break after dealing with the headache that was Day 5, but as mentioned before, I am scared of what Day 7 has to offer. |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.