Created
December 5, 2020 19:10
-
-
Save code-shoily/0097648d6aabc024251c34e460fdfdba to your computer and use it in GitHub Desktop.
Advent of Code 2020, Day 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_1_bin, do: input!() |> String.split("\n") |> Enum.map(fn d -> d |> String.replace("F", "0") |> String.replace("B", "1") |> String.replace("R", "1") |> String.replace("L", "0") |> String.to_integer(2) end) |> Enum.max() | |
def run_2_bin, do: input!() |> String.split("\n") |> Enum.map(fn d -> d |> String.replace("F", "0") |> String.replace("B", "1") |> String.replace("R", "1") |> String.replace("L", "0") |> String.to_integer(2) end) |> Enum.sort() |> (fn [_ | tail] = total -> total |> Enum.zip(tail) |> Enum.filter(fn {a, b} -> b - a != 1 end) |> (fn [{_, b}] -> b - 1 end).() end).() end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment