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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="faried" data-post="5" data-topic="27250">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/faried/48/17538_2.png" class="avatar"> faried:</div>
<blockquote>
<p>What’s interesting is that I read <a href="https://forum.elixirforum.com/u/sasajuric" rel="nofollow">sasajuric</a>’s solution, adapted it, and it seems to run slower (!) than what I have: 175769 microseconds for my part2, 682567 for theirs. Maybe it’s because of all the destructuring? Both solutions in one <a href="https://gist.github.com/faried/2a8640d5b2b75fd5a90127ce908c0040" rel="noopener nofollow ugc">file</a></p>
</blockquote>
</aside>
<p>My first guess would be that your solution is faster b/c you’re using spawn, which means you’re leveraging multiple cores. The <code>Enum.find</code> version is sequential.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="152980" 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-2019-day-2/27250/10">Post #9</a>
	                </div>
	            </div>
              <div id="likers-container-152980" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152980"
                     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 #9"></div>
  </section>
</div>
    <div class="postbit" id="152973" data-post-id="152973">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That’s cool. Didn’t know about <code>:array</code> from Erlang.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="152973" 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-2019-day-2/27250/9">Post #8</a>
	                </div>
	            </div>
              <div id="likers-container-152973" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152973"
                     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 #8"></div>
  </section>
</div>
    <div class="postbit" id="152970" data-post-id="152970">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Finaly I found some time to do it. And a small typo took me half an hour to figure out the problem… I did <code>for noun &lt;- 0..99, verb &lt;- 0..9 do … end</code>…</p>
<aside class="onebox gitlabblob" data-onebox-src="https://gitlab.com/NobbZ/aoc_ex/blob/master/lib/y2019/d2.ex">
  <header class="source">

      <a href="https://gitlab.com/NobbZ/aoc_ex/blob/master/lib/y2019/d2.ex" target="_blank" rel="noopener nofollow">gitlab.com/NobbZ/aoc_ex</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gitlab.com/NobbZ/aoc_ex/blob/master/lib/y2019/d2.ex" target="_blank" rel="noopener nofollow">lib/y2019/d2.ex</a></h4>

<div class="git-blob-info">
  <a href="https://gitlab.com/NobbZ/aoc_ex/blob/master/lib/y2019/d2.ex" rel="noopener nofollow"><code>master</code></a>
</div>

  <pre><code class="lang-ex">defmodule AocEx.Y2019.D2 do
  use AocEx.Boilerplate,
    transform: fn raw -&gt;
      raw
      |&gt; String.split(",")
      |&gt; Enum.map(&amp;String.to_integer/1)
      |&gt; AocEx.Y2019.IntcodeVM.new()
    end

  alias AocEx.Y2019.IntcodeVM

  def part1(input \\ processed()) do
    input
    |&gt; IntcodeVM.poke(1, 12)
    |&gt; IntcodeVM.poke(2, 2)
    |&gt; IntcodeVM.exec()
    |&gt; IntcodeVM.peek(0)
  end

  def part2(input \\ processed()) do
</code></pre>


  This file has been truncated. <a href="https://gitlab.com/NobbZ/aoc_ex/blob/master/lib/y2019/d2.ex" target="_blank" rel="noopener nofollow">show original</a>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="152970" 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-2019-day-2/27250/8">Post #7</a>
	                </div>
	            </div>
              <div id="likers-container-152970" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152970"
                     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 #7"></div>
  </section>
</div>
    <div class="postbit" id="152965" data-post-id="152965">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m learning Elixir currently, and here is my mine: <a href="https://gitlab.com/KonradBorowski/advent_of_code_2019/blob/master/lib/day2.ex" class="inline-onebox" rel="noopener nofollow ugc">lib/day2.ex · master · Konrad Borowski / advent_of_code_2019 · GitLab</a></p>
<p>I’m pretty sure it can be improved, but I quite like what I have 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="152965" 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-2019-day-2/27250/7">Post #6</a>
	                </div>
	            </div>
              <div id="likers-container-152965" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152965"
                     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 #6"></div>
  </section>
</div>
    <div class="postbit" id="152958" data-post-id="152958">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here is mine: <a href="https://github.com/egze/aoc/blob/master/lib/aoc/y2019/d2.ex" class="inline-onebox" rel="noopener nofollow ugc">aoc/lib/aoc/y2019/d2.ex at master · egze/aoc · GitHub</a></p>
<p>Thanks <a class="mention" href="/u/nobbz" rel="nofollow">@NobbZ</a> for the boilerplate.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="152958" 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-2019-day-2/27250/6">Post #5</a>
	                </div>
	            </div>
              <div id="likers-container-152958" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152958"
                     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 #5"></div>
  </section>
</div>
    <div class="postbit" id="152956" data-post-id="152956">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m learning Elixir, and didn’t know about <code>Enum.find</code>; I couldn’t figure out how to do an early return from inside <code>for noun &lt;- 0..100,  verb &lt;- 0..100, do: ...</code>, so I picked a terrible way to do handle it: <a href="https://github.com/danhimalplanet/advent/blob/master/2019/self/day02/day02.exs" rel="noopener nofollow ugc">spawn 10k processes</a>! (I finished reading the <em>Concurrent Programming</em> section of <em>Programming Elixir</em> last night.)</p>
<p>What’s interesting is that I read <a href="https://forum.elixirforum.com/u/sasajuric" rel="nofollow">sasajuric</a>’s solution, adapted it, and it seems to run slower (!) than what I have: 175769 microseconds for my part2, 682567 for theirs.  Maybe it’s because of all the destructuring?  Both solutions in one <a href="https://gist.github.com/faried/2a8640d5b2b75fd5a90127ce908c0040" rel="noopener nofollow ugc">file</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="152956" 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-2019-day-2/27250/5">Post #4</a>
	                </div>
	            </div>
              <div id="likers-container-152956" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152956"
                     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 #4"></div>
  </section>
</div>
    <div class="postbit" id="152951" data-post-id="152951">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Nice solution based on <code>Stream</code>, and <code>Function.info/1</code> I’ve never thought about before <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"></p>
<p><a href="https://github.com/qhwa/AdventOfCode/blob/master/lib/aoc/2019/day02.ex" rel="noopener nofollow ugc">Here’s</a> my version.<br>
I did the input parsing in compile time so it was a bit faster. I found that in later puzzles the input might take more time to parse (it happened before).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="152951" 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-2019-day-2/27250/4">Post #3</a>
	                </div>
	            </div>
              <div id="likers-container-152951" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152951"
                     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 #3"></div>
  </section>
</div>
    <div class="postbit" id="152927" data-post-id="152927">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a href="https://github.com/sasa1977/aoc/blob/master/lib/2019/201902.ex" rel="noopener nofollow ugc">This</a> is my take. It’s not super fast (takes about 2 sec on my machine for part 2), but does the job.</p>
<p>The most interesting part to me is instruction execution. I define the <a href="https://github.com/sasa1977/aoc/blob/master/lib/2019/201902.ex#L44-L50" rel="noopener nofollow ugc">instruction mapping</a>, and then have a <a href="https://github.com/sasa1977/aoc/blob/master/lib/2019/201902.ex#L37-L42" rel="noopener nofollow ugc">generic exec function</a> which interprets the instruction, fetching the correct amount of arguments based on the arity.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="152927" 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-2019-day-2/27250/3">Post #2</a>
	                </div>
	            </div>
              <div id="likers-container-152927" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152927"
                     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 #2"></div>
  </section>
</div>
    <div class="postbit" id="152922" data-post-id="152922">
  <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
                    <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 class="user-title">
									<span>Erlang Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here is <a href="https://github.com/bjorng/advent-of-code-2019/blob/71e7d676226cac45a8c5c5c2c9e791027c3f705a/day02/lib/day02.ex" rel="noopener nofollow ugc">my solution</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="152922" data-batch-url="/posts/batch_likers">
                        3
                      </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-2019-day-2/27250/2">Post #1</a>
	                </div>
	            </div>
              <div id="likers-container-152922" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="152922"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-first-post cat-first-post" title="First 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>