<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="197731" data-post-id="197731">
  <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 only made this code longer because I had not the leisure to make it shorter. <em>cough</em></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Day16 do
  def readinput() do
    [labelranges, myticket, nearbytickets] =
      File.read!("16.input.txt")
      |&gt; String.split("\n\n")
      |&gt; Enum.map(&amp;String.split(&amp;1, "\n", trim: true))

    # my ticket and nearby ticket sections starts with a header string
    # use tl() to skip that
    [
      ranges(labelranges),
      ticketsplit(List.last(myticket)),
      Enum.map(tl(nearbytickets), &amp;ticketsplit/1)
    ]
  end

  @doc """
  Takes a list of strings like

  ["class: 1-3 or 5-7", "row: 6-11 or 33-44", "seat: 13-40 or 45-50"]

  and returns a dictionary of string keys, list of ranges values

    %{
        "class" =&gt; [1..3, 5..7],
        "row" =&gt; [6..11, 33..44],
        "seat" =&gt; [13..40, 45..50]
      },
  """
  def ranges(labels) do
    labels
    |&gt; Enum.map(fn rule -&gt;
      [label, r1start, r1end, r2start, r2end] =
        Regex.run(~r/(.*): (\d+)-(\d+) or (\d+)-(\d+)/, rule, capture: :all_but_first)

      {label,
       [
         String.to_integer(r1start)..String.to_integer(r1end),
         String.to_integer(r2start)..String.to_integer(r2end)
       ]}
    end)
    |&gt; Map.new()
  end

  @doc """
  Splits a comma-separated list of numbers as a string and
  returns a list of numbers.
  """
  def ticketsplit(ticket) do
    String.split(ticket, ",")
    |&gt; Enum.map(&amp;String.to_integer/1)
  end

  def part1([rangemap, _, nearbytickets] \\ readinput()) do
    allranges = Map.values(rangemap) |&gt; List.flatten()

    Enum.flat_map(nearbytickets, fn ticket -&gt;
      Enum.reject(ticket, fn field -&gt;
        Enum.any?(allranges, fn range -&gt;
          field in range
        end)
      end)
    end)
    |&gt; Enum.sum()
  end

  ################ part 2 ################

  def part2([rangemap, myticket, nearbytickets] \\ readinput()) do
    allranges = Map.values(rangemap) |&gt; List.flatten()

    validtickets =
      Enum.filter(nearbytickets, fn ticket -&gt;
        length(ticket) ==
          Enum.filter(ticket, fn field -&gt;
            Enum.any?(allranges, fn range -&gt;
              field in range
            end)
          end)
          |&gt; Enum.count()
      end)
      |&gt; Enum.map(&amp;fieldtolabel(&amp;1, rangemap))

    numtickets = length(validtickets)

    # labels starting with "departure"
    departuresidx =
      process(validtickets, numtickets)
      |&gt; Enum.reduce([], fn {idx, label}, acc -&gt;
        if String.starts_with?(label, "departure"), do: [idx | acc], else: acc
      end)

    # finally, calculate the product of the departure fields in my ticket
    myticket
    |&gt; Enum.with_index()
    |&gt; Enum.reduce(1, fn {val, idx}, acc -&gt;
      if idx in departuresidx, do: acc * val, else: acc
    end)
  end

  @doc """

  Take a list of tickets and return a list of matching labels against
  each ticket item.  Find the matching labels by checking every item in
  each ticket with the label ranges.
  """
  def fieldtolabel(ticket, rangemap, result \\ [])

  def fieldtolabel([], _, result), do: Enum.reverse(result)

  def fieldtolabel([t | ticket], rangemap, result) do
    labels =
      Enum.filter(rangemap, fn {_label, [r1, r2]} -&gt;
        t in r1 or t in r2
      end)
      |&gt; Enum.map(fn {k, _v} -&gt; k end)

    fieldtolabel(ticket, rangemap, [labels | result])
  end

  @doc """
  Take something like

    [
      [["row", "seat"], ["class", "row", "seat"], ["class", "row", "seat"]],
      [["class", "row"], ["class", "row", "seat"], ["class", "row", "seat"]],
      [["class", "row", "seat"], ["class", "row"], ["class", "row", "seat"]]
    ]

  and rotate it so the first column becomes the first row, etc.  Then, flatten the
  list:

    [["row", "seat"], ["class", "row"], ["class", "row", "seat"]]
    [["class", "row", "seat"], ["class", "row", "seat"], ["class", "row"]]
    [["class", "row", "seat"], ["class", "row", "seat"], ["class", "row", "seat"]]

    =&gt;

    ["row", "seat", "class", "row", "class", "row", "seat"]
    ["class", "row", "seat", "class", "row", "seat", "class", "row"]
    ["class", "row", "seat", "class", "row", "seat", "class", "row", "seat"]

  Calculate the frequency of each item in each row, and filter out all
  items that do not show up in all of the original table's columns.
  We are left with the common fields.

  [["row"], ["class", "row"], ["class", "row", "seat"]]
  """
  def process(validtickets, numtickets) do
    bycolumn =
      for c &lt;- 0..(length(List.first(validtickets)) - 1) do
        for r &lt;- 0..(numtickets - 1) do
          Enum.at(validtickets, r) |&gt; Enum.at(c)
        end
        |&gt; List.flatten()
        |&gt; Enum.frequencies()
        |&gt; Enum.filter(fn {_k, v} -&gt; v == numtickets end)
        |&gt; Enum.map(fn {k, _v} -&gt; k end)
      end
      |&gt; Enum.with_index()

    # take something like [{["seat"], 0}]
    # and convert it to %{0 =&gt; "seat"}

    # "seat" is the common field in the first item of each row of validtickets

    colmap =
      bycolumn
      |&gt; Enum.filter(fn {ks, _c} -&gt; length(ks) == 1 end)
      |&gt; Enum.reduce(%{}, fn {k, c}, acc -&gt; Map.put(acc, c, List.first(k)) end)

    loop(colmap, bycolumn)
  end

  @doc """
  Loop until each column in bycolumn has one label
  """
  def loop(colmap, bycolumn) do
    if Enum.all?(bycolumn, fn {ks, _c} -&gt; length(ks) == 1 end) do
      colmap
    else
      bycolumn =
        Enum.map(bycolumn, fn {ks, c} -&gt;
          if length(ks) == 1 do
            {ks, c}
          else
            {MapSet.new(ks)
             |&gt; MapSet.difference(MapSet.new(Map.values(colmap)))
             |&gt; MapSet.to_list(), c}
          end
        end)

      colmap =
        bycolumn
        |&gt; Enum.filter(fn {ks, _c} -&gt; length(ks) == 1 end)
        |&gt; Enum.reduce(%{}, fn {k, c}, acc -&gt; Map.put(acc, c, List.first(k)) end)

      loop(colmap, bycolumn)
    end
  end
end

</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="197731" 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-16/36264/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-197731" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197731"
                     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="197733" data-post-id="197733">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I did something different today by using nimble_parsec to parse the input data. But otherwise especially part 2 feels like awkwardly procedural. I could make it work, but it’s just an unnerving amount of nested iterations over lists.</p>
<p><a href="https://github.com/LostKobrakai/aoc2020/commit/b393486d3c745788e756ed1c8d57f03491ac5b44" class="onebox" target="_blank" rel="noopener nofollow">https://github.com/LostKobrakai/aoc2020/commit/b393486d3c745788e756ed1c8d57f03491ac5b44</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="197733" 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-2020-day-16/36264/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-197733" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197733"
                     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="197740" data-post-id="197740">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Didn’t take the time to clean this up since I wanted breakfast, but it came out okay.</p>
<p><a href="https://github.com/felix-alonso/advent-of-code/blob/master/2020/day-16.ex" rel="noopener nofollow ugc">Day16</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="197740" 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-16/36264/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-197740" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197740"
                     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="197748" data-post-id="197748">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So much iteration…</p>
<p><a href="https://github.com/camilleryr/advent20/blob/main/lib/Day16.ex" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/camilleryr/advent20/blob/main/lib/Day16.ex</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="197748" 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-16/36264/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-197748" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197748"
                     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="197755" data-post-id="197755">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Today I didn’t have much time to work on this so my solution isn’t very refined (please nobody look at my parsing function); however it gets the job done reasonably fast.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule AdventOfCode.Day16 do
  def part1(input) do
    {fields, _my_ticket, tickets} = parse_input(input)

    Enum.reduce(tickets, 0, fn ticket, total -&gt;
      ticket
      |&gt; Enum.map(fn ticket_field -&gt;
        case Enum.find(fields, fn {_, r1, r2} -&gt; ticket_field in r1 or ticket_field in r2 end) do
          nil -&gt; ticket_field
          _range -&gt; 0
        end
      end)
      |&gt; Enum.sum()
      |&gt; Kernel.+(total)
    end)
  end

  def part2(input) do
    {fields, my_ticket, tickets} = parse_input(input)

    # this mega-pipe should be split in different functions for better testability...
    # find the valid tickets
    Enum.reduce([my_ticket | tickets], [], fn ticket, valid_tickets -&gt;
      ticket
      |&gt; Enum.map(fn ticket_field -&gt;
        case Enum.find(fields, fn {_, r1, r2} -&gt; ticket_field in r1 or ticket_field in r2 end) do
          nil -&gt; false
          _range -&gt; true
        end
      end)
      |&gt; Enum.all?(&amp; &amp;1)
      |&gt; if(do: [ticket | valid_tickets], else: valid_tickets)
    end)
    # zip all the valid tickets into columns
    |&gt; Enum.zip()
    |&gt; Enum.map(&amp;Tuple.to_list/1)
    |&gt; Enum.with_index()
    |&gt; Enum.map(fn {col, col_i} -&gt;
      plaus =
        Enum.reduce(fields, [], fn {label, r1, r2}, plausible -&gt;
          if Enum.all?(col, fn f -&gt; f in r1 or f in r2 end),
            do: [label | plausible],
            else: plausible
        end)

      {plaus, col_i}
    end)
    # find the correct field for each column
    |&gt; Enum.sort(fn {p1, _}, {p2, _} -&gt; length(p1) &lt; length(p2) end)
    |&gt; Enum.reduce(%{}, fn {plaus, i}, assigned -&gt;
      Enum.reduce_while(plaus, assigned, fn p, ass -&gt;
        if Map.has_key?(ass, p), do: {:cont, ass}, else: {:halt, Map.put(ass, p, i)}
      end)
    end)
    |&gt; Enum.filter(fn {k, _v} -&gt; String.starts_with?(k, "departure") end)
    |&gt; Enum.map(fn {_k, v} -&gt; Enum.at(my_ticket, v) end)
    |&gt; Enum.reduce(&amp;Kernel.*/2)
  end

  def parse_input(input) do
    # this parser function is disgusting, maybe refactor with nimbleparsec
    [fields, my_ticket, tickets] = String.split(input, "\n\n", trim: true)

    fields =
      fields
      |&gt; String.split("\n", trim: true)
      |&gt; Enum.map(fn line -&gt;
        [label, ranges] = String.split(line, ": ")
        [r1, r2] = String.split(ranges, " or ")
        [r1a, r1b] = String.split(r1, "-")
        [r2a, r2b] = String.split(r2, "-")

        {label, String.to_integer(r1a)..String.to_integer(r1b),
         String.to_integer(r2a)..String.to_integer(r2b)}
      end)

    [_, my_ticket] = String.split(my_ticket, "\n", trim: true)
    my_ticket = my_ticket |&gt; String.split(",") |&gt; Enum.map(&amp;String.to_integer/1)

    [_ | tickets] = String.split(tickets, "\n", trim: true)

    tickets =
      tickets |&gt; Enum.map(fn t -&gt; t |&gt; String.split(",") |&gt; Enum.map(&amp;String.to_integer/1) end)

    {fields, my_ticket, tickets}
  end
end
</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="197755" 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-16/36264/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-197755" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197755"
                     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="197757" data-post-id="197757">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="APB9785" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/APB9785/120/24101_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  APB9785
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of ECSx</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>My solution uses MapSets of all possible values for each field, and MapSet.member? to test validity.  Maybe not the most efficient way, but it still runs very fast.  With ticket indexes 0 to 19, I used a Reduce to check each index and save the results, then another Reduce on my ticket to get the product of the appropriate indexes.</p>
<p><a href="https://github.com/APB9785/AoC-2020-elixir/blob/main/day_16.ex" rel="noopener nofollow ugc">Day 16</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="197757" 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-16/36264/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-197757" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197757"
                     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="197771" data-post-id="197771">
  <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>Refactored my answer to remove almost all usages of Map and MapSet in favour of lists. I also stole <a class="mention" href="/u/aetherus" rel="nofollow">@Aetherus</a>’ Enum.zip idea for transpose. Much happier with it now. <a href="https://github.com/adamu/AdventOfCode2020/blob/main/day16/day16part2-simpler-transpose.exs" rel="noopener nofollow ugc">Here</a> it is without the input parsing:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def run do
  {rules, my_ticket, tickets} = File.read!("input") |&gt; parse_input()

  tickets
  |&gt; Enum.filter(&amp;valid?(&amp;1, rules))
  |&gt; transpose_tickets()
  |&gt; valid_fields_for_columns(rules)
  |&gt; reduce_to_column_by_field_name()
  |&gt; Stream.filter(&amp;match?({"departure" &lt;&gt; _, _idx}, &amp;1))
  |&gt; Stream.map(fn {_name, idx} -&gt; my_ticket[idx] end)
  |&gt; Enum.reduce(&amp;Kernel.*/2)
  |&gt; IO.puts()
end

def valid?(ticket, rules) do
  Enum.all?(ticket, fn field -&gt;
    Enum.any?(rules, fn {_name, {range1, range2}} -&gt; field in range1 || field in range2 end)
  end)
end

def transpose_tickets(tickets) do
  tickets |&gt; Enum.zip() |&gt; Enum.map(&amp;Tuple.to_list/1) |&gt; Enum.with_index()
end

# Compare each column against the rules to determine the list of fields each column satisfies
def valid_fields_for_columns(transposed_tickets, rules) do
  for {column, idx} &lt;- transposed_tickets, do: {idx, valid_fields_for(column, rules)}
end

# Reduce the list of valid fields by elimination.
# The number of valid fields for each column is unique, which doesn't seem like a coincidence.
# Start with the column that only has one possible valid field, mark the field as seen.
# Continue to the column with two valid fields, subtract the seen field, mark remaining field as seen.
# Repeat for all columns.
def reduce_to_column_by_field_name(valid_fields_by_column) do
  valid_fields_by_column
  |&gt; Enum.sort_by(fn {_k, v} -&gt; length(v) end)
  |&gt; Enum.map_reduce([], fn {col, fields}, seen -&gt;
    [field] = fields -- seen
    {{field, col}, [field | seen]}
  end)
  |&gt; elem(0)
end

def valid_fields_for(column, rules) do
  Enum.filter(rules, fn {_field, {range1, range2}} -&gt;
    Enum.all?(column, fn val -&gt; val in range1 || val in range2 end)
  end)
  |&gt; Enum.map(&amp;elem(&amp;1, 0))
end

</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="197771" 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-16/36264/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-197771" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197771"
                     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="197776" data-post-id="197776">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Aetherus" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Aetherus/120/17203_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Aetherus
                    <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>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Happy to be stolen from <img src="https://forum.elixirforum.com/images/emoji/apple/grin.png?v=15" title=":grin:" class="emoji" alt=":grin:" loading="lazy" width="20" height="20"></p>
<p>I’m not very happy with my solution either. I found that <code>Enum.chunk_every(2, 1, :discard)</code> is useless in my 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="197776" 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-16/36264/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-197776" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197776"
                     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="197783" data-post-id="197783">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="APB9785" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/APB9785/120/24101_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  APB9785
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of ECSx</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>What is the benefit of using Lists over Map/Set?  Is “in” faster than “member?” ?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="197783" 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-16/36264/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-197783" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197783"
                     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>
    <div class="postbit" id="197784" data-post-id="197784">
  <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>Mostly just for simplicity. However, here’s a nice article by <a class="mention" href="/u/sasajuric" rel="nofollow">@sasajuric</a> from 3 days ago:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.theerlangelist.com/article/sequences">
  <header class="source">

      <a href="https://www.theerlangelist.com/article/sequences" target="_blank" rel="noopener nofollow ugc">theerlangelist.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://www.theerlangelist.com/article/sequences" target="_blank" rel="noopener nofollow ugc">The Erlangelist
- Sequences</a></h3>



  </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="197784" 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-16/36264/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-197784" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="197784"
                     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>
</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/36264/load_more?page=3">Load more posts (1 remaining)</a>
</div></template></turbo-stream>