You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
2.3 KiB
Go
117 lines
2.3 KiB
Go
package day23
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.paas.celticinfo.fr/oabrivard/aoc2023/utils"
|
|
)
|
|
|
|
func TestPart1(t *testing.T) {
|
|
lines := []string{
|
|
"#.#####################",
|
|
"#.......#########...###",
|
|
"#######.#########.#.###",
|
|
"###.....#.>.>.###.#.###",
|
|
"###v#####.#v#.###.#.###",
|
|
"###.>...#.#.#.....#...#",
|
|
"###v###.#.#.#########.#",
|
|
"###...#.#.#.......#...#",
|
|
"#####.#.#.#######.#.###",
|
|
"#.....#.#.#.......#...#",
|
|
"#.#####.#.#.#########v#",
|
|
"#.#...#...#...###...>.#",
|
|
"#.#.#v#######v###.###v#",
|
|
"#...#.>.#...>.>.#.###.#",
|
|
"#####v#.#.###v#.#.###.#",
|
|
"#.....#...#...#.#.#...#",
|
|
"#.#########.###.#.#.###",
|
|
"#...###...#...#...#.###",
|
|
"###.###.#.###v#####v###",
|
|
"#...#...#.#.>.>.#.>.###",
|
|
"#.###.###.#.###.#.#v###",
|
|
"#.....###...###...#...#",
|
|
"#####################.#",
|
|
}
|
|
|
|
result := Part1(lines)
|
|
|
|
if result != 94 {
|
|
t.Fatalf("expected 94, got %d", result)
|
|
}
|
|
}
|
|
|
|
func TestPart1WithInput(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := Part1(lines)
|
|
|
|
if result != 2402 {
|
|
t.Fatalf("expected 2402, got %d", result)
|
|
}
|
|
}
|
|
|
|
func TestPart2(t *testing.T) {
|
|
lines := []string{
|
|
"#.#####################",
|
|
"#.......#########...###",
|
|
"#######.#########.#.###",
|
|
"###.....#.>.>.###.#.###",
|
|
"###v#####.#v#.###.#.###",
|
|
"###.>...#.#.#.....#...#",
|
|
"###v###.#.#.#########.#",
|
|
"###...#.#.#.......#...#",
|
|
"#####.#.#.#######.#.###",
|
|
"#.....#.#.#.......#...#",
|
|
"#.#####.#.#.#########v#",
|
|
"#.#...#...#...###...>.#",
|
|
"#.#.#v#######v###.###v#",
|
|
"#...#.>.#...>.>.#.###.#",
|
|
"#####v#.#.###v#.#.###.#",
|
|
"#.....#...#...#.#.#...#",
|
|
"#.#########.###.#.#.###",
|
|
"#...###...#...#...#.###",
|
|
"###.###.#.###v#####v###",
|
|
"#...#...#.#.>.>.#.>.###",
|
|
"#.###.###.#.###.#.#v###",
|
|
"#.....###...###...#...#",
|
|
"#####################.#",
|
|
}
|
|
|
|
result := Part2(lines)
|
|
|
|
if result != 154 {
|
|
t.Fatalf("expected 154, got %d", result)
|
|
}
|
|
}
|
|
|
|
func Test2Part2(t *testing.T) {
|
|
lines := []string{
|
|
"#.########",
|
|
"#.....####",
|
|
"#####.####",
|
|
"###......#",
|
|
"###.####.#",
|
|
"###.####.#",
|
|
"###......#",
|
|
"#####.####",
|
|
"#####....#",
|
|
"########.#",
|
|
}
|
|
|
|
result := Part2(lines)
|
|
|
|
if result != 22 {
|
|
t.Fatalf("expected 22, got %d", result)
|
|
}
|
|
}
|
|
|
|
func TestPart2WithInput(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := Part2(lines)
|
|
|
|
if result != 6450 {
|
|
t.Fatalf("expected 6450, got %d", result)
|
|
}
|
|
}
|