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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I love doing challenges like this and looking at other peoples solutions. I’ve started Advent of Code the past two years but I’ve never finished. I’m determined this year. I started reading Seven Languages in Seven Weeks and plan on attempting them in some of the more obscure languages (namely prolog and io).</p>
<p>Here are my solutions for Day1 and Day2 in elixir, I’m hoping to knock out Day3 tonight as soon as I figure out a pattern in the spiral.</p>
<p><a href="https://github.com/kylethebaker/elixir-advent-of-code-2017/blob/master/lib/day1.ex" rel="noopener nofollow ugc">Day 1</a><br>
<a href="https://github.com/kylethebaker/elixir-advent-of-code-2017/blob/master/lib/day2.ex" rel="noopener nofollow ugc">Day 2</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="60594" 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-2017/10526/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-60594" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60594"
                     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="60615" data-post-id="60615">
  <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>I just solved day 5 and I am quite unhappy with the runtime of my version. Especially the second assignment of today takes a long time. 10 to 15 seconds.</p>
<p>The code can be found in my repo: (but of course it spoils if you haven’t finished yet)</p>
<details><summary>Day 5, second assignment, my slow solution</summary>
<aside class="onebox gitlabblob" data-onebox-src="https://gitlab.com/NobbZ/aoc17/blob/7b0b32f7ff23b7d167630dc05d2181a26fd9ff07/lib/aoc/day5.ex#L12-33">
  <header class="source">

      <a href="https://gitlab.com/NobbZ/aoc17/blob/7b0b32f7ff23b7d167630dc05d2181a26fd9ff07/lib/aoc/day5.ex#L12-33" target="_blank" rel="noopener nofollow">gitlab.com/NobbZ/aoc17</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gitlab.com/NobbZ/aoc17/blob/7b0b32f7ff23b7d167630dc05d2181a26fd9ff07/lib/aoc/day5.ex#L12-33" target="_blank" rel="noopener nofollow">lib/aoc/day5.ex</a></h4>

<div class="git-blob-info">
  <a href="https://gitlab.com/NobbZ/aoc17/blob/7b0b32f7ff23b7d167630dc05d2181a26fd9ff07/lib/aoc/day5.ex#L12-33" rel="noopener nofollow"><code>7b0b32f7f</code></a>
</div>


  <pre class="onebox"><code class="lang-ex">
    <ol class="start lines" start="2" style="counter-reset: li-counter 1 ;">
        <li>use AoC.Default, into: :instructions</li>
        <li></li>
        <li>@default @instructions</li>
        <li>  |&gt; String.split()</li>
        <li>  |&gt; Enum.map(&amp;String.to_integer/1)</li>
        <li></li>
        <li>def a(instructions \\ @default) do</li>
        <li>  do_it(instructions, &amp;(&amp;1 + 1))</li>
        <li>end</li>
        <li></li>
        <li class="selected">def b(instructions \\ @default) do</li>
        <li>  do_it(instructions, fn</li>
        <li>    v when v &gt;= 3 -&gt; v - 1</li>
        <li>    v -&gt; v + 1</li>
        <li>  end)</li>
        <li>end</li>
        <li></li>
        <li>defp do_it(instructions, f) do</li>
        <li>  instructions</li>
        <li>  |&gt; Enum.with_index()</li>
        <li>  |&gt; Enum.into(%{}, fn {n, i} -&gt; {i, n} end)</li>
    </ol>
    </code></pre>


  </article>

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

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

</details>
I'm currently thinking about implementing it with some kind of zypper, but if this would really provide any benefits, I'm unsure... 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="60615" 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-2017/10526/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-60615" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60615"
                     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="60616" data-post-id="60616">
  <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>I was able to speed up the second assignment using some zypper like structure to take about 7 to 9 seconds.</p>
<p>Sadly the first assignment takes about 4 seconds then instead of ~1…</p>
<details><summary>zypper version</summary>
<aside class="onebox gitlabblob" data-onebox-src="https://gitlab.com/NobbZ/aoc17/blob/dea88cb5b1f9aef16c1154a7a862a2433e07be8b/lib/aoc/day5.ex#L12-38">
  <header class="source">

      <a href="https://gitlab.com/NobbZ/aoc17/blob/dea88cb5b1f9aef16c1154a7a862a2433e07be8b/lib/aoc/day5.ex#L12-38" target="_blank" rel="noopener nofollow">gitlab.com/NobbZ/aoc17</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gitlab.com/NobbZ/aoc17/blob/dea88cb5b1f9aef16c1154a7a862a2433e07be8b/lib/aoc/day5.ex#L12-38" target="_blank" rel="noopener nofollow">lib/aoc/day5.ex</a></h4>

