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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Pretty much the same as everyone else’s. Passing functions and tail recursion makes this really clean. <a href="https://github.com/shritesh/advent/blob/main/2023/09.livemd" class="inline-onebox" rel="noopener nofollow ugc">advent/2023/09.livemd at main · shritesh/advent · GitHub</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="310827" 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-2023-day-9/60260/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-310827" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310827"
                     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="310830" data-post-id="310830">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Converted part 1 to a simple visualization using Kino + VegaLite:</p>
<p><img src="https://forum.elixirforum.com/uploads/default/original/3X/9/5/9523d4fac32037e4c29ea0738a454e0b941de91d.gif" alt="output" data-base62-sha1="lhlUApCKrieq8rXMAqO7rYGsvxz" width="600" height="272" class="animated"></p>
<details>
<summary>
Code</summary>
<pre data-code-wrap="elixir"><code class="lang-elixir">alias VegaLite, as: Vl

defmodule Viz do
  def difference(widget, history), do: difference(widget, history, [])

  def difference(widget, prev_diffs, rest_diffs) do
    i = length(rest_diffs)

    data =
      for {diff, x} &lt;- Enum.with_index(prev_diffs) do
        %{"x" =&gt; x, "y" =&gt; diff, "i" =&gt; i}
      end

    Kino.VegaLite.push_many(widget, data)
    Process.sleep(div(500, i + 1))

    if Enum.all?(prev_diffs, &amp;(&amp;1 == 0)) do
      predictr(widget, [prev_diffs | rest_diffs])
    else
      next_diffs =
        prev_diffs
        |&gt; Enum.chunk_every(2, 1, :discard)
        |&gt; Enum.map(fn xs -&gt; Enum.reduce(xs, &amp;Kernel.-/2) end)

      difference(widget, next_diffs, [prev_diffs | rest_diffs])
    end
  end

  def predictr(widget, diffs), do: predictr(widget, diffs, 0)
  def predictr(_, [], extrapolation), do: extrapolation

  def predictr(widget, [diffs | rest], extrapolation) do
    next_extrapolation = extrapolation + List.last(diffs)

    i = length(rest)

    Kino.VegaLite.push(widget, %{
      "x" =&gt; length(diffs),
      "y" =&gt; next_extrapolation,
      "i" =&gt; i
    })

    Process.sleep(div(500, i + 1))
    predictr(widget, rest, next_extrapolation)
  end
end

widget =
  Vl.new(width: 600, height: 300)
  |&gt; Vl.mark(:line)
  |&gt; Vl.encode_field(:x, "x", type: :quantitative)
  |&gt; Vl.encode_field(:y, "y", type: :quantitative)
  |&gt; Vl.encode_field(:color, "i", type: :nominal)
  |&gt; Kino.VegaLite.render()

for history &lt;- histories do
  Kino.VegaLite.clear(widget)
  Viz.difference(widget, history)
end
</code></pre>
</details> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="310830" data-batch-url="/posts/batch_likers">
                        2
                      </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-2023-day-9/60260/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-310830" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310830"
                     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="310835" data-post-id="310835">
  <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">
								<aside class="quote no-group" data-username="trnasistor" data-post="11" data-topic="60260">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/3ab097/48.png" class="avatar"> trnasistor:</div>
<blockquote>
<pre data-code-wrap="elixir"><code class="lang-elixir">12 20 25 35 64 137 305 670 1420 2874 5537 10165 17840 30055 48809 76712 117100 174160 253065 360119 502912
</code></pre>
</blockquote>
</aside>
<p>These are the intermediate lists I found with my working solution:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">12 20 25 35 64 137 305 670 1420 2874 5537 10165 17840 30055 48809 76712 117100 174160 253065 360119 502912
8 5 10 29 73 168 365 750 1454 2663 4628 7675 12215 18754 27903 40388 57060 78905 107054 142793
-3 5 19 44 95 197 385 704 1209 1965 3047 4540 6539 9149 12485 16672 21845 28149 35739
8 14 25 51 102 188 319 505 756 1082 1493 1999 2610 3336 4187 5173 6304 7590
6 11 26 51 86 131 186 251 326 411 506 611 726 851 986 1131 1286
5 15 25 35 45 55 65 75 85 95 105 115 125 135 145 155
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
0 0 0 0 0 0 0 0 0 0 0 0 0 0
</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="310835" 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-2023-day-9/60260/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-310835" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310835"
                     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="310870" data-post-id="310870">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="lud" data-post="14" data-topic="60260">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lud/48/14382_2.png" class="avatar"> lud:</div>
