Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Day 20

day20.livemd

Day 20

# Note: when making the next template, something like this works well:
#   `cat day04.livemd | sed 's/20/04/' > day04.livemd`
# When inspecting lists of numbers, use "charlists: :as_lists"
#
Mix.install([
  # Join the string so a copy of dayN to dayM doesn't destroy it.
  {:kino, "~> 0.1" <> "4.2"}
])

# Join the string so a copy of dayN to dayM doesn't destroy it.
IEx.Helpers.c("/Users/johnb/dev/2" <> "0" <> "2" <> "4adventOfCode/advent_of_code.ex")
alias AdventOfCode, as: AOC
alias Kino.Input

Installation and Data

input_example = Kino.Input.textarea("Example Data", monospace: true)
input_puzzleInput = Kino.Input.textarea("Puzzle Input", monospace: true)
input_source_select =
  Kino.Input.select("Source", [{:example, "example"}, {:puzzle_input, "puzzle input"}])
data = fn ->
  (Kino.Input.read(input_source_select) == :example &amp;&amp;
     Kino.Input.read(input_example)) ||
    Kino.Input.read(input_puzzleInput)
end

Solution

defmodule Day20 do
  def parse(text) do
    text
    |> AOC.as_single_lines()
  end

  def solve1(text) do
    parse(text)
  end

  def solve2(text) do
    parse(text)
  end
end

# Example:

data.()
|> Day20.solve1()
|> IO.inspect(label: "\n*** Part 1 solution (example: 84/72)")
#

# data.()
# |> Day20.solve2()
# |> IO.inspect(label: "\n*** Part 2 solution (example: )")
#