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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="MikeLindner" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  MikeLindner
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>There is a decent amount of puzzles that require to expand the grid, or to take only a sub part of it like today.</p>
</blockquote>
<p>This is my first time doing AOC so that’s a great tip.</p>
<p>What really help me get unstuck today was learning how to implement the Inspect protocol for debugging. Being able to easily see the example grid step by step is so beneficial. Loving how easy it is to implement things like that in Elixir with minimal code.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="349607" 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-12/68054/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-349607" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349607"
                     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 #21"></div>
  </section>
</div>
    <div class="postbit" id="349619" data-post-id="349619">
  <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 managed to understand the convex and concave solution and extracted it from your solution into my own. I have never done stuff like this, so this was totally new to me.</p>
<p><a href="https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_12/Part1%262.ex#L38" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_12/Part1%262.ex#L38</a></p>
<p>as you can see i just mapped my list of positions into a map, to adjust for the count_corners function.</p>
<p>but you had x and y flipped though <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"> i flipped them back <img src="https://forum.elixirforum.com/images/emoji/apple/stuck_out_tongue.png?v=15" title=":stuck_out_tongue:" class="emoji" alt=":stuck_out_tongue:" loading="lazy" width="20" height="20"></p>
<p>PS! What would be nice though .. is if anyone had some learning material or visualization for convex and concave checks in a grid.</p> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I put the puzzles down for a bit yesterday and decided to get back to it this morning.</p>
<p>Here’s my pass at part 2 after reading up a bit here:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">#!/usr/bin/env elixir

defmodule Day12.Part2 do
  defp parse(str) do
    [row | _rows] =
      rows =
      str
      |&gt; String.split("\n", trim: true)
      |&gt; Enum.map(&amp;to_charlist/1)

    height = Enum.count(rows)
    length = Enum.count(row)

    graph = :digraph.new([:acyclic])

    for y &lt;- 0..(height - 1) do
      for x &lt;- 0..(length - 1) do
        value = rows |&gt; Enum.at(y) |&gt; Enum.at(x)
        :digraph.add_vertex(graph, {x, y}, value)

        [{x + 1, y}, {x - 1, y}, {x, y + 1}, {x, y - 1}]
        |&gt; Enum.filter(fn {n_x, n_y} = neighbor -&gt;
          on_board?(neighbor, height, length) and rows |&gt; Enum.at(n_y) |&gt; Enum.at(n_x) == value
        end)
        |&gt; Enum.each(fn neighbor -&gt; :digraph.add_edge(graph, {x, y}, neighbor) end)
      end
    end

    :digraph_utils.components(graph)
  end

  defp on_board?({x, y}, height, length) when x &lt; 0 or x &gt;= length or y &lt; 0 or y &gt;= height,
    do: false

  defp on_board?(_pair, _height, _length), do: true

  defp area(contiguous_region) do
    contiguous_region |&gt; Enum.count()
  end

  defp corner?({side_a, side_b, diagonal}, contiguous_region) do
    sides = [side_a, side_b]

    convex? =
      sides
      |&gt; Enum.all?(&amp;(not MapSet.member?(contiguous_region, &amp;1)))

    concave? =
      sides
      |&gt; Enum.all?(&amp;MapSet.member?(contiguous_region, &amp;1)) and
        not MapSet.member?(contiguous_region, diagonal)

    convex? or concave?
  end

  defp sides({x, y} = _point, %MapSet{} = contiguous_region) do
    right = {x + 1, y}
    left = {x - 1, y}
    below = {x, y + 1}
    above = {x, y - 1}
    above_left = {x - 1, y - 1}
    above_right = {x + 1, y - 1}
    below_left = {x - 1, y + 1}
    below_right = {x + 1, y + 1}

    [
      {above, left, above_left},
      {above, right, above_right},
      {below, right, below_right},
      {below, left, below_left}
    ]
    |&gt; Enum.map(fn triple -&gt;
      if corner?(triple, contiguous_region), do: 1, else: 0
    end)
    |&gt; Enum.sum()
  end

  defp sides(contiguous_region) do
    contiguous_region
    |&gt; Enum.map(&amp;sides(&amp;1, contiguous_region))
    |&gt; Enum.sum()
  end

  defp fence_cost([point | _points] = contiguous_region) when is_tuple(point) do
    area = area(contiguous_region)
    sides = sides(MapSet.new(contiguous_region))
    area * sides
  end

  defp fence_cost([region | _regions] = contiguous_regions) when is_list(region) do
    contiguous_regions
    |&gt; Enum.map(&amp;fence_cost(&amp;1))
    |&gt; Enum.sum()
  end

  def solve() do
    File.read!("lib/advent_of_code/year/2024/day/12/input.txt")
    |&gt; parse()
    |&gt; fence_cost()
    |&gt; IO.puts()
  end
end

Day12.Part2.solve()
</code></pre>
<p>I had figured out the equality of sides to corners, but went in totally the wrong direction for calculating them at first. I may have also read something a while back about corner checking- felt like it rang a bell once I grasped it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="349668" 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-12/68054/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-349668" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349668"
                     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 #23"></div>
  </section>
</div>
    <div class="postbit" id="349704" data-post-id="349704">
  <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><a class="mention" href="/u/flo0807" rel="nofollow">@Flo0807</a> is this correct counting with convex and concave ?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">A  A  A  A
B  B  C2 D
B  B  C2 C2
E  E  E  C2
</code></pre>
<p>the top c (2,1) has A+B convex  and A+D as convex, so 2<br>
the next c (2,2) has B+E convex and D concave, so 2<br>
the top right c (3,2) has E concave and D+nil convex, so 2<br>
the bottom right c (3,3) has E+nil convex and nil+nil convex, so 2</p>
<p>this equals 8?</p>
<p>but the big question is, where do people get this info from? where was it learned ?</p> 
	            </div>

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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bjorng" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bjorng/120/13187_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bjorng
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Erlang Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>For part 2 I implemented a neat maze walking algorithm. Unfortunately, it only counted the outer fences and not fences around enclosed regions. My attempts to handle the enclosed  regions didn’t produce the correct answer.</p>
<p>I went back to the drawing board and ended up with this solution:</p>
<p><a href="https://github.com/bjorng/advent-of-code/blob/main/2024/day12/lib/day12.ex" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/bjorng/advent-of-code/blob/main/2024/day12/lib/day12.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="349738" 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-12/68054/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-349738" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349738"
                     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 #25"></div>
  </section>
</div>
    <div class="postbit" id="349751" data-post-id="349751">
  <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>anyway i asked perplexity</p>
<p><a href="https://www.perplexity.ai/search/i-have-recently-learned-about-LLX8S.QhQkuqPO1FoMe2RQ" class="onebox" target="_blank" rel="noopener nofollow ugc">https://www.perplexity.ai/search/i-have-recently-learned-about-LLX8S.QhQkuqPO1FoMe2RQ</a></p>
<p>Im very stubborn on not letting such knowledge pass me by <img src="https://forum.elixirforum.com/images/emoji/apple/rofl.png?v=15" title=":rofl:" class="emoji" alt=":rofl:" loading="lazy" width="20" height="20"> the question is both showing that i now fully understand it, its corner counting. And perplexity sheds some light on the background of the theory</p>
<p>A healthy combination of OCD and perseverance lead to me to the final refactor: <a href="https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_12/Part1_2.ex#L113" rel="noopener nofollow ugc">https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_12/Part1_2.ex#L113</a> (next up figure out what the others did, if it was not corner counting)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="349751" 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-12/68054/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-349751" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349751"
                     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 #26"></div>
  </section>
</div>
    <div class="postbit" id="349761" data-post-id="349761">
  <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>im now trying to dig into the alternative approaches to convex/concave corner counting and your part2 cost calculation seems a good candidate. Or maybe its hiding the same convex/concave in the code ?</p>
<p>for ex this</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">    sides = region
    |&gt; Enum.flat_map(fn plot -&gt;
      plot
      |&gt; adjacent_squares
      |&gt; Enum.filter(&amp;fence?(grid, type, &amp;1))
      |&gt; Enum.map(fn square -&gt;
        diff = sub(plot, square)
        axis = if elem(diff, 1) === 0, do: 0, else: 1
        other_axis = rem(axis + 1, 2)
        {{diff, elem(plot, axis)}, elem(plot, other_axis)}
      end)
    end)
</code></pre>
<p>it goes through all adjacent squares and subtracts the square (x,y) from the plot (x,y) to get a diff (x, y). Then it sets axis variable to 0 if y from diff is 0, else 1. Then it sets other_axis variable to the remainder of dividing axis (0 or 1) + 1 by 2, which can result in 2 or 1. Then end result is {{diff, elem(plot, 0 or 1)}, elem(plot, 1 or 2)} which is basically either {{diff, x}, x} or {{diff, y}, x}. Then we need to find out what this means. it returns which axis is … different? EDIT: my explanation here might be wrong, it just shows how my mind is trying to read the code  <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> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The counting looks good!</p>
<blockquote>
<p>but the big question is, where do people get this info from? where was it learned ?</p>
</blockquote>
<p>Like I said, I got this vector counting from a reddit post. I guess it’s the kind of math you learn when you dive into grids, 2D spaces and geometry.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="349763" 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-12/68054/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-349763" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349763"
                     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 #28"></div>
  </section>
</div>
    <div class="postbit" id="349764" data-post-id="349764">
  <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>ok im guess im going down the long road. If i cant solve it i find someone who has and dissects it to its fine grained atoms <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="349764" 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-12/68054/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-349764" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349764"
                     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 #29"></div>
  </section>
</div>
    <div class="postbit" id="349765" data-post-id="349765">
  <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
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If you struggle with corner counting I suggest to look at my solution (1st post in thread). It thinks it’s straightforward to implement.</p>
<p>Here is the additional code not shared from the <code>Grid</code> module:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">
  def cardinal4(xy) do
    [
      translate(xy, :n),
      translate(xy, :s),
      translate(xy, :w),
      translate(xy, :e)
    ]
  end

  def translate(xy, direction, n \\ 1)
  def translate({x, y}, :n, n), do: {x, y - n}
  def translate({x, y}, :s, n), do: {x, y + n}
  def translate({x, y}, :w, n), do: {x - n, y}
  def translate({x, y}, :e, n), do: {x + n, y}
</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="349765" 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-12/68054/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-349765" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="349765"
                     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 #30"></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/68054/load_more?page=4">Load more posts (11 remaining)</a>
</div></template></turbo-stream>