Compare commits

..

4 Commits

Author SHA1 Message Date
cdbc3f3b16 feat: solve part one 2025-12-09 19:22:12 +01:00
ed445a8be7 test: add unit test for both parts 2025-12-09 19:21:59 +01:00
8bbf6662b1 chore: add 2016D3 input 2025-12-09 19:21:51 +01:00
b60c971d50 feat: register third day 2025-12-09 19:21:44 +01:00
4 changed files with 1668 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package daythree
import (
"advent-of-code/internal/registry"
"fmt"
"os"
"strings"
)
func init() {
registry.Register("2016D3", ParseInput, PartOne, PartTwo)
}
func ParseInput(filepath string) [][3]int {
content, _ := os.ReadFile(filepath)
lines := strings.Split(string(content), "\n")
var result [][3]int
for _, line := range lines {
var a, b, c int
fmt.Sscanf(line, "%d %d %d", &a, &b, &c)
result = append(result, [3]int{a, b, c})
}
return result
}
func PartOne(data [][3]int) int {
count := 0
for _, triangle := range data {
a, b, c := triangle[0], triangle[1], triangle[2]
if a+b > c && a+c > b && b+c > a {
count++
}
}
return count
}
func PartTwo(data [][3]int) int {
return 0
}

View File

@@ -0,0 +1,28 @@
package daythree
import "testing"
func TestPartOne(t *testing.T) {
input := [][3]int{{5, 10, 25}}
expected := 0
got := PartOne(input)
if got != expected {
t.Errorf("PartOne() = %d, want %d", got, expected)
}
}
func TestPartTwo(t *testing.T) {
input := [][3]int{
{101, 301, 501},
{102, 302, 502},
{103, 303, 503},
{201, 401, 601},
{202, 402, 602},
{203, 403, 603},
}
expected := 6
got := PartTwo(input)
if got != expected {
t.Errorf("PartTwo() = %d, want %d", got, expected)
}
}

View File

@@ -2,5 +2,6 @@ package year2016
import (
_ "advent-of-code/internal/2016/DayOne"
_ "advent-of-code/internal/2016/DayThree"
_ "advent-of-code/internal/2016/DayTwo"
)

File diff suppressed because it is too large Load Diff