Skip to content

Commit 3afd725

Browse files
Update docs on Mon Dec 16 15:50:23 UTC 2024
1 parent 5355e16 commit 3afd725

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

2024/16/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ <h2 id="problem-name">Reindeer Maze</h2>
275275
</div>
276276

277277
<div class="content">
278-
<div id="notes"><p>It&#39;s time again for the <a href="/2015/day/14">Reindeer Olympics</a>! This year, the big event is the <em>Reindeer Maze</em>, where the Reindeer compete for the <em>lowest score</em>.</p>
278+
<div id="notes"><p>It&#39;s time again for the <em>Reindeer Olympics</em>! This year, the big event is the <em>Reindeer Maze</em>, where the Reindeer compete for the <em>lowest score</em>.</p>
279279
<p>You and The Historians arrive to search for the Chief right as the event is about to start. It wouldn&#39;t hurt to watch a little, right?</p>
280280
<p><em>Visit the website for the full story and <a href="https://adventofcode.com/2024/day/16">full puzzle</a> description.</em></p>
281-
<p>I spent hell a lot of time on this one. I’m not sure why, because I had a good understanding of what to do for both parts. <code>Part 1</code> went reasonably well: I quickly used a priority based approach to find the shortest path from the <code>start</code> state to the <code>goal</code>.</p>
282-
<p>For <code>Part 2</code>, I initially tried a few dead ends, because I overcomplicate things as usual. But I found the right direction after about half an hour. The idea is to split the problem into two halves. First, we compute the optimal distances from every tile and direction to the goal node. This can be found using <em>Dijskstra&#39;s algorithm</em>.</p>
281+
<p>I spent hell a lot of time on this one. I’m not sure why, because I had a good understanding of what to do for both parts. <code>Part 1</code> went reasonably well: I quickly used a priority queue based approach to find the shortest path from the <code>start</code> state to the <code>goal</code>.</p>
282+
<p>For <code>Part 2</code>, I tried a few dead ends, because I overcomplicate things as usual. But I found the right direction after about half an hour. The idea is to split the problem into two halves. First, we compute the optimal distances from every tile and direction to the goal node. This can be found using <em>Dijskstra&#39;s algorithm</em>.</p>
283283
<p>Once I have the distances, I can start an other round, now working forward from the start position and using a flood-fill-like algorithm to discover the positions on the shortest path. This is easy to do with the distance map as a guide. I maintain the &#39;remaining score&#39; along the path, and just need to check if the distance from a potential next state equals to the score I still have to use. This logic can be found in the <code>FindBestSpots</code> function.</p>
284284
</div>
285285
<div id="code-container"><pre class="hljs language-csharp"><code>namespace AdventOfCode.Y2024.Day16;

0 commit comments

Comments
 (0)