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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I learned a lot from the discussions in this thread <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> thank you everyone.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197654" 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-2020-day-14/36199/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-197654" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197654"
                     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="197656" data-post-id="197656">
  <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>Seems the link was broken. Take two:</p>
<p><a href="https://github.com/adamu/AdventOfCode2020/blob/main/day14/README" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/adamu/AdventOfCode2020/blob/main/day14/README</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="197656" 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-2020-day-14/36199/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-197656" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197656"
                     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="197738" data-post-id="197738">
  <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>This horse is dead but I’m going to continue to  beat it.<br>
For part 2 I’m trying this to generate the permutations of masks in a tuple with a <code>one_mask</code> that sets all the Xs to zero:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def process_mask(mask, 2) do
    one_mask = mask |&gt; String.replace("X", "0") |&gt; String.to_integer(2)
    parts = mask |&gt; String.replace("1", "0") |&gt; String.split("X", trim: true)

    {one_mask, process_masks(parts, [])}
  end

  def process_masks([part | rest], []) do
    process_masks(rest, [part &lt;&gt; "0", part &lt;&gt; "1"])
  end

  def process_masks([part | rest], masks) do
    masks =
      masks
      |&gt; Enum.flat_map(fn digits -&gt; [digits &lt;&gt; "0" &lt;&gt; part, digits &lt;&gt; "1" &lt;&gt; part] end)

    process_masks(rest, masks)
  end

  def process_masks([], masks) do
    masks
    |&gt; Enum.map(&amp;String.to_integer(&amp;1, 2))
  end
</code></pre>
<p>To apply the masks and build the memory map I’m doing this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def build_mem_map(processed_lines, version \\ 1) do
    processed_lines
    |&gt; Enum.reduce(%{}, fn {mask, assignments}, memory -&gt;
      assign_memory(mask, assignments, memory, version)
    end)
  end

  def assign_memory(masks, assignments, memory, 2 = version) do
    assignments
    |&gt; Enum.map(&amp;apply_mask(&amp;1, masks, version))
    |&gt; Enum.reduce(memory, fn assign, acc -&gt; update_memory(assign, acc, version) end)

    # |&gt; Enum.reduce(%{}, fn map, acc -&gt; Map.merge(acc, map) end)
  end
  def apply_mask({address, value}, {one_mask, x_masks}, 2) do
    x_masks
    |&gt; Enum.map(fn x_mask -&gt; (address ||| one_mask) &amp;&amp;&amp; x_mask end)
    |&gt; Enum.map(fn address -&gt; {address, value} end)
  end

  def update_memory(assignments, memory, 2) do
    assignments
    |&gt; Enum.reduce(memory, fn assign, acc -&gt; update_memory(assign, acc, 1) end)
  end

</code></pre>
<p>I’m guessing my bitmask operations are a misunderstanding of the prompts rules again because I keep getting it wrong. From the prompt:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">address: 000000000000000000000000000000101010  (decimal 42)
mask:    000000000000000000000000000000X1001X
result:  000000000000000000000000000000X1101X
</code></pre>
<p>which looks to me like an <code>|||</code> operation for one bits. I think I’m getting it wrong by doing the next <code>&amp;&amp;&amp;</code> operation. But it seems like a mask of <code>000000000000000000000000000000X1001X</code> would become four masks of</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">000000000000000000000000000000100000
000000000000000000000000000000100001
000000000000000000000000000000000000
000000000000000000000000000000000001
</code></pre>
<p>which I think is the problem. Applying an &amp;&amp;&amp; to the all zero mask will be zero, which is incorrect. Inverting the order and applying the x_mask first and then doing an ||| for the one_mask is also wrong though. What’s the concept I’m missing here?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197738" 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-2020-day-14/36199/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-197738" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197738"
                     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="197741" data-post-id="197741">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Like you said, you can’t use &amp;&amp;&amp; to set a bit value to 1.</p>
<p>Basically what you want is an ability to set bit to either 0 or 1 irrespective of other value X. You can’t do that with just one operator.</p>
<p>For setting 0: x &amp;&amp;&amp; 0<br>
For setting 1: x ||| 1</p>
<p>There are many ways to express this logic with different combination of bitwise operators.</p>
<p>Specific to this problem, one way to do it is to set all x bits to zero explicitly at the beginning and do lll with your generated mask</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197741" 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-2020-day-14/36199/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-197741" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197741"
                     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="197744" data-post-id="197744">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can try, <code>((address ||| one_mask) &amp;&amp;&amp; ~~~x_mask) ||| x_mask</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="197744" 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-2020-day-14/36199/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-197744" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197744"
                     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="197745" data-post-id="197745">
  <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>no dice. I’m going to have to re-organize the masking to branch at the apply step rather than at the processing input step. Thanks for your explanation.</p>
<p>This problem is going to haunt me forever, but I just can’t get it to work.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197745" 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-2020-day-14/36199/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-197745" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197745"
                     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="197782" data-post-id="197782">
  <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">
								<aside class="quote no-group" data-username="stevensonmt" data-post="24" data-topic="36199">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/stevensonmt/48/20503_2.png" class="avatar"> stevensonmt:</div>
