aoc2023/day-12/two.go
2023-12-14 03:44:07 +00:00

37 lines
826 B
Go

package main
// multiplyBy unfolds all records by a given factor
func multiplyRawBy(factor int, original []int) []int {
multiplied := []int{}
for i := 0; i < factor; i++ {
multiplied = append(multiplied, original...)
if i < factor-1 {
multiplied = append(multiplied, UNKNOWN)
}
}
return multiplied
}
// multiplyBy unfolds all records by a given factor
func multiplyFormatBy(factor int, original []int) []int {
multiplied := []int{}
for i := 0; i < factor; i++ {
multiplied = append(multiplied, original...)
}
return multiplied
}
// two returns the sum of all unfolded arrangement counts
func two(lines []string) int {
fnTracker = newTracker()
sum := 0
for _, record := range records {
raw := record.raw()
sum += count(multiplyRawBy(5, raw), multiplyFormatBy(5, record.format))
}
return sum
}