<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="196345" data-post-id="196345">
  <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>Not much, I dit not reach for Ecto intentionally.. which I would have done if it was production code. <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>The most interesting part was to use <code>Stream.chunk_while</code> to cleanup the input:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def input_stream(path) do
    File.stream!(path)
    |&gt; Stream.chunk_while(
      [],
      fn
        "\n", parts -&gt;
          {:cont, Enum.join(parts, " "), []}

        part, parts -&gt;
          {:cont, [String.trim(part) | parts]}
      end,
      fn parts -&gt; {:cont, Enum.join(parts, " "), []} end
    )
    |&gt; Stream.map(&amp;parse/1)
  end

  defp parse(line) do
    line
    |&gt; String.trim()
    |&gt; String.split(" ")
    |&gt; Enum.into(%{}, fn kv -&gt;
      [k, v] = String.split(kv, ":", parts: 2)
      {k, v}
    end)
  end
</code></pre>
<p><a href="https://github.com/kwando/AoC2020/blob/master/lib/04/day04.exs" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/kwando/AoC2020/blob/master/lib/04/day04.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="196345" 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-4/35971/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-196345" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196345"
                     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="196346" data-post-id="196346">
  <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>In these 4 days, it seems we are digging deeper and deeper into the <code>Stream</code> module <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>So far we’ve seen</p>
<ul>
<li><code>Stream.map/2</code></li>
<li><code>Stream.drop/2</code></li>
<li><code>Stream.transform/3</code></li>
<li><code>Stream.cycle/1</code></li>
<li><code>Stream.unfold/2</code></li>
<li><code>Stream.take_every/2</code></li>
<li><code>Stream.chunk_while/4</code></li>
</ul>
<p>Let’s see what else functions will be used in future solutions.</p> 
	            </div>

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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Nice use of <code>~w[]</code> <a class="mention" href="/u/aetherus" rel="nofollow">@Aetherus</a>  I should really start using some more of these sigils. Here my solution before seeing this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">#!/usr/bin/env elixir
must_have = MapSet.new(["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"])
colors = ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"]
check_int = fn (int, min, max) -&gt;
  case Integer.parse(int) do
    {num, ""} -&gt; num &gt;= min and num &lt;= max
    _ -&gt; false
  end
end

result = File.read!("4.csv")
|&gt; String.split("\n\n", trim: true)
|&gt; Enum.map(fn record -&gt;
  entries = String.replace(record, "\n", " ") |&gt; String.split(" ")
    |&gt; Enum.map(fn field -&gt;
      field = String.split(field, ":")
      case field do
        ["byr", &lt;&lt;year :: binary-size(4)&gt;&gt;] -&gt; check_int.(year, 1920, 2002)
        ["iyr", &lt;&lt;year :: binary-size(4)&gt;&gt;] -&gt; check_int.(year, 2010, 2020)
        ["eyr", &lt;&lt;year :: binary-size(4)&gt;&gt;] -&gt; check_int.(year, 2020, 2030)
        ["hgt", &lt;&lt;cm :: binary-size(3), "cm"&gt;&gt;] -&gt; check_int.(cm, 150, 193)
        ["hgt", &lt;&lt;inch :: binary-size(2), "in"&gt;&gt;] -&gt; check_int.(inch, 59, 76)
        ["hcl", &lt;&lt;"#", hex :: binary-size(6)&gt;&gt;] -&gt; Regex.match?(~r/^[0-9a-f]+$/, hex)
        ["ecl", color] -&gt; Enum.member?(colors, color)
        ["pid", &lt;&lt;num :: binary-size(9)&gt;&gt;] -&gt; Regex.match?(~r/^[0-9]+$/, num)
        _other -&gt; false
      end
      |&gt; if do
        hd(field)
      end
    end)
    |&gt; MapSet.new()

  MapSet.size(MapSet.difference(must_have, entries)) == 0
end)
|&gt; Enum.count(fn valid -&gt; valid end)