<blockquote>
<p>I’m guessing my bitmask operations are a misunderstanding of the prompts rules again because I keep getting it wrong. From the prompt:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">address: 000000000000000000000000000000101010  (decimal 42)
mask:    000000000000000000000000000000X1001X
result:  000000000000000000000000000000X1101X
</code></pre>
<p>which looks to me like an <code>|||</code> operation for one bits. I think I’m getting it wrong by doing the next <code>&amp;&amp;&amp;</code> operation. But it seems like a mask of <code>000000000000000000000000000000X1001X</code> would become four masks of</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">000000000000000000000000000000100000
000000000000000000000000000000100001
000000000000000000000000000000000000
000000000000000000000000000000000001
</code></pre>
</blockquote>
</aside>
<p>I made the same mistake originally. You are substituting the Xs in the <em>mask</em>, but what you need to do is substitute the Xs in the <em>masked value</em>.</p>
<p>Step 1: Apply <code>mask</code> to <code>address</code>, to produce <code>result</code>.<br>
Step 2: Permute all the Xs in the <code>result</code>, which produces:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">000000000000000000000000000000011010  (decimal 26)
000000000000000000000000000000011011  (decimal 27)
000000000000000000000000000000111010  (decimal 58)
000000000000000000000000000000111011  (decimal 59)
</code></pre>
<p>So you need to make sure your mask operation preserves the Xs.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197782" 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-2020-day-14/36199/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-197782" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197782"
                     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="197788" data-post-id="197788">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I took a look at your code, I think your approach is mostly correct, but there seems to be few issues with the code for generating the masks.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def process_masks([part | rest], []) do
    process_masks(rest, [part &lt;&gt; "0", part &lt;&gt; "1"])
  end

  def process_masks([part | rest], masks) do
    masks =
      masks
      |&gt; Enum.flat_map(fn digits -&gt; [digits &lt;&gt; "0" &lt;&gt; part, digits &lt;&gt; "1" &lt;&gt; part] end)

    process_masks(rest, masks)
  end

  def process_masks([], masks) do
    masks
    |&gt; Enum.map(&amp;String.to_integer(&amp;1, 2))
  end
</code></pre>
<p>Let’s consider generating masks for <code>0X0</code>, expected <code>000, 010</code></p>
<pre><code class="lang-plaintext">mask: 0X0 -&gt; parts: [0, 0]

process_masks([0,0], []) =&gt; 
   process_masks([0], [00, 01]) =&gt; 
      # Now we are at the second function, `def process_masks([part | rest], masks)`
      # 
      # here are creating new permutation by considering part=0, which is wrong 
      # because there is only one "X" in the input. 
      #    length(part) != number of x
      # 
      # after `flat_map`, masks = [0000, 0010, 0100, 0110] which is  [0, 2, 4, 6] 
</code></pre>
<p>Also, there is another issue, you are using <code>trim: true</code>,</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">iex(1)&gt; String.split("0X", "X", trim: true)
["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="197788" 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-2020-day-14/36199/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-197788" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197788"
                     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="197827" data-post-id="197827">
  <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>Thanks for taking the time to review the code. I really appreciate it. For some reason I remember struggling to pattern match on <code>process_masks([head | []], acc)</code> but I guess I need a case statement to handle that. The trim issue is a true brain fart. Thank you for pointing that out.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197827" 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-2020-day-14/36199/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-197827" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197827"
                     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="198246" data-post-id="198246">
  <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’ve narrowed down the error (at least I think so) but still don’t know why it’s happening. For the dataset:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">mask = 1XX010X01110X110100000X11101X10X0X11
mem[3513] = 1787222
mem[11652] = 13761
mem[25508] = 235920
mem[49386] = 7440645
mem[51287] = 197564380
mem[9697] = 1812
mem[62638] = 5207143
</code></pre>
<p>I get a sum that is off by the sum of values of the 4th memory entry (<code>mem[49386] = 7440645</code>) after the mask is applied. Applying the mask generates a correct value (I checked using successful algorithms posted in this thread). For some reason this address is being duplicated by my algorithm. I really suspect it is in this bit:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def flip_bits(acc, []), do: acc

  def flip_bits(acc, [x | rest]) do
    acc
    |&gt; Enum.flat_map(fn digits -&gt;
      [List.update_at(digits, x, fn _ -&gt; 1 end), List.update_at(digits, x, fn _ -&gt; 0 end)]
    end)
    |&gt; flip_bits(rest)
  end
</code></pre>
<p>The initial value for <code>acc</code> is a list containing the list of digits of the original address in binary after applying the one mask and padding to length 36. The argument <code>[x | rest]</code> is a list of indices in the mask at which an “X” was identified.</p>
<p>I cannot understand what is special about this one memory address that it gets duplicated. If I remove that one address I get the same answer as the successful algorithm. When I use the entire dataset my solution is off by more than just the value of this one entry, so it is clearly not JUST this value that is problematic. My hope is that someone can help me identify why this entry is problematic so that I can understand the flaw in my logic that generates what currently seems to me a random error.</p>
<p>Full code here: <a href="https://gist.github.com/stevensonmt/348e60393b0195369137da5237e99e59" class="inline-onebox" rel="noopener nofollow ugc">flawed Advent of Code 2020 day 14 part 2 · 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="198246" 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-2020-day-14/36199/31">Post #30</a>
	                </div>
	            </div>
              <div id="likers-container-198246" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="198246"
                     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/36199/load_more?page=4">Load more posts (1 remaining)</a>
</div></template></turbo-stream>