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

Day 11

day11.livemd

Day 11

Mix.install([
  {:kino, "~> 0.14.2"}
])

IEx.Helpers.c("/Users/johnb/dev/2015adventOfCode/advent_of_code.ex")
alias AdventOfCode, as: AOC
alias Kino.Input
require Integer
use Bitwise

# Note: when making the next template, something like this works well:
#   `cat day01.livemd | sed 's/01/02/' > day02.livemd`
#

Installation and Data

input_p1example = Kino.Input.textarea("Example Data")
input_p1puzzleInput = Kino.Input.textarea("Puzzle Input")
input_source_select =
  Kino.Input.select("Source", [{:example, "example"}, {:puzzle_input, "puzzle input"}])
p1data = fn ->
  (Kino.Input.read(input_source_select) == :example &&
     Kino.Input.read(input_p1example)) ||
    Kino.Input.read(input_p1puzzleInput)
end

Part 1

defmodule Day11 do

  def solve1(text) do
    # cqjxjnds
    # Iterates by inspection to...
    "cqjxxyzz"
  end

  def solve2(text) do
    # cqjxxyzz
    # Iterates by inspection to...
    # cakaabcc which is somehow wrong (because I typo'd an 'a' instead of a 'q')
    "cqkaabcc"
  end
end

# Example data:

p1data.()
|> Day11.solve1()
|> IO.inspect(label: "\n*** Part 1 solution (example: 2)")
# cqjxxyzz

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