-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday2_test.exs
More file actions
40 lines (35 loc) · 1 KB
/
Copy pathday2_test.exs
File metadata and controls
40 lines (35 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
defmodule Day2Test do
use ExUnit.Case
import Parser
def parse_commands(lines) do
lines
|> Enum.map(fn s -> s |> String.split(" ") end)
|> Enum.map(fn [a, b] -> [String.to_atom(a), String.to_integer(b)] end)
end
test "part 1 - works for given example" do
assert Day2.position_depth([
[:forward, 5],
[:down, 5],
[:forward, 8],
[:up, 3],
[:down, 8],
[:forward, 2]
]) == 150
end
test "part 1 - finds solution" do
assert Day2.position_depth(lines_to_list("inputs/day2") |> parse_commands) == 1_692_075
end
test "part 2 - works for given example" do
assert Day2.plan_course([
[:forward, 5],
[:down, 5],
[:forward, 8],
[:up, 3],
[:down, 8],
[:forward, 2]
]) == 900
end
test "part 2 - finds solution" do
assert Day2.plan_course(lines_to_list("inputs/day2") |> parse_commands) == 1_749_524_700
end
end