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.

295 lines
4.5 KiB
Go

package day13
import (
"testing"
"gitea.paas.celticinfo.fr/oabrivard/aoc2023/utils"
)
func TestSumMirrorLines(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLines(lines)
if result != 405 {
t.Fatalf("expected 405, got %v", result)
}
}
func TestSumMirrorLinesDebug(t *testing.T) {
lines := []string{
"#...#..#.",
"#...#..#.",
".####..#.",
"..#..#..#",
"...#....#",
"##..###..",
"#...####.",
"#...####.",
"##..##...",
"...#....#",
"..#..#..#",
".####..#.",
"#...#..#.",
"",
}
result := SumMirrorLines(lines)
if result != 100 {
t.Fatalf("expected 100, got %v", result)
}
}
func TestSumMirrorLinesWithInput1(t *testing.T) {
lines := utils.ReadLines("input.txt")
result := SumMirrorLines(lines)
if result != 43614 {
t.Fatalf("expected 43614 %v", result)
}
}
func TestSumMirrorLinesWithSmudge(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLinesWithSumdge(lines)
if result != 400 {
t.Fatalf("expected 400, got %v", result)
}
}
func TestSumMirrorLinesWithSmudgeWithInput1(t *testing.T) {
lines := utils.ReadLines("input.txt")
result := SumMirrorLinesWithSumdge(lines)
if result != 43614 {
t.Fatalf("expected 43614 %v", result)
}
}
func TestSumMirrorLines2(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLines2(lines, 0)
if result != 405 {
t.Fatalf("expected 405, got %v", result)
}
}
func TestSumMirrorLines2WithInput1(t *testing.T) {
lines := utils.ReadLines("input.txt")
result := SumMirrorLines2(lines, 0)
if result != 43614 {
t.Fatalf("expected 43614 %v", result)
}
}
func TestSumMirrorLines2Debug(t *testing.T) {
lines := []string{
"...###...##",
"##....#..#.",
"###.#.#....",
"#..###.##.#",
"#..###.##.#",
"###.#......",
"##....#..#.",
"...###...##",
"...###...##",
"##....#..#.",
"###.#......",
"",
}
result := SumMirrorLines2(lines, 0)
if result != 800 {
t.Fatalf("expected 800, got %v", result)
}
}
func TestSumMirrorLines2WithSmudge(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLines2(lines, 1)
if result != 405 {
t.Fatalf("expected 405, got %v", result)
}
}
func TestSumMirrorLinesWithSmudge2(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLinesWithSumdge2(lines)
if result != 400 {
t.Fatalf("expected 400, got %v", result)
}
}
func TestSumMirrorLines3(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLines3(lines, 0)
if result != 405 {
t.Fatalf("expected 405, got %v", result)
}
}
func TestSumMirrorLines3WithInput1(t *testing.T) {
lines := utils.ReadLines("input.txt")
result := SumMirrorLines3(lines, 0)
if result != 43614 {
t.Fatalf("expected 43614 %v", result)
}
}
func TestSumMirrorLines3WithSmudge(t *testing.T) {
lines := []string{
"#.##..##.",
"..#.##.#.",
"##......#",
"##......#",
"..#.##.#.",
"..##..##.",
"#.#.##.#.",
"",
"#...##..#",
"#....#..#",
"..##..###",
"#####.##.",
"#####.##.",
"..##..###",
"#....#..#",
"",
}
result := SumMirrorLines3(lines, 1)
if result != 400 {
t.Fatalf("expected 400, got %v", result)
}
}
func TestSumMirrorLines3WithSmudgeWithInput1(t *testing.T) {
lines := utils.ReadLines("input.txt")
result := SumMirrorLines3(lines, 1)
if result != 36771 {
t.Fatalf("expected 36771 %v", result)
}
}