:io.format("~p~n", [result])
</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="196347" 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-4/35971/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-196347" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196347"
                     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="196348" data-post-id="196348">
  <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 really like the not so harsh ramp-up I experienced last year, but I also hope for a bit more variety in the upcoming challenges.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="196348" 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-4/35971/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-196348" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196348"
                     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="196350" data-post-id="196350">
  <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>Brilliant! I’ve used <code>Integer.parse</code> some days ago, and I wonder why it didn’t come to me this time <img src="https://forum.elixirforum.com/images/emoji/apple/roll_eyes.png?v=15" title=":roll_eyes:" class="emoji" alt=":roll_eyes:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="196350" 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-4/35971/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-196350" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196350"
                     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="196351" data-post-id="196351">
  <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>Not sure who invented the operator, but Regex in most languages is inspired by Perl, AFAIK. Elixir/Erlang use <a href="http://erlang.org/doc/man/re.html" rel="nofollow">“Perl-like regular expressions”</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="196351" 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-4/35971/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-196351" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196351"
                     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="196358" data-post-id="196358">
  <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>Naive solution, with some pattern matching and some regex:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule AdventOfCode.Day04 do
  def part1(input) do
    input
    |&gt; String.split("\n\n")
    |&gt; Enum.map(&amp;valid_passport_1?/1)
    |&gt; Enum.count(&amp; &amp;1)
  end

  def part2(input) do
    input
    |&gt; String.split("\n\n")
    |&gt; Enum.map(&amp;(valid_passport_1?(&amp;1) and valid_passport_2?(&amp;1)))
    |&gt; Enum.count(&amp; &amp;1)
  end

  def valid_passport_1?(passport) do
    ~w/byr iyr eyr hgt hcl ecl pid/
    |&gt; Enum.map(&amp;String.contains?(passport, &amp;1 &lt;&gt; ":"))
    |&gt; Enum.all?(&amp; &amp;1)
  end

  def valid_passport_2?(passport) do
    passport
    |&gt; String.split()
    |&gt; Enum.map(fn fragment -&gt;
      [field, content] = String.split(fragment, ":")
      valid_field?(field, content)
    end)
    |&gt; Enum.all?(&amp; &amp;1)
  end

  def valid_field?("byr", date), do: valid_range?(date, 1920..2002)
  def valid_field?("iyr", date), do: valid_range?(date, 2010..2020)
  def valid_field?("eyr", date), do: valid_range?(date, 2020..2030)

  def valid_field?("hgt", height) do
    case String.split_at(height, -2) do
      {h, "cm"} -&gt; valid_range?(h, 150..193)
      {h, "in"} -&gt; valid_range?(h, 59..76)
      _ -&gt; false
    end
  end

  def valid_field?("hcl", "#" &lt;&gt; color) do
    Regex.match?(~r/^([0-9a-f]){6}$/, color)
  end

  def valid_field?("hcl", _), do: false

  def valid_field?("ecl", color) when color in ~w/amb blu brn gry grn hzl oth/, do: true
  def valid_field?("ecl", _), do: false

  def valid_field?("pid", id) do
    Regex.match?(~r/^([0-9]){9}$/, id)
  end

  def valid_field?("cid", _), do: true

  def valid_field?(_, _), do: false

  def valid_range?(num, range) do
    try do
      num |&gt; String.to_integer() |&gt; Kernel.in(range)
    catch
      _ -&gt; false
    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="196358" 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-4/35971/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-196358" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196358"
                     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="196374" data-post-id="196374">
  <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><code>Enum.all?</code> could’ve saved me a bunch of code.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Day04 do
  @requiredkeys MapSet.new(~w{byr iyr eyr hgt hcl ecl pid})
  @eyecolors MapSet.new(~w{amb blu brn gry grn hzl oth})

  # returns a list of maps
  def readinput() do
    File.read!("4.input.txt")
    |&gt; String.split("\n\n")
    |&gt; Enum.map(&amp;String.replace(&amp;1, "\n", " "))
    |&gt; Enum.map(fn entry -&gt;
      Regex.scan(~r/(\w+):(\S+)/, entry, capture: :all_but_first)
      |&gt; Enum.map(&amp;List.to_tuple/1)
      |&gt; Map.new()
    end)
  end

  def allkeys?(entry) do
    entry
    |&gt; Enum.filter(fn k -&gt; k != "cid" end)
    |&gt; MapSet.new()
    |&gt; MapSet.equal?(@requiredkeys)
  end

  def valid?({"byr", value}),
    do: String.length(value) == 4 &amp;&amp; String.to_integer(value) in 1920..2002

  def valid?({"iyr", value}),
    do: String.length(value) == 4 &amp;&amp; String.to_integer(value) in 2010..2020

  def valid?({"eyr", value}),
    do: String.length(value) == 4 &amp;&amp; String.to_integer(value) in 2020..2030

  def valid?({"hgt", value}) do
    case hd(Regex.scan(~r/(\d+)(\w+)/, value, capture: :all_but_first)) do
      [cm, "cm"] -&gt; String.to_integer(cm) in 150..193
      [inch, "in"] -&gt; String.to_integer(inch) in 59..76
      _ -&gt; false
    end
  end

  def valid?({"hcl", value}),
    do:
      String.first(value) == "#" &amp;&amp; String.length(value) == 7 &amp;&amp;
        Regex.match?(~r/[0-9a-f]/, String.trim_leading(value, "#"))

  def valid?({"ecl", value}), do: MapSet.member?(@eyecolors, value)

  def valid?({"pid", value}), do: String.length(value) == 9 &amp;&amp; Regex.match?(~r/[0-9]/, value)

  def valid?({"cid", _}), do: false

  def part1(input \\ readinput()) do
    input
    |&gt; Enum.map(&amp;Map.keys/1)
    |&gt; Enum.map(&amp;allkeys?/1)
    |&gt; Enum.count(&amp; &amp;1)
  end

  def part2(input \\ readinput()) do
    input
    |&gt; Enum.map(fn entry -&gt;
      entry
      |&gt; Enum.map(fn {k, v} -&gt; if valid?({k, v}), do: k end)
      |&gt; Enum.filter(&amp; &amp;1)
    end)
    |&gt; Enum.map(&amp;allkeys?/1)
    |&gt; Enum.count(&amp; &amp;1)
  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="196374" 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-4/35971/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-196374" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196374"
                     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="196378" data-post-id="196378">
  <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>My code looks a lot like yours, pattern matching rocks <img src="https://forum.elixirforum.com/images/emoji/apple/sunglasses.png?v=15" title=":sunglasses:" class="emoji" alt=":sunglasses:" loading="lazy" width="20" height="20"></p>
