<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="348736" data-post-id="348736">
  <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">
								<p>My first defeat.</p>
<p>I implemented part 2 by doing this:</p>
<ol>
<li>Keep track of all visited  spaces and the direction.</li>
<li>For each step, look right and check if we would join any previously visited path in the same direction</li>
</ol>
<p>It works on the sample input, but says it’s too low on the real one. Must be a bug somewhere, but time’s up.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348736" data-batch-url="/posts/batch_likers">
                        1
                      </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/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-348736" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348736"
                     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 #11"></div>
  </section>
</div>
    <div class="postbit" id="348739" data-post-id="348739">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sevenseacat" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sevenseacat/120/23153_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sevenseacat
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Ash Framework</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>“Look right”?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348739" 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/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-348739" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348739"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="348740" data-post-id="348740">
  <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">
								<p>Yes, the guard only turns right. So my thinking is if there is already a travelled path to the right of the current position, putting a boulder immediately ahead will create a cycle.</p>
<p>From the sample:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">....#.....
....+---+#
....|...|.
..#.|...|.
....|..#|.
....|...|.
.#.O^---+.
........#.
#.........
......#...
</code></pre>
<p>When we “look right” after reaching the start position a 2nd time, we see the already travelled path in the same direction, put obstacle.</p>
<p>edit:</p>
<p>I think I forgot to account for cases where the guard could walk backwards along the same path: like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">.#.
-&gt;#
#..
.O.
</code></pre>
<p>Anyway…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348740" 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/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-348740" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348740"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="348744" data-post-id="348744">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>finally got time to complete Part1 &lt;3</p>
<p><a href="https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_6/Part1.ex" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_6/Part1.ex</a></p>
<p>its pretty simple to do, IF you have the hunch early to create a tile formatter .. which I didn’t and made much later than I should have …  this can easily display the grid back in the terminal … much easier to see offset errors</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348744" data-batch-url="/posts/batch_likers">
                        1
                      </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/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-348744" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348744"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="348746" data-post-id="348746">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey there, I completed Part 1 &amp; 2, but I’m not proud of my code <img src="https://forum.elixirforum.com/images/emoji/apple/face_with_tongue.png?v=15" title=":face_with_tongue:" class="emoji" alt=":face_with_tongue:" loading="lazy" width="20" height="20"><br>
so I keep it for myself <img src="https://forum.elixirforum.com/images/emoji/apple/zipper_mouth_face.png?v=15" title=":zipper_mouth_face:" class="emoji" alt=":zipper_mouth_face:" loading="lazy" width="20" height="20"></p>
<p>Part2 runs in 3.5 sec, with <code>Task.async_stream</code> <img src="https://forum.elixirforum.com/images/emoji/apple/snail.png?v=15" title=":snail:" class="emoji" alt=":snail:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348746" data-batch-url="/posts/batch_likers">
                        1
                      </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/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-348746" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348746"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="348747" data-post-id="348747">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Haha. One thing ive learned in 16 years as developer. Never keep things for your self. Always something to learn, and some «bad code» can even look good to others <img src="https://forum.elixirforum.com/images/emoji/apple/sign_of_the_horns.png?v=15" title=":sign_of_the_horns:" class="emoji" alt=":sign_of_the_horns:" loading="lazy" width="20" height="20"><img src="https://forum.elixirforum.com/images/emoji/apple/raising_hands.png?v=15" title=":raising_hands:" class="emoji" alt=":raising_hands:" loading="lazy" width="20" height="20"> but good job. I almost never think about speed. Unless i see its slow</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348747" data-batch-url="/posts/batch_likers">
                        1
                      </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/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-348747" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348747"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="348749" data-post-id="348749">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here it <a href="https://github.com/cblavier/advent/blob/master/lib/2024/day06/part2.ex" rel="noopener nofollow ugc">is</a> <img src="https://forum.elixirforum.com/images/emoji/apple/shushing_face.png?v=15" title=":shushing_face:" class="emoji" alt=":shushing_face:" loading="lazy" width="20" height="20"></p>
<p>Now it’s tea time <img src="https://forum.elixirforum.com/images/emoji/apple/teapot.png?v=15" title=":teapot:" class="emoji" alt=":teapot:" loading="lazy" width="20" height="20"></p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/d/b/db61301f198d9b0d882b8649d47f3e11f3ff9c81.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/db61301f198d9b0d882b8649d47f3e11f3ff9c81" title="IMG_9023" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/d/b/db61301f198d9b0d882b8649d47f3e11f3ff9c81_2_517x388.jpeg" alt="IMG_9023" data-base62-sha1="viIMZVrR67bMHAcQpPPRSxujHzP" width="517" height="388" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/d/b/db61301f198d9b0d882b8649d47f3e11f3ff9c81_2_517x388.jpeg, https://forum.elixirforum.com/uploads/default/optimized/3X/d/b/db61301f198d9b0d882b8649d47f3e11f3ff9c81_2_775x582.jpeg 1.5x, https://forum.elixirforum.com/uploads/default/optimized/3X/d/b/db61301f198d9b0d882b8649d47f3e11f3ff9c81_2_1034x776.jpeg 2x" data-dominant-color="7A8085"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">IMG_9023</span><span class="informations">1200×901 63.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348749" data-batch-url="/posts/batch_likers">
                        3
                      </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/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-348749" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348749"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="348753" data-post-id="348753">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>impressive cod .. I mean cuP &lt;3  <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"> but seriously i see no issues with code <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p>