<div class="git-blob-info">
  <a href="https://gitlab.com/NobbZ/aoc17/blob/dea88cb5b1f9aef16c1154a7a862a2433e07be8b/lib/aoc/day5.ex#L12-38" rel="noopener nofollow"><code>dea88cb5b</code></a>
</div>


  <pre class="onebox"><code class="lang-ex">
    <ol class="start lines" start="2" style="counter-reset: li-counter 1 ;">
        <li>use AoC.Default, into: :instructions</li>
        <li></li>
        <li>@default @instructions</li>
        <li>  |&gt; String.split()</li>
        <li>  |&gt; Enum.map(&amp;String.to_integer/1)</li>
        <li></li>
        <li>def a(instructions \\ @default) do</li>
        <li>  do_it(instructions, &amp;(&amp;1 + 1))</li>
        <li>end</li>
        <li></li>
        <li class="selected">def b(instructions \\ @default) do</li>
        <li>  do_it(instructions, fn</li>
        <li>    v when v &gt;= 3 -&gt; v - 1</li>
        <li>    v -&gt; v + 1</li>
        <li>  end)</li>
        <li>end</li>
        <li></li>
        <li>defp do_it(instructions, f) do</li>
        <li>  instructions</li>
        <li>  |&gt; prepare()</li>
        <li>  |&gt; walk(f)</li>
    </ol>
    </code></pre>


  </article>

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

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

</details> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I cut my runtime in half (10s to 5s) by using ets instead of a map.. Still ruby does the same in about 2.5s on the same hardware</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="60618" 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-2017/10526/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-60618" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60618"
                     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="60619" data-post-id="60619">
  <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>I get similar times (~ 15 sec), and I also use map to store instructions. I briefly tried with ETS, which shaved a few secs. One thing which I thought of, but didn’t try was to optimize the case where the current instruction is 0. In that case, you can skip extra map store/lookup and immediately move on to the next iteration (though you need to somehow indicate that you made two moves). I didn’t really have the time to try it out, and it would uglify the code, so I just left it as it was.</p> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey all,</p>
<p>I’ve made a private leaderboard if any others want to join: <code>101181-38e9ecde</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="60626" 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-2017/10526/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-60626" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60626"
                     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="60655" data-post-id="60655">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a href="https://github.com/pcorey/advent_of_code_2017/blob/master/05/05.exs" rel="noopener nofollow ugc">Here’s my day 5 solution</a>. I originally kept it simple using list lookups and replacements, and later made it a little faster by reducing the initial list into a map.</p>
<p>I spent some time (way too much time) trying to come up with a divide and conquer or backtracing algorithm to make things more efficient, but the changing offsets seemed to make this impossible. Sub-solutions can’t be guaranteed to be isolated. I’d love to see if someone found an efficient solution.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="60655" 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-2017/10526/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-60655" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60655"
                     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="60777" data-post-id="60777">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="michallepicki" data-post="1" data-topic="10526">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/48.png" class="avatar"> michallepicki:</div>
<blockquote>
<p>Is anyone doing this year’s edition using Elixir</p>
</blockquote>
</aside>
<p>Me! I’m posting my solutions here: <a href="https://github.com/aarvay/advent/tree/master/2017" class="inline-onebox" rel="noopener nofollow ugc">advent/2017 at master · aarvay/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="60777" 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-2017/10526/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-60777" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60777"
                     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="60864" data-post-id="60864">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Same, even though I’m using a handful of different languages - not exclusively Elixir: <a href="https://github.com/nicbet/advent-of-code" class="inline-onebox" rel="noopener nofollow ugc">GitHub - nicbet/advent-of-code: The Advent of Code Programming Puzzles · 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="60864" 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-2017/10526/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-60864" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60864"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="60883" data-post-id="60883">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here’s my <a href="https://github.com/pcorey/advent_of_code_2017/blob/master/06/06.exs" rel="noopener nofollow ugc">day 6 solution</a>. It was nice how part 2 fell into place.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="60883" 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-2017/10526/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-60883" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="60883"
                     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 #20"></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/10526/load_more?page=3">Load more posts (83 remaining)</a>
</div></template></turbo-stream>