<blockquote>
<p>These are the intermediate lists I found with my working solution</p>
</blockquote>
</aside>
<p>Thank you! Turns out, I was wrong to take absolute value of the difference like so:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  new_value = abs(head - List.first(tail))
</code></pre>
<p>Instead, I had to simply subtract the second value from the first</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  new_value = List.first(tail) - head
</code></pre>
<p>With this change, I got the right answer immediately.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="310870" data-batch-url="/posts/batch_likers">
                        2
                      </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-2023-day-9/60260/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-310870" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310870"
                     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="310901" data-post-id="310901">
  <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>I thought the first few days had some excessively hard problems for early on but this was an oddly easy day. Part 2 was just not much of a challenge after part 1.</p>
<details>
<summary>
Code</summary>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Day9 do
  @moduledoc """
  Day9 AoC Solutions
  """

  alias AocToolbox.Input

  # add sample data here
  def input(:test),
    do: """
    0 3 6 9 12 15
    1 3 6 10 15 21
    10 13 16 21 30 45
    """

  def input(:real), do: Input.load(__DIR__ &lt;&gt; "/input.txt")

  def solve(1, mode) do
    __MODULE__.Part1.solve(input(mode))
  end

  def solve(2, mode) do
    __MODULE__.Part2.solve(input(mode))
  end

  def parse(input) do
    input
    |&gt; String.split("\n", trim: true)
    |&gt; Enum.map(&amp;String.split(&amp;1, ~r"\s"))
    |&gt; Enum.map(fn gs -&gt; gs |&gt; Enum.map(&amp;String.to_integer/1) end)
  end

  def intervals(histories), do: Enum.map(histories, fn row -&gt; do_intervals(row, []) end)

  def do_intervals(row, acc) do
    if Enum.all?(row, &amp;Kernel.==(&amp;1, 0)) do
      [row | acc]
    else
      next_row = Enum.chunk_every(row, 2, 1, :discard) |&gt; Enum.map(fn [a, b] -&gt; b - a end)
      do_intervals(next_row, [row | acc])
    end
  end

  def apply_intervals(intervals, part \\ 1)

  def apply_intervals(intervals, 1) do
    intervals
    |&gt; Enum.map(&amp;Enum.map(&amp;1, fn row -&gt; Enum.reverse(row) |&gt; hd() end))
    |&gt; Enum.map(&amp;Enum.sum/1)
  end

  def apply_intervals(intervals, 2) do
    intervals
    |&gt; Enum.map(&amp;Enum.map(&amp;1, fn row -&gt; hd(row) end))
    |&gt; Enum.map(&amp;Enum.reduce(&amp;1, fn i, acc -&gt; i - acc end))
  end

  defmodule Part1 do
    def solve(input) do
      input
      |&gt; Day9.parse()
      |&gt; Day9.intervals()
      |&gt; Day9.apply_intervals()
      |&gt; Enum.sum()
    end
  end

  defmodule Part2 do
    def solve(input) do
      input
      |&gt; Day9.parse()
      |&gt; Day9.intervals()
      |&gt; Day9.apply_intervals(2)
      |&gt; Enum.sum()
    end
  end
end
</code></pre>
</details> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="310901" data-batch-url="/posts/batch_likers">
                        2
                      </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-2023-day-9/60260/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-310901" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310901"
                     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="310911" data-post-id="310911">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Built an extrapolate function with <code>map</code> and <code>unfold</code>. Could reuse it for part 2 with minimal adjustments:</p>
<p><a href="https://github.com/pehbehbeh/adventofcode/blob/main/2023/09.livemd" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/pehbehbeh/adventofcode/blob/main/2023/09.livemd</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="310911" data-batch-url="/posts/batch_likers">
                        2
                      </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-2023-day-9/60260/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-310911" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="310911"
                     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="311429" data-post-id="311429">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I just can’t get rid of the impulse to solve this puzzle using Nx and linear algebra.</p>
<p>Here’s my new code with a lot of description about the math.</p>
<p>Please download it to your livebook to see the content because GitHub does not render the LaTeX parts correctly.</p>
<p><a href="https://github.com/Aetherus/advent-of-code/blob/master/2023/day-09-nx.livemd" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/Aetherus/advent-of-code/blob/master/2023/day-09-nx.livemd</a></p>
<p>By the way, the code is fully vectorized so there’s no explicit for-loop or <code>Enum</code> or <code>Stream</code> function calls in solving the equation, except for parsing the input and building the tensors.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="311429" data-batch-url="/posts/batch_likers">
                        2
                      </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-2023-day-9/60260/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-311429" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="311429"
                     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="311520" data-post-id="311520">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Found a bug in <code>Nx.BinaryBackend</code>.</p>
<p>When running <code>Nx.LinAlg.solve(mat_x, mat_y)</code> in a livebook when <code>mat_y</code> has more columns than rows, this error was raised:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">#Inspect.Error&lt;
  got ArgumentError with message:

      """
      errors were found at the given arguments:

        * 3rd argument: out of range
      """

  while inspecting:

      %{
        data: %Nx.BinaryBackend{
          state: &lt;&lt;4, 0, 0, 0, 0, 0, 8, 192, 46, 33, 9, 20, 142, 152, 243, 188, 179, 255, 255, 255, 255,
            255, 19, 64, 4, 0, 0, 0, 0, 0, 8, 192, 46, 33, 9, 20, 142, 152, 243, 188, 179, 255, 255, 255,
            255, 255, 19, 64, ...&gt;&gt;
        },
        type: {:f, 64},
        names: [nil, nil],
        __struct__: Nx.Tensor,
        vectorized_axes: [],
        shape: {6, 7}
      }

  Stacktrace:

    :erlang.binary_part(&lt;&lt;4, 0, 0, 0, 0, 0, 8, 192, 46, 33, 9, 20, 142, 152, 243, 188, 179, 255, 255, 255, 255, 255, 19, 64, 4, 0, 0, 0, 0, 0, 8, 192, 46, 33, 9, 20, 142, 152, 243, 188, 179, 255, 255, 255, 255, 255, 19, 64, 28, 0, ...&gt;&gt;, 0, 336)
    (nx 0.6.4) lib/nx/binary_backend.ex:179: Nx.BinaryBackend.to_binary/2
    (nx 0.6.4) lib/nx/binary_backend.ex:1028: Nx.BinaryBackend.inspect/2
    (nx 0.6.4) lib/nx/tensor.ex:241: Inspect.Nx.Tensor.inspect/2
    (elixir 1.15.7) lib/inspect/algebra.ex:348: Inspect.Algebra.to_doc/2
    (elixir 1.15.7) lib/kernel.ex:2366: Kernel.inspect/2
    (kino 0.12.0) lib/kino/output.ex:21: Kino.Output.inspect/2
    lib/livebook/runtime/evaluator/formatter.ex:62: Livebook.Runtime.Evaluator.Formatter.to_output/1

&gt;
</code></pre>
<p>There’s no error when using <code>EXLA.Backend</code>.</p>
<p>Still digging the source code of <code>Nx.BinaryBackend</code> trying to spot the cause of this error.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="311520" 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-2023-day-9/60260/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-311520" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="311520"
                     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="347967" data-post-id="347967">
  <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>Sharing a year late because I just did it while waiting for 2024 Day 2, and I don’t think anyone else used <code>Enum.uniq</code></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def part1(histories) do
    histories |&gt; Enum.map(&amp;walk/1) |&gt; Enum.sum()
  end

  def walk(history) do
    case Enum.uniq(history) do
      [last] -&gt; last
      _ -&gt; List.last(history) + walk(diff(history))
    end
  end

  def diff([_]), do: []
  def diff([a, b | rest]), do: [b - a | diff([b | rest])]
</code></pre>
<p><a href="https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2023/day9.exs" class="onebox" target="_blank" rel="noopener nofollow ugc">https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2023/day9.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="347967" 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-2023-day-9/60260/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-347967" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="347967"
                     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>