Skip to content

Commit 619afcf

Browse files
authored
Update README.md
1 parent d373fa5 commit 619afcf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

2024/Day20/README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ While The Historians get to work, a nearby program sees that you're idle and cha
55

66
_Visit the website for the full story and [full puzzle](https://adventofcode.com/2024/day/20) description._
77

8-
The problem included a small but crucial hint: _there is only a single path from the start to the end_. Moreover, there are no dead ends in the input; it's just a single, continuous trace. The definition of _cheating_ was super hard to understand. I have to admit that instead, I used my intuition and give a more simple definition: in cheat mode you can step to any cell within the distance of 2 (or 20 for the second part).
8+
The problem included a small but crucial hint: _there is only a single path from the start to the end_. Moreover, there are no dead ends in the input; it's just a single, continuous trace.
99

10-
I created a function that returns the points of the track in from finish to start. This way, the index of an item in the array corresponds to its distance to the finish line. Then, I go over the path. For each position, the number of possible cheats is calculated by checking what happens if we are trying to make a shortcut to any other positions that is closer to the finish line.
10+
The definition of _cheating_ was super hard to understand. I have to admit that instead, I used my intuition and used a more simple definition: in cheat mode you can step to any cell within the distance of 2 (or 20 for the second part). This really worked.
11+
12+
I created a function that returns the points of the track from finish to start. This way, the _index_ of an item in the array corresponds to its distance to the finish line.
13+
14+
Then, I go over the path. For each position, the number of possible cheats is calculated by checking what happens if we are trying to make a shortcut to any other positions around.
1115

1216
There are a number of cases to consider:
1317
- the target position is too far away. This happens when its Manhattan distance is greater than the allowed _cheat_ limit
14-
- the target is within range, but the saving is less than 100
18+
- the target is within range, but actually further from the finish when we are (the saving is negative).
19+
- the target is within range, closer to the finish, but the saving is still less than 100
1520
- the target is within range, and the saving is at least 100
1621

17-
We need to determine the number of good cheats for each position add them up. I used Parallel LINQ here, as the regular sequential one took significantly more time.
22+
We need to determine the number of good cheats for each position _add_ them up. I used Parallel LINQ here, as the regular sequential one took significantly more time.

0 commit comments

Comments
 (0)