You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<divid="notes"><p>The Historians are quite pixelated again. This time, a massive, black building looms over you - you're <em>right outside</em> the CPU!</p>
283
283
<p>While The Historians get to work, a nearby program sees that you're idle and challenges you to a <em>race</em>. Apparently, you've arrived just in time for the frequently-held <em>race condition</em> festival!</p>
284
284
<p><em>Visit the website for the full story and <ahref="https://adventofcode.com/2024/day/20">full puzzle</a> description.</em></p>
285
-
<p>The problem included a small but crucial hint: <em>there is only a single path from the start to the end</em>. Moreover, there are no dead ends in the input; it's just a single, continuous trace. The definition of <em>cheating</em> 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).</p>
286
-
<p>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. </p>
285
+
<p>The problem included a small but crucial hint: <em>there is only a single path from the start to the end</em>. Moreover, there are no dead ends in the input; it's just a single, continuous trace.</p>
286
+
<p>The definition of <em>cheating</em> 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.</p>
287
+
<p>I created a function that returns the points of the track from finish to start. This way, the <em>index</em> of an item in the array corresponds to its distance to the finish line.</p>
288
+
<p>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. </p>
287
289
<p>There are a number of cases to consider:</p>
288
290
<ul>
289
291
<li>the target position is too far away. This happens when its Manhattan distance is greater than the allowed <em>cheat</em> limit</li>
290
-
<li>the target is within range, but the saving is less than 100</li>
292
+
<li>the target is within range, but actually further from the finish when we are (the saving is negative).</li>
293
+
<li>the target is within range, closer to the finish, but the saving is still less than 100</li>
291
294
<li>the target is within range, and the saving is at least 100</li>
292
295
</ul>
293
-
<p>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.</p>
296
+
<p>We need to determine the number of good cheats for each position <em>add</em> them up. I used Parallel LINQ here, as the regular sequential one took significantly more time.</p>
0 commit comments