Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created December 1, 2020 06:38
Show Gist options
  • Save ynonp/b40b7f1b68da5b880286645930c889f4 to your computer and use it in GitHub Desktop.
Save ynonp/b40b7f1b68da5b880286645930c889f4 to your computer and use it in GitHub Desktop.
defmodule Day1 do
def read_input do
File.read!("input/day1.txt")
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer/1)
end
def part1 do
values = read_input()
for a <- values, b <- values, a + b == 2020, do: a * b
|> IO.inspect
end
def part2 do
values = read_input()
for a <- values, b <- values, c <- values, a + b + c == 2020, do: a * b * c
|> IO.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment