<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="196469" data-post-id="196469">
  <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 felt like there was a some “binary hack” one could do here, 127 and 7 is not just random numbers <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"><br>
Anyway, I did this before my daily coffee so my solution is a little longer but I’m still happy with it.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Aoc2020.Day05 do
  def part1(input) do
    input
    |&gt; Stream.map(&amp;seat_id/1)
    |&gt; Enum.max()
  end

  def part2(input) do
    input
    |&gt; Stream.map(&amp;seat_id/1)
    |&gt; Enum.sort()
    |&gt; Enum.drop_while(&amp;(&amp;1 &lt;= 7))
    |&gt; find_gap()
  end

  def find_gap([a, b | rest]) when b - a == 2, do: a + 1
  def find_gap([a, b | rest]) when b - a == 1, do: find_gap([b | rest])

  def seat_id(spec) when is_binary(spec) do
    {rows, cols} = String.split_at(spec, 7)
    seat_id({decode(rows, ?F, ?B, {0, 127}), decode(cols, ?L, ?R, {0, 7})})
  end

  def seat_id({row, col}) do
    row * 8 + col
  end

  def decode(&lt;&lt;lft&gt;&gt;, lft, _rgt, {min, _max}), do: min
  def decode(&lt;&lt;rgt&gt;&gt;, _lft, rgt, {_min, max}), do: max

  def decode(&lt;&lt;lft, rest::binary()&gt;&gt;, lft, rgt, {min, max}),
    do: decode(rest, lft, rgt, {min, max - mid(min, max)})

  def decode(&lt;&lt;rgt, rest::binary()&gt;&gt;, lft, rgt, {min, max}),
    do: decode(rest, lft, rgt, {min + mid(min, max), max})

  defp mid(min, max), do: div(max - min, 2) + 1

  def input_stream(path) do
    File.stream!(path)
    |&gt; Stream.map(&amp;parse/1)
  end

  defp parse(line), do: String.trim(line)
end

357 = Aoc2020.Day05.seat_id({44, 5})
357 = Aoc2020.Day05.seat_id("FBFBBFFRLR")

567 = Aoc2020.Day05.seat_id({70, 7})
567 = Aoc2020.Day05.seat_id("BFFFBBFRRR")

119 = Aoc2020.Day05.seat_id({14, 7})
119 = Aoc2020.Day05.seat_id("FFFBBBFRRR")

820 = Aoc2020.Day05.seat_id({102, 4})
820 = Aoc2020.Day05.seat_id("BBFFBBFRLL")

input = Aoc2020.Day05.input_stream("input.txt")

Aoc2020.Day05.part1(input)
|&gt; IO.inspect(label: "part1")

Aoc2020.Day05.part2(input)
|&gt; IO.inspect(label: "part2")
</code></pre>
<p><a href="https://github.com/kwando/AoC2020/blob/master/lib/05/day05.exs" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/kwando/AoC2020/blob/master/lib/05/day05.exs</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="196469" 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-2020-day-5/35997/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-196469" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196469"
                     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="196471" data-post-id="196471">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Nothing really fancy, but still code I am proud of <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/cblavier/advent/blob/master/lib/2020/day05/part1.ex" rel="noopener nofollow ugc">Part1</a> / <a href="https://github.com/cblavier/advent/blob/master/lib/2020/day05/part2.ex" rel="noopener nofollow ugc">Part2</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="196471" 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-5/35997/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-196471" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196471"
                     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="196475" data-post-id="196475">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Day 5 was pretty fun!</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Day5 do
  def one do
    File.read!("inputs/five.txt")
    |&gt; String.split("\n")
    |&gt; Enum.map(&amp;parse/1)
    |&gt; Enum.max()
  end

  def two do
    [[x, _]] = File.read!("inputs/five.txt")
    |&gt; String.split("\n")
    |&gt; Enum.map(&amp;parse/1)
    |&gt; Enum.sort()
    |&gt; Enum.chunk_every(2, 1, :discard)
    |&gt; Enum.filter(fn [x, y] -&gt; y - x == 2 end)

    x + 1
  end

  def parse(input) do
    [[r, s]] = Regex.scan(~r/([F|B]{7})([R|L]{3})/, input, capture: :all_but_first)

    row = r
    |&gt; String.replace("F", "0")
    |&gt; String.replace("B", "1")
    |&gt; String.to_integer(2)

    seat = s
    |&gt; String.replace("L", "0")
    |&gt; String.replace("R", "1")
    |&gt; String.to_integer(2)

    row * 8 + seat
  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="196475" 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-5/35997/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-196475" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196475"
                     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="196476" data-post-id="196476">
  <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>Yes!</p>
<p>Your solution is almost the same as mine, except that I didn’t split the strings into 2 parts. The <code>row * 8</code> part is tricky.</p> 
	            </div>

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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="deadbeef" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  deadbeef
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Same idea as some above, but when I was solving I wanted to see if I could use <code>Bitwise</code> at all. Ended up using it to “construct” the id by reducing it to the value. Shift left for each character, adding a bit at the end if it’s “B” or “R”. No need to “multiple 8, then add col” since the row/col are already in “position”, bitwise.</p>
<ul>
<li>part one just aggregates the max</li>
<li>part two sorts the ids then pattern matches to find two ids that are 2 “away” from each other. I think you could use <code>reduce_while</code> and <code>MapSet</code> to locate pairs like 2SUM (so you can stream and not have to sort). However, I felt the sort + function matches were more compact for the challenge.</li>
</ul>
<p>(apologies if any terminology is wrong, new to Elixir)</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Advent.Y2020.D05 do
  use Bitwise, only_operators: true

  @spec part_one(passes :: Enumerable.t(String.t())) :: integer
  def part_one(passes) do
    passes
    |&gt; Stream.map(&amp;seat_id/1)
    |&gt; Enum.max()
  end

  @spec part_two(passes :: Enumerable.t(String.t())) :: integer | nil
  def part_two(passes) do
    passes
    |&gt; Stream.map(&amp;seat_id/1)
    |&gt; Enum.sort()
    |&gt; find_middle_seat()
  end

  defp seat_id(partition) do
    partition
    |&gt; String.graphemes()
    |&gt; Enum.reduce(0, fn
      "B", sum -&gt; sum &lt;&lt;&lt; 1 ||| 1
      "R", sum -&gt; sum &lt;&lt;&lt; 1 ||| 1
      _, sum -&gt; sum &lt;&lt;&lt; 1
    end)
  end

  # Assumes the list is sorted
  defp find_middle_seat([a, b | _tail]) when b - a == 2, do: a + 1
  defp find_middle_seat([_a, b | tail]), do: find_middle_seat([b | tail])
  defp find_middle_seat(_), do: nil
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="196477" 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-2020-day-5/35997/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-196477" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196477"
                     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="196485" data-post-id="196485">
  <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 unusual for this one: I implemented the bording pass code as a sigil/struct with a custom <code>Inspect</code> implementation, before solving the problem itself.</p>
<p><a href="https://github.com/LostKobrakai/aoc2020/commit/a4b9f37a633907064632e86ba7a236d020d018c0" class="onebox" target="_blank" rel="noopener nofollow">https://github.com/LostKobrakai/aoc2020/commit/a4b9f37a633907064632e86ba7a236d020d018c0</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="196485" 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-2020-day-5/35997/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-196485" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196485"
                     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="196486" data-post-id="196486">
  <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>Wow, that’s awesome! Finally, we have someone doing metaprogramming!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="196486" 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-5/35997/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-196486" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196486"
                     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="196488" data-post-id="196488">
  <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>Not as clever as the folks above, but I like it <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<p><a href="https://github.com/egze/aoc/blob/master/lib/aoc/y2020/d5.ex" rel="noopener nofollow ugc">GitHub</a></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Aoc.Y2020.D5 do
  use Aoc.Boilerplate,
    transform: fn raw -&gt; raw |&gt; String.split() end

  def part1(input \\ processed()) do
    input
    |&gt; Enum.reduce(0, &amp;max_seat_id_reducer/2)
  end

  def part2(input \\ processed()) do
    input
    |&gt; Enum.map(&amp;get_seat_id/1)
    |&gt; Enum.sort()
    |&gt; Enum.reduce_while(0, fn x, acc -&gt;
      cond do
        acc == 0 -&gt; {:cont, x}
        x - 1 == acc -&gt; {:cont, x}
        :else -&gt; {:halt, x - 1}
      end
    end)
  end

  defp max_seat_id_reducer(seat, acc) do
    seat_id = get_seat_id(seat)

    if seat_id &gt;= acc, do: seat_id, else: acc
  end

  def get_seat_id(seat) do
    {row, col, _, _} =
      seat
      |&gt; String.graphemes()
      |&gt; Enum.reduce({0, 0, 0..127, 0..7}, fn char, {row, col, row_range, col_range} -&gt;
        case char do
          "F" -&gt;
            first..last = row_range
            new_row_last = floor((first + last) / 2)
            {first, col, first..new_row_last, col_range}

          "B" -&gt;
            first..last = row_range
            new_row_first = round((first + last) / 2)
            {new_row_first, col, new_row_first..last, col_range}

          "R" -&gt;
            first..last = col_range
            new_col_first = round((first + last) / 2)
            {row, new_col_first, row_range, new_col_first..last}

          "L" -&gt;
            first..last = col_range
            new_col_last = floor((first + last) / 2)
            {row, first, row_range, first..new_col_last}
        end
      end)

    row * 8 + col
  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="196488" 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-5/35997/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-196488" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196488"
                     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="196489" data-post-id="196489">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>For Part 2:<br>
Solution without sorting<br>
computed minSeat, maxSeat, seatTotal<br>
<em><strong>Missing Seat = sum(minSeat:maxSeat) - seatTotal</strong></em></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Day5 do

  defp getIndex(_charList, index, index) do
    index
  end

  defp getIndex([headChar | tail], minIdx, maxIdx) when headChar == "F" or headChar == "L" do
    getIndex(tail, minIdx, minIdx + div(maxIdx - minIdx + 1, 2) - 1)
  end

  defp getIndex([headChar | tail], minIdx, maxIdx) when headChar == "B" or headChar == "R" do
    getIndex(tail, minIdx + div(maxIdx - minIdx + 1, 2), maxIdx)
  end

  defp seatFun([], seatIdAcc) do
    seatIdAcc
  end

  defp seatFun([head | tail], seatIdAcc) do
    {rowStr, colStr} = String.split_at(head, 7)
    row = getIndex(String.graphemes(rowStr), 0, 127)
    col = getIndex(String.graphemes(colStr), 0, 7)
    seatFun(tail, [row * 8 + col | seatIdAcc])
  end

  defp sumAtoB(a, b) do
    div(b * (b + 1) - (a - 1) * a, 2)
  end

  defp getMinMaxTotal([], seatAcc) do
    seatAcc
  end

  defp getMinMaxTotal([head | tail], {seatMinAcc, seatMaxAcc, seatTotalAcc}) do
    getMinMaxTotal(tail, {min(head, seatMinAcc), max(head, seatMaxAcc), head + seatTotalAcc})
  end

  def main(part) do
    seatList =
      File.read!("day5.txt")
      |&gt; String.split("\n", trim: true)
      |&gt; seatFun([])
    case part do
      1 -&gt;
        Enum.max(seatList)
      2 -&gt;
        {minSeat, maxSeat, seatTotal} = getMinMaxTotal(seatList, {10_000_000, 0, 0})
        sumAtoB(minSeat, maxSeat) - seatTotal
    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="196489" 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-5/35997/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-196489" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196489"
                     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="196490" data-post-id="196490">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Today I wanted to play with bit syntax and bitstrings, it was fun</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def read_file!(file, _part) do
    Input.stream_file_lines(file, trim: true)
  end
​
  def parse_input!(input, _part) do
    input
  end
​
  def part_one(problem) do
    problem
    |&gt; Stream.map(&amp;seat_id/1)
    |&gt; Enum.max()
  end
​
  def part_two(problem) do
    problem
    |&gt; Stream.map(&amp;seat_id/1)
    |&gt; Enum.sort()
    |&gt; find_self_seat
  end
​
  def seat_id(letters) do
    partial = for &lt;&lt;char::8 &lt;- letters&gt;&gt;, into: &lt;&lt;&gt;&gt;, do: cast_bit(char)
    :binary.decode_unsigned(&lt;&lt;0::6, partial::bitstring&gt;&gt;)
  end
​
  def cast_bit(?F), do: &lt;&lt;0::1&gt;&gt;
  def cast_bit(?L), do: &lt;&lt;0::1&gt;&gt;
  def cast_bit(?B), do: &lt;&lt;1::1&gt;&gt;
  def cast_bit(?R), do: &lt;&lt;1::1&gt;&gt;
​
  def find_self_seat([prev, next | _]) when next - prev == 2 do
    next - 1
  end
​
  def find_self_seat([_ | next]) do
    find_self_seat(next)
  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="196490" 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-5/35997/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-196490" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196490"
                     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/35997/load_more?page=3">Load more posts (12 remaining)</a>
</div></template></turbo-stream>