<p>how is this Mac mini going btw. and m1 model ? niiice clean desktop (for the picture I guess)</p>
<p>now ill shut up with the Segways <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348753" data-batch-url="/posts/batch_likers">
                        1
                      </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/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-348753" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348753"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="348756" data-post-id="348756">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m weird. My desktop is always clean and tidy, otherwise I can’t work.</p>
<p>It’s a Mac Studio I bought almost 3 years ago, still so powerful I think I will keep it for years</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348756" data-batch-url="/posts/batch_likers">
                        1
                      </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/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-348756" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348756"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="348759" data-post-id="348759">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<pre data-code-wrap="elixir"><code class="lang-elixir">      {guard, grid} = :persistent_term.get(Day06)
      grid = Map.put(grid, pos, ?\#)
</code></pre>
<p><a class="mention" href="/u/bjorng" rel="nofollow">@bjorng</a> On my machine I have seen that if I modify the map it’s slower. I just carry the new obstacle pos around and return <code>:obst</code> arbitrarily when looking for that key.</p>
<p>I wonder if modifying the persistent term does a full copy of the term instead of having the rest of the map being pointed to the shared memory.</p>
<p>Edit: Hmmm I do not have this behaviour anymore. Should be caused by something else.</p>
<p>Anyway it runs under 1s at the expense of clarity, enough for today <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule AdventOfCode.Solutions.Y24.Day06 do
  alias AdventOfCode.Grid
  alias AoC.Input

  def parse(input, _part) do
    grid =
      input
      |&gt; Input.stream!()
      |&gt; Grid.parse_stream(fn
        _, "#" -&gt;
          {:ok, :obst}

        {x, y}, "^" -&gt;
          Process.put(:start_pos, {x, y})
          {:ok, :n}

        _, _ -&gt;
          :ignore
      end)

    start = Process.get(:start_pos)
    Process.delete(:start_pos)

    {0, xo, 0, yo} = Grid.bounds(grid)
    {grid, start, :n, {xo, yo}}
  end

  def part_one({grid, start, dir, {xo, yo}}) do
    grid
    |&gt; loop_until_quits(start, dir, {xo, yo}, %{start =&gt; true})
    |&gt; map_size()
  end

  defp loop_until_quits(grid, pos, dir, {xo, yo}, acc) do
    {x, y} = next_pos = Grid.translate(pos, dir, 1)

    case Map.get(grid, next_pos) do
      :obst -&gt;
        loop_until_quits(grid, pos, rotate(dir), {xo, yo}, acc)

      nil when x in 0..xo//1 and y in 0..yo//1 -&gt;
        loop_until_quits(grid, next_pos, dir, {xo, yo}, Map.put(acc, next_pos, true))

      nil -&gt;
        acc

      _ -&gt;
        loop_until_quits(grid, next_pos, dir, {xo, yo}, Map.put(acc, next_pos, true))
    end
  end

  defp rotate(:n), do: :e
  defp rotate(:e), do: :s
  defp rotate(:s), do: :w
  defp rotate(:w), do: :n

  def part_two({grid, start, dir, {xo, yo}}) do
    candidates =
      grid
      |&gt; loop_until_quits(start, dir, {xo, yo}, %{})
      |&gt; Map.keys()

    :persistent_term.put(:grid, grid)

    parent = self()

    candidates
    |&gt; Enum.map(
      &amp;spawn_link(fn -&gt;
        grid = Map.put(:persistent_term.get(:grid), &amp;1, :obst)
        one_or_zero = loop_value(grid, start, dir, {xo, yo})
        send(parent, one_or_zero)
      end)
    )
    |&gt; Enum.reduce(0, fn _, acc -&gt;
      receive do
        n -&gt; acc + n
      end
    end)
  end

  defp loop_value(grid, pos, dir, {xo, yo}) do
    {x, y} = next_pos = Grid.translate(pos, dir, 1)

    case Map.get(grid, next_pos) do
      :obst -&gt;
        loop_value(grid, pos, rotate(dir), {xo, yo})

      ^dir -&gt;
        1

      _ when x in 0..xo//1 and y in 0..yo//1 -&gt;
        loop_value(Map.put(grid, next_pos, dir), next_pos, dir, {xo, yo})

      nil -&gt;
        0
    end
  end
end

</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="348759" 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/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-348759" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="348759"
                     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 #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/67917/load_more?page=3">Load more posts (22 remaining)</a>
</div></template></turbo-stream>