<aside class="onebox githubfolder" data-onebox-src="https://github.com/cblavier/advent/tree/master/lib/2020/day04">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" alt="" width="32" height="32">

      <a href="https://github.com/cblavier/advent/tree/master/lib/2020/day04" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h3><a href="https://github.com/cblavier/advent/tree/master/lib/2020/day04" target="_blank" rel="noopener nofollow ugc">advent/lib/2020/day04 at master · cblavier/advent</a></h3>

  <p><a href="https://github.com/cblavier/advent/tree/master/lib/2020/day04" target="_blank" rel="noopener nofollow ugc">master/lib/2020/day04</a></p>

  <p><span class="label1">Advent of Code. Contribute to cblavier/advent development by creating an account on GitHub.</span></p>

  </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="196378" 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-4/35971/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-196378" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="196378"
                     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="196386" data-post-id="196386">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I went ahead and made <code>Passport</code> a struct, but it didn’t turn out to be terribly important.</p>
<p>I thought about using <code>Ecto.Schema</code> for this, but the hand-rolled version is reasonably readable and has a strong “this could be written by a macro someday” smell.</p>
<p><a href="https://github.com/al2o3cr/advent-of-code-2020/blob/db8633a6b1851f5e1ceb7b0ca68c05b88e9a0a3c/day4/part2.exs#L41-L54" class="onebox" target="_blank" rel="noopener nofollow">https://github.com/al2o3cr/advent-of-code-2020/blob/db8633a6b1851f5e1ceb7b0ca68c05b88e9a0a3c/day4/part2.exs#L41-L54</a></p>
<p>Also check out the classic “sum type represented as a tagged tuple” pattern for a number with units.</p> 
	            </div>

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