Created
December 1, 2020 06:38
-
-
Save ynonp/b40b7f1b68da5b880286645930c889f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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