<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="351210" data-post-id="351210">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="adamu" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/adamu/120/31482_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  adamu
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="adamu" data-post="12" data-topic="67917">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/adamu/48/31482_2.png" class="avatar"> adamu:</div>
<blockquote>
<p>My first defeat.</p>
</blockquote>
</aside>
<p>I finally came back and finished part 2. 40-50 seconds on the core i5… <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20"></p>
<p>I updated part 1 to detect loops, ran it again to get the path travelled, calculated all the adjacent spaces, then brute forced it re-running part 1 with an obstacle in every space, counting how many of them resulted in a loop.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">Enum.count(candidate_obstructions, fn {x, y} -&gt;
  new_obstacles = MapSet.put(patrol.obstacles, {x, y})
  new_patrol = %Patrol{patrol | obstacles: new_obstacles}

  patrol(new_patrol) == :loop
end)
</code></pre>
<p><a href="https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2024/day6.exs" class="onebox" target="_blank" rel="noopener nofollow ugc">https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2024/day6.exs</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="351210" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/advent-of-code-2024-day-6/67917/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-351210" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="351210"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #41"></div>
  </section>
</div>
    <div class="postbit" id="351223" data-post-id="351223">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="stevensonmt" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/120/20503_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  stevensonmt
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Still going to plod along. Haven’t had much time this year and this day I wasted a lot of time trying to be clever with digraphs. In the end I’ve got it finishing part 2 in about 8-9 seconds on my 13 year old 4 core i5.</p>
<p><a href="https://github.com/stevensonmt/advent_of_code/blob/1b6d50c22e9e396731d6a1caf04ea001ffdf4653/2024/day6/lib/day6.ex" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/stevensonmt/advent_of_code/blob/1b6d50c22e9e396731d6a1caf04ea001ffdf4653/2024/day6/lib/day6.ex</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="351223" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/advent-of-code-2024-day-6/67917/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-351223" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="351223"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>