<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="62321" data-post-id="62321">
  <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 glanced your solution on my mobile, but I don’t get how or why it works right now…</p>
<p>I do have found a solution using rustler, but it is my personal goal to find a pure elixir solution for every day that fits into the ex_unit default timeout of 60 seconds…</p>
<p>In the meantime I talked to some other people, they used other languages and printed out every iteration, they reported it seems as if there were a repeating patttern, at least visually.</p>
<p>As I’m the only one of us 3 that actually solved part 2 so far, I might redo part 2 and look out for repetition.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62321" 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/72">Post #71</a>
	                </div>
	            </div>
              <div id="likers-container-62321" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62321"
                     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 #71"></div>
  </section>
</div>
    <div class="postbit" id="62328" data-post-id="62328">
  <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>Yes, I was pretty sure that brute-forcing won’t work here, so I felt there had to be some way to radically reduce the number of dances. I went down some wrong paths, before trying to the cycle, and there it was, after only 60 dances <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>I’m not very happy with this solution, as I’m not really sure about how long a cycle can be. I went to the reddit thread to see how others solved it. Most of them also went for the cycle detection. However, I discovered <a href="https://www.reddit.com/r/adventofcode/comments/7k572l/2017_day_16_solutions/drbqb27/" rel="noopener nofollow ugc">this solution</a> which I find highly elegant, and it works very fast. It took me a bit to figure it out, but now that I do, I really like it. I didn’t have the time to code it in Elixir, but it shouldn’t be complicated.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62328" 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/73">Post #72</a>
	                </div>
	            </div>
              <div id="likers-container-62328" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62328"
                     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 #72"></div>
  </section>
</div>
    <div class="postbit" id="62349" data-post-id="62349">
  <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 <a href="https://github.com/pcorey/advent_of_code_2017/blob/master/16/16.exs" rel="noopener nofollow ugc">my day 16 solution</a>. The code itself isn’t too elegant, but I’m happy that I found a fast solution to part 2. That definitely took some outside of the box thinking, though.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62349" 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/74">Post #73</a>
	                </div>
	            </div>
              <div id="likers-container-62349" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62349"
                     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 #73"></div>
  </section>
</div>
    <div class="postbit" id="62356" data-post-id="62356">
  <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>My rust version I pushed so far didn’t even work <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p>
<p>It times out as well, <strong>but</strong> due to some happy coincidents, my cycle has the same modulo for 1000 and for 1000000000…</p>
<p>But I do have a pure elixir version now which runs in ~2 seconds.</p>
<p>I’ll do some cleanup and then push it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62356" 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/75">Post #74</a>
	                </div>
	            </div>
              <div id="likers-container-62356" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62356"
                     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 #74"></div>
  </section>
</div>
    <div class="postbit" id="62393" data-post-id="62393">
  <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>Day 17 was kind of easy after you realized the naive version for part1 is to slow for part2.</p>
<aside class="onebox githubgist" data-onebox-src="https://gist.github.com/kwando/cc3515a45070d3ced68f4a46d2044c27">
  <header class="source">

      <a href="https://gist.github.com/kwando/cc3515a45070d3ced68f4a46d2044c27" target="_blank" rel="noopener nofollow ugc">gist.github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gist.github.com/kwando/cc3515a45070d3ced68f4a46d2044c27" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/kwando/cc3515a45070d3ced68f4a46d2044c27</a></h4>



  </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="62393" 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/76">Post #75</a>
	                </div>
	            </div>
              <div id="likers-container-62393" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62393"
                     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 #75"></div>
  </section>
</div>
    <div class="postbit" id="62395" data-post-id="62395">
  <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>Agreed, it was much easier than yesterday, as soon as you spot the trick for part 2 (which is IMO not all that hard, and there’s even a hint in the task description).</p>
<p><a href="https://gist.github.com/sasa1977/97e97e69eefb1f98bc6f405eccf88a4d" rel="noopener nofollow ugc">Here</a>’s my take. After a bit of experiments, I also went for a basic recursion, as it provides fastest running times (~ 2sec on my machine).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62395" 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/77">Post #76</a>
	                </div>
	            </div>
              <div id="likers-container-62395" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62395"
                     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 #76"></div>
  </section>
</div>
    <div class="postbit" id="62417" data-post-id="62417">
  <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>Apparently I missed that hint. I spent more time thinking about a solution to day 17’s part two than day 16. <a href="https://github.com/pcorey/advent_of_code_2017/blob/master/17/17.exs" rel="noopener nofollow ugc">Here’s the solution I landed on.</a> I’m not sure if I took the best route (I’ll have to check out your solution), but mine takes ~7 seconds on my machine.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62417" 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/78">Post #77</a>
	                </div>
	            </div>
              <div id="likers-container-62417" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62417"
                     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 #77"></div>
  </section>
</div>
    <div class="postbit" id="62426" data-post-id="62426">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve fallen a bit behind but managed to get back on track today.</p>
<p>For <a href="https://github.com/MitjaBezensek/advent-of-code/blob/master/advent14.exs" rel="noopener nofollow ugc">Day 14 part 2</a> I used the logic for counting groups from Day 12. I just had to create a list of connections for each disk space, so that I could use the Day 12 solution. It seems we can use some old solutions for other puzzles as well! I’m really liking how the whole Advent of code is thought out.</p>
<p><a href="https://github.com/MitjaBezensek/advent-of-code/blob/master/advent15.exs" rel="noopener nofollow ugc">Day 15</a> seemed one of the easiest.</p>
<p>I accidentally stumbled upon the solution for <a href="https://github.com/MitjaBezensek/advent-of-code/blob/master/advent16.exs" rel="noopener nofollow ugc">Day 16 part II</a>, because I was printing out the order of the programs after each application of dance moves. My dances began cycling at 30 already and on top of that the cycle started at the first move. I didn’t bother to implement a general solution since I guess that the cycling could start at some random repetition and not necessarily the first one.</p>
<p>Since printing out solutions of each step in Day 16 helped me find the solution I also started printing out the solutions for Day 17 and again this helped me <a href="https://github.com/MitjaBezensek/advent-of-code/blob/master/advent17.exs" rel="noopener nofollow ugc">spot the trick.</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="62426" 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/79">Post #78</a>
	                </div>
	            </div>
              <div id="likers-container-62426" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62426"
                     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 #78"></div>
  </section>
</div>
    <div class="postbit" id="62492" data-post-id="62492">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here is day 12</p><aside class="onebox githubgist" data-onebox-src="https://gist.github.com/maruks/af0a24d39de18480c54e966f962d1c77">
  <header class="source">

      <a href="https://gist.github.com/maruks/af0a24d39de18480c54e966f962d1c77" target="_blank" rel="noopener nofollow ugc">gist.github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gist.github.com/maruks/af0a24d39de18480c54e966f962d1c77" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/maruks/af0a24d39de18480c54e966f962d1c77</a></h4>



  </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="62492" 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/80">Post #79</a>
	                </div>
	            </div>
              <div id="likers-container-62492" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62492"
                     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 #79"></div>
  </section>
</div>
    <div class="postbit" id="62518" data-post-id="62518">
  <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://gist.github.com/sasa1977/7e0ebc2e36072bf90bcb139e02558f65" rel="noopener nofollow ugc">Here</a>’s my take for day 18. I spent some time refactoring the code to extract common parts. I have a “core” machine which contains only the features needed in both parts. Then on top of that I build specific machines for each part. Finally, I have the <a href="https://gist.github.com/sasa1977/7e0ebc2e36072bf90bcb139e02558f65#file-aoc2017_day18-ex-L122-L129" rel="noopener nofollow ugc">common executor</a> which runs the machine until it’s done, and spits out its output. It would likely be cleaner if I had turned the core machine into a behaviour, and moved the execute function there, but I already spent too much time on the refactoring, so I left it in this shape.</p>
<p>Although the 2nd part tempts to be solved with two processes, I decided to go for just one. I don’t see any particular benefit of using two of them, while I think that cross-process deadlock detection can only bring problems.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="62518" 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/81">Post #80</a>
	                </div>
	            </div>
              <div id="likers-container-62518" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="62518"
                     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 #80"></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=9">Load more posts (23 remaining)</a>
</div></template></turbo-stream>