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.
56 lines
953 B
Go
56 lines
953 B
Go
package day9
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.paas.celticinfo.fr/oabrivard/aoc2023/utils"
|
|
)
|
|
|
|
func TestSumLastTerms(t *testing.T) {
|
|
lines := []string{
|
|
"0 3 6 9 12 15",
|
|
"1 3 6 10 15 21",
|
|
"10 13 16 21 30 45",
|
|
}
|
|
|
|
result := SumLastTerms(lines, true)
|
|
|
|
if result != 114 {
|
|
t.Fatalf("expected 114, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumLastTermsWithInput(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := SumLastTerms(lines, true)
|
|
|
|
if result != 1681758908 {
|
|
t.Fatalf("expected 1681758908, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumLastTerms2(t *testing.T) {
|
|
lines := []string{
|
|
"0 3 6 9 12 15",
|
|
"1 3 6 10 15 21",
|
|
"10 13 16 21 30 45",
|
|
}
|
|
|
|
result := SumLastTerms(lines, false)
|
|
|
|
if result != 2 {
|
|
t.Fatalf("expected 2, got %v", result)
|
|
}
|
|
}
|
|
|
|
func TestSumLastTermsWithInput2(t *testing.T) {
|
|
lines := utils.ReadLines("input.txt")
|
|
|
|
result := SumLastTerms(lines, false)
|
|
|
|
if result != 803 {
|
|
t.Fatalf("expected 803, got %v", result)
|
|
}
|
|
}
|