|
@ -21,14 +21,15 @@ func TestPuzzles(t *testing.T) { |
|
|
solver puzzle |
|
|
solver puzzle |
|
|
ans1 string |
|
|
ans1 string |
|
|
ans2 string |
|
|
ans2 string |
|
|
input string |
|
|
inp1 string |
|
|
|
|
|
inp2 string |
|
|
}{ |
|
|
}{ |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
solver: Day1{}, |
|
|
solver: Day1{}, |
|
|
ans1: "11", |
|
|
ans1: "11", |
|
|
ans2: "31", |
|
|
ans2: "31", |
|
|
input: `3 4 |
|
|
inp1: `3 4 |
|
|
4 3 |
|
|
4 3 |
|
|
2 5 |
|
|
2 5 |
|
|
1 3 |
|
|
1 3 |
|
@ -39,7 +40,7 @@ func TestPuzzles(t *testing.T) { |
|
|
solver: Day2{}, |
|
|
solver: Day2{}, |
|
|
ans1: "2", |
|
|
ans1: "2", |
|
|
ans2: "4", |
|
|
ans2: "4", |
|
|
input: `7 6 4 2 1 |
|
|
inp1: `7 6 4 2 1 |
|
|
1 2 7 8 9 |
|
|
1 2 7 8 9 |
|
|
9 7 6 2 1 |
|
|
9 7 6 2 1 |
|
|
1 3 2 4 5 |
|
|
1 3 2 4 5 |
|
@ -49,15 +50,19 @@ func TestPuzzles(t *testing.T) { |
|
|
{ |
|
|
{ |
|
|
solver: Day3{}, |
|
|
solver: Day3{}, |
|
|
ans1: "161", |
|
|
ans1: "161", |
|
|
ans2: "", |
|
|
ans2: "48", |
|
|
input: "xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))", |
|
|
inp1: "xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))", |
|
|
|
|
|
inp2: "xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))", |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for i, tt := range tests { |
|
|
for i, tt := range tests { |
|
|
name := fmt.Sprintf("Day%d", i+1) |
|
|
name := fmt.Sprintf("Day%d", i+1) |
|
|
t.Run(name, func(t *testing.T) { |
|
|
t.Run(name, func(t *testing.T) { |
|
|
p1, p2 := dup(tt.input) |
|
|
p1, p2 := dup(tt.inp1) |
|
|
|
|
|
if tt.inp2 != "" { |
|
|
|
|
|
p2 = strings.NewReader(tt.inp2) |
|
|
|
|
|
} |
|
|
if got := tt.solver.Part1(p1); got != tt.ans1 { |
|
|
if got := tt.solver.Part1(p1); got != tt.ans1 { |
|
|
t.Errorf("Part 1 = %s; expected %s", got, tt.ans1) |
|
|
t.Errorf("Part 1 = %s; expected %s", got, tt.ans1) |
|
|
} |
|
|
} |
|
|