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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Catching up after the weekend. Not the best, but will do.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Aoc2025.Solutions.Y25.Day06 do
  alias AoC.Input

  def parse(input, _part) do
    Input.read!(input)
    |&gt; String.split("\n", trim: true)
  end

  def part_one(problem) do
    problem
    |&gt; Enum.flat_map(&amp;(String.split(&amp;1) |&gt; Enum.with_index()))
    |&gt; Enum.reverse()
    |&gt; Enum.group_by(fn {x, y} -&gt; y end, fn {x, y} -&gt; x end)
    |&gt; Map.values()
    |&gt; Enum.map(fn [op | numbers] -&gt; build_expr_and_calc(numbers, op) end)
    |&gt; Enum.sum()
  end

  def part_two(rows) do
    col_sizes =
      rows
      |&gt; Enum.map(&amp;fetch_space_locations/1)
      |&gt; Enum.zip_reduce([], &amp;fetch_max_col_size/2)
      |&gt; Enum.reverse()

    Enum.map(rows, fn row -&gt; split_row(row, col_sizes) end)
    |&gt; Enum.zip_with(&amp;(&amp;1 |&gt; Enum.reverse()))
    |&gt; Enum.map(fn [op | col] -&gt; [op | Enum.zip_with(Enum.reverse(col), &amp; &amp;1)] end)
    |&gt; Enum.map(fn [op | numbers] -&gt; build_expr_and_calc(numbers, op) end)
    |&gt; Enum.sum()
  end

  def build_expr_and_calc(numbers, op) do
    numbers |&gt; Enum.intersperse(op) |&gt; List.to_string() |&gt; Code.eval_string() |&gt; elem(0)
  end

  def fetch_space_locations(rows) do
    Regex.scan(~r/[\d\*\+]+/, rows, return: :index, trim: true) |&gt; List.flatten()
  end

  def fetch_max_col_size(els, acc) do
    [Enum.max_by(els, fn {x, y} -&gt; y end) | acc]
  end

  def split_row(row, col_sizes) do
    Enum.map(col_sizes, fn {start, size} -&gt;
      String.slice(row, start, size) |&gt; String.to_charlist()
    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="379540" 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-2025-day-6/73563/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-379540" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="379540"
                     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>