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.
119 lines
2.2 KiB
Go
119 lines
2.2 KiB
Go
package day12
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.paas.celticinfo.fr/oabrivard/aoc2023/utils"
|
|
)
|
|
|
|
func TestSumArragements(t *testing.T) {
|
|
lines := []string{
|
|
"???.### 1,1,3",
|
|
".??..??...?##. 1,1,3",
|
|
"?#?#?#?#?#?#?#? 1,3,1,6",
|
|
"????.#...#... 4,1,1",
|
|
"????.######..#####. 1,6,5",
|
|
"?###???????? 3,2,1",
|
|
}
|
|
|
|
result := SumArragements(lines)
|
|
|
|
if result != 21 {
|
|
t.Fatalf("expected 21, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragementsWithInput(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := SumArragements(lines)
|
|
|
|
if result != 7110 {
|
|
t.Fatalf("expected 7110, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragements2(t *testing.T) {
|
|
lines := []string{
|
|
// "???.### 1,1,3",
|
|
".??..??...?##. 1,1,3",
|
|
// "?#?#?#?#?#?#?#? 1,3,1,6",
|
|
// "????.#...#... 4,1,1",
|
|
// "????.######..#####. 1,6,5",
|
|
// "?###???????? 3,2,1",
|
|
}
|
|
|
|
result := SumArragements2(lines)
|
|
|
|
if result != 21 {
|
|
t.Fatalf("expected 21, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragements3(t *testing.T) {
|
|
lines := []string{
|
|
"???.### 1,1,3",
|
|
".??..??...?##. 1,1,3",
|
|
"?#?#?#?#?#?#?#? 1,3,1,6",
|
|
"????.#...#... 4,1,1",
|
|
"????.######..#####. 1,6,5",
|
|
"?###???????? 3,2,1",
|
|
}
|
|
|
|
result := SumArragements3(lines)
|
|
|
|
if result != 21 {
|
|
t.Fatalf("expected 21, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragements3WithInput(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := SumArragements3(lines)
|
|
|
|
if result != 7110 {
|
|
t.Fatalf("expected 7110, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragements4(t *testing.T) {
|
|
lines := []string{
|
|
"???.### 1,1,3",
|
|
".??..??...?##. 1,1,3",
|
|
"?#?#?#?#?#?#?#? 1,3,1,6",
|
|
"????.#...#... 4,1,1",
|
|
"????.######..#####. 1,6,5",
|
|
"?###???????? 3,2,1",
|
|
}
|
|
|
|
result := SumArragements4(lines)
|
|
|
|
if result != 525152 {
|
|
t.Fatalf("expected 525152, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragements4_2(t *testing.T) {
|
|
lines := []string{
|
|
"?#?##?#????.?..?? 9,1",
|
|
"????????#???#? 1,8",
|
|
}
|
|
|
|
result := SumArragements4(lines)
|
|
|
|
if result != 525152 {
|
|
t.Fatalf("expected 525152, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumArragements4WithInput(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := SumArragements4(lines)
|
|
|
|
if result != 525152 {
|
|
t.Fatalf("expected 525152, got %v", result)
|
|
}
|
|
}
|