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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I thought I could edit my post <img src="https://forum.elixirforum.com/images/emoji/apple/japanese_goblin.png?v=15" title=":japanese_goblin:" class="emoji" alt=":japanese_goblin:" loading="lazy" width="20" height="20"><br>
Anyway, <a class="mention" href="/u/bjorng" rel="nofollow">@bjorng</a></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">input
|&gt; Input.stream!(trim: true) #=&gt; #Stream&lt;[
  enum: %File.Stream{
    path: "/home/ken/aoc_2024/priv/input/2024/day-21.inp",
    modes: [:raw, :read_ahead, :binary],
    line_or_bytes: :line,
    raw: true,
    node: :nonode@nohost
  },
  funs: [#Function&lt;49.118167795/1 in Stream.map/2&gt;,
   #Function&lt;39.118167795/1 in Stream.filter/2&gt;]
]&gt;
|&gt; Enum.map(fn code -&gt;
  {number, _} = Integer.parse(code)
  {number, code}
end) #=&gt; [{803, "803A"}, {528, "528A"}, {586, "586A"}, {341, "341A"}, {319, "319A"}]

[lib/aoc_2024/solutions/y24/day21.ex:15: Aoc2024.Solutions.Y24.Day21.parse/2]
parse2(Input.stream!(input, trim: true)) #=&gt; [{803, "803A"}, {528, "528A"}, {586, "586A"}, {341, "341A"}, {319, "319A"}]
</code></pre>
<p><code>parse2</code> is your function - they return the same. I checked every other line of code multiple times, nothing stands out to me - everything is the same AFAIK. I’m flabbergasted to say the least. <img src="https://forum.elixirforum.com/images/emoji/apple/face_with_monocle.png?v=15" title=":face_with_monocle:" class="emoji" alt=":face_with_monocle:" loading="lazy" width="20" height="20"> <img src="https://forum.elixirforum.com/images/emoji/apple/joy.png?v=15" title=":joy:" class="emoji" alt=":joy:" loading="lazy" width="20" height="20"></p>
<p>Here is some more debug data I ran with <code>pads = [numeric() | List.duplicate(direct(), 3)]</code>:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">"BUTTONS ~c\"^&gt;A\""
[lib/aoc_2024/solutions/y24/day21.ex:103: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
cache_key #=&gt; {65, {1, 2}, 2}

"LENGTH OF PADS 2"
[lib/aoc_2024/solutions/y24/day21.ex:105: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
pad #=&gt; %Aoc2024.Solutions.Y24.Day21.Keypad{
  position: {1, 2},
  grid: %{
    {0, 0} =&gt; :panic,
    {0, 1} =&gt; {-1, 0},
    {0, 2} =&gt; :activate,
    {1, 0} =&gt; {0, -1},
    {1, 1} =&gt; {1, 0},
    {1, 2} =&gt; {0, 1}
  },
  parse: #Function&lt;1.134059619/1 in Aoc2024.Solutions.Y24.Day21.vector_dir&gt;
}

[lib/aoc_2024/solutions/y24/day21.ex:107: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
Process.get(cache_key) #=&gt; {{17},
 %Aoc2024.Solutions.Y24.Day21.Keypad{
   position: {3, 2},
   grid: %{
     {0, 0} =&gt; 7,
     {0, 1} =&gt; 8,
     {0, 2} =&gt; 9,
     {1, 0} =&gt; 4,
     {1, 1} =&gt; 5,
     {1, 2} =&gt; 6,
     {2, 0} =&gt; 1,
     {2, 1} =&gt; 2,
     {2, 2} =&gt; 3,
     {3, 0} =&gt; :panic,
     {3, 1} =&gt; 0,
     {3, 2} =&gt; :activate
   },
   parse: #Function&lt;2.134059619/1 in Aoc2024.Solutions.Y24.Day21.numeric/0&gt;
 }}

"VALUE FOUND"
[lib/aoc_2024/solutions/y24/day21.ex:138: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
pad #=&gt; %Aoc2024.Solutions.Y24.Day21.Keypad{
  position: {3, 2},
  grid: %{
    {0, 0} =&gt; 7,
    {0, 1} =&gt; 8,
    {0, 2} =&gt; 9,
    {1, 0} =&gt; 4,
    {1, 1} =&gt; 5,
    {1, 2} =&gt; 6,
    {2, 0} =&gt; 1,
    {2, 1} =&gt; 2,
    {2, 2} =&gt; 3,
    {3, 0} =&gt; :panic,
    {3, 1} =&gt; 0,
    {3, 2} =&gt; :activate
  },
  parse: #Function&lt;2.134059619/1 in Aoc2024.Solutions.Y24.Day21.numeric/0&gt;
}

"BUTTONS ~c\"&gt;^A\""
[lib/aoc_2024/solutions/y24/day21.ex:103: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
cache_key #=&gt; {62, {3, 2}, 2}

"LENGTH OF PADS 2"
[lib/aoc_2024/solutions/y24/day21.ex:105: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
pad #=&gt; %Aoc2024.Solutions.Y24.Day21.Keypad{
  position: {3, 2},
  grid: %{
    {0, 0} =&gt; 7,
    {0, 1} =&gt; 8,
    {0, 2} =&gt; 9,
    {1, 0} =&gt; 4,
    {1, 1} =&gt; 5,
    {1, 2} =&gt; 6,
    {2, 0} =&gt; 1,
    {2, 1} =&gt; 2,
    {2, 2} =&gt; 3,
    {3, 0} =&gt; :panic,
    {3, 1} =&gt; 0,
    {3, 2} =&gt; :activate
  },
  parse: #Function&lt;2.134059619/1 in Aoc2024.Solutions.Y24.Day21.numeric/0&gt;
}

[lib/aoc_2024/solutions/y24/day21.ex:107: Aoc2024.Solutions.Y24.Day21.press_recursive/2]
Process.get(cache_key) #=&gt; nil

"&gt;"
part_two: Aoc2024.Solutions.Y24.Day21.part_two/1 error: ** (CaseClauseError) no case clause matching: 62
    (aoc_2024 0.1.0) lib/aoc_2024/solutions/y24/day21.ex:53: anonymous fn/1 in Aoc2024.Solutions.Y24.Day21.numeric/0
    (aoc_2024 0.1.0) lib/aoc_2024/solutions/y24/day21.ex:178: Aoc2024.Solutions.Y24.Day21.Keypad.press/2
    (aoc_2024 0.1.0) lib/aoc_2024/solutions/y24/day21.ex:124: anonymous fn/3 in Aoc2024.Solutions.Y24.Day21.press_recursive/2
    (elixir 1.18.0) lib/enum.ex:1840: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (aoc_2024 0.1.0) lib/aoc_2024/solutions/y24/day21.ex:115: anonymous fn/2 in Aoc2024.Solutions.Y24.Day21.press_recursive/2
    (elixir 1.18.0) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
    (aoc_2024 0.1.0) lib/aoc_2024/solutions/y24/day21.ex:114: anonymous fn/3 in Aoc2024.Solutions.Y24.Day21.press_recursive/2
    (elixir 1.18.0) lib/enum.ex:1840: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
</code></pre>
<p>The previous step succeeded because cache was found, but for the fail step nothing was found. <img src="https://forum.elixirforum.com/images/emoji/apple/thinking.png?v=15" title=":thinking:" class="emoji" alt=":thinking:" loading="lazy" width="20" height="20"> I’ll give it another go later, this is a puzzle beyond advent of code for me, an exercise in debugging. <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> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="352026" 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-21/68279/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-352026" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="352026"
                     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="352027" data-post-id="352027">
  <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">
								<p><code>AoC.Input.stream!(path)</code> is just <code>File.stream!(path)</code></p>
<p><code>AoC.Input.stream!(path, trim: true)</code> is the same mapped with this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">      stream
      |&gt; Stream.map(&amp;String.trim/1)
      |&gt; Stream.filter(fn
        "" -&gt; false
        _ -&gt; true
      end)
</code></pre>
<p><a class="mention" href="/u/ken-kost" rel="nofollow">@ken-kost</a> your code works on my machine and finds the right answer with my input. I just copypasted everything and replaced the <code>Aoc2024</code> namespace with my own.</p>
<p>EDIT: OK I can reproduce it now. I was testing in an ExUnit test and it worked properly, but not straight from iex</p>
<p>EDIT2: OK I get it, it’s the part 1 that pollutes the process dictionary for part two. I guess you tried to run that with <code>mix aoc.run</code> and it keeps the same process. I’m very sorry for all the time you lost because of it. I’ll make sure to spawn a new process in the command to prevent process dictionary cache pollution.</p> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>I’m very sorry for all the time you lost because of it</p>
</blockquote>
<p>It’s totally fine, I’m glad you figured it out. <img src="https://forum.elixirforum.com/images/emoji/apple/tada.png?v=15" title=":tada:" class="emoji" alt=":tada:" loading="lazy" width="20" height="20"><br>
Yea, I do <code>mix aoc.run</code></p>
<p>I enjoy using your lib, consider me QA. <img src="https://forum.elixirforum.com/images/emoji/apple/japanese_ogre.png?v=15" title=":japanese_ogre:" class="emoji" alt=":japanese_ogre:" loading="lazy" width="20" height="20"></p>
<p>So the process dictionary got polluted. Interesting. Makes sense now in hindsight. <img src="https://forum.elixirforum.com/images/emoji/apple/face_with_peeking_eye.png?v=15" title=":face_with_peeking_eye:" class="emoji" alt=":face_with_peeking_eye:" 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="352037" 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-21/68279/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-352037" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="352037"
                     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="352042" data-post-id="352042">
  <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">
								<p>&lt;3</p>
<p>I guess because how you compute the cache level. But I am not sure why.</p>
<p>When I read your code I see that the cache key (using length(pads)) should have <code>0</code> for the numeric keypad, as it enters map_reduce first.</p>
<p>But I probably missed some logic because on part_one with this code:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">        [pad | pads] -&gt;
          pad_is_numeric? =
            case map_size(pad.grid) do
              12 -&gt; true
              6 -&gt; false
            end

          if pad_is_numeric? do
            length(pads) |&gt; dbg()
          end

          cache_key = {button, pad.position, length(pads)}
</code></pre>
<p>You get <code>2</code>,</p>
<p>And on part_two you get <code>25</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="352042" 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-21/68279/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-352042" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="352042"
                     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="352048" data-post-id="352048">
  <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">
								<p><a class="mention" href="/u/ken-kost" rel="nofollow">@ken-kost</a> Can you upgrade :aoc to <code>0.14.0</code> and tell me if it’s working?</p> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yep, working. <img src="https://forum.elixirforum.com/images/emoji/apple/+1.png?v=15" title=":+1:" class="emoji" alt=":+1:" 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="352052" 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-21/68279/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-352052" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="352052"
                     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>