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 <ahref="/2017/day/24">right outside</a> the CPU!</p>
282
+
<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>Here is your corrected text with improved grammar and flow: </p>
286
+
<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>
287
+
<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>
288
+
<p>There are a number of cases to consider:</p>
289
+
<ul>
290
+
<li>the target position is too far away. This happens when its Manhattan distance is greater than the allowed <em>cheat</em> limit</li>
291
+
<li>the target is within range, but the saving is less than 100</li>
292
+
<li>the target is within range, and the saving is at least 100</li>
293
+
</ul>
294
+
<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>
0 commit comments