Compare commits

...

5 commits

Author SHA1 Message Date
82f06213fb solve day 9 2023-12-09 15:18:45 +01:00
7117aca07e solve day8 part 2 2023-12-09 12:08:59 +01:00
4978707252 solve day8 part 1 2023-12-09 11:34:43 +01:00
090495d0e9 solve day 7 part 2 2023-12-09 11:22:32 +01:00
17049c1f98 solve day 7 part 1 2023-12-09 11:10:31 +01:00
19 changed files with 2633 additions and 11 deletions

View file

@ -2,7 +2,6 @@ package _023
import (
"bufio"
"fmt"
"io"
"math"
"strings"
@ -15,12 +14,11 @@ func Day06Part1(input io.Reader) (int, error) {
times := lineToInts(strings.TrimPrefix(scanner.Text(), "Time:"))
scanner.Scan()
distances := lineToInts(strings.TrimPrefix(scanner.Text(), "Distance:"))
fmt.Println(times, distances)
margin := 1
for i := 0; i < len(times); i++ {
x1, x2 := zeros(times[i], distances[i])
x1, x2 := day06Zeros(times[i], distances[i])
if distance(x1, times[i]) <= distances[i] {
x1++
}
@ -30,7 +28,7 @@ func Day06Part1(input io.Reader) (int, error) {
return margin, nil
}
func zeros(time, distance int) (int, int) {
func day06Zeros(time, distance int) (int, int) {
t, d := float64(time), float64(distance)
delta := math.Sqrt(math.Pow(t, 2) - 4*d)
return int(math.Ceil((t - delta) / 2)), int(math.Ceil((t + delta) / 2))
@ -47,12 +45,11 @@ func Day06Part2(input io.Reader) (int, error) {
times := lineToInts(strings.ReplaceAll(strings.TrimPrefix(scanner.Text(), "Time:"), " ", ""))
scanner.Scan()
distances := lineToInts(strings.ReplaceAll(strings.TrimPrefix(scanner.Text(), "Distance:"), " ", ""))
fmt.Println(times, distances)
margin := 1
for i := 0; i < len(times); i++ {
x1, x2 := zeros(times[i], distances[i])
x1, x2 := day06Zeros(times[i], distances[i])
if distance(x1, times[i]) <= distances[i] {
x1++
}

220
2023/day07_camel_cards.go Normal file
View file

@ -0,0 +1,220 @@
package _023
import (
"bufio"
"fmt"
"io"
"slices"
"strconv"
"strings"
)
const d07CardsP1 = "23456789TJQKA"
const d07CardsP2 = "J23456789TQKA"
const (
d07HandHigh = iota
d07HandPair
d07HandTwoPairs
d07HandThree
d07HandHouse
d07HandFour
d07HandFive
)
type d07Hand struct {
hand string
bid int
value int
}
func newD07Hand(hand string, bid int) d07Hand {
return d07Hand{
hand: hand,
bid: bid,
value: d07HandValueP1(hand),
}
}
func Day07Part1(input io.Reader) (int, error) {
scanner := bufio.NewScanner(input)
var hands []d07Hand
for scanner.Scan() {
line := strings.Split(scanner.Text(), " ")
hand, bidS := line[0], line[1]
bid, err := strconv.Atoi(bidS)
if err != nil {
return 0, fmt.Errorf("converting bid to int on line %v: %w", line, err)
}
hands = append(hands, newD07Hand(hand, bid))
}
slices.SortFunc(hands, d07CmpHands)
sum := 0
for i, hand := range hands {
sum += (i + 1) * hand.bid
}
return sum, nil
}
func d07CmpHands(a d07Hand, b d07Hand) int {
// cmp(a, b) should return a negative number when a < b, a positive number when
// a > b and zero when a == b.
if a.value < b.value {
return -1
}
if a.value > b.value {
return 1
}
for i := 0; i < len(a.hand); i++ {
aValue := strings.Index(d07CardsP1, a.hand[i:i+1])
bValue := strings.Index(d07CardsP1, b.hand[i:i+1])
if aValue > bValue {
return 1
}
if aValue < bValue {
return -1
}
}
return 0
}
func d07HandValueP1(hand string) int {
count := make(map[rune]byte)
var maxCount byte = 1
var maxFor rune
var secondMax byte = 1
for _, c := range hand {
v := count[c]
v++
if v > maxCount {
maxCount = v
maxFor = c
}
count[c] = v
}
for c, v := range count {
if secondMax < v && c != maxFor {
secondMax = v
}
}
switch {
case maxCount == 5:
return d07HandFive
case maxCount == 4:
return d07HandFour
case maxCount == 3 && secondMax == 2:
return d07HandHouse
case maxCount == 3 && secondMax == 1:
return d07HandThree
case maxCount == 2 && secondMax == 2:
return d07HandTwoPairs
case maxCount == 2 && secondMax == 1:
return d07HandPair
default:
return d07HandHigh
}
}
func Day07Part2(input io.Reader) (int, error) {
scanner := bufio.NewScanner(input)
var hands []d07Hand
for scanner.Scan() {
line := strings.Split(scanner.Text(), " ")
hand, bidS := line[0], line[1]
bid, err := strconv.Atoi(bidS)
if err != nil {
return 0, fmt.Errorf("converting bid to int on line %v: %w", line, err)
}
hands = append(hands, newD07HandP2(hand, bid))
}
slices.SortFunc(hands, d07CmpHandsP2)
sum := 0
for i, hand := range hands {
sum += (i + 1) * hand.bid
}
return sum, nil
}
func newD07HandP2(hand string, bid int) d07Hand {
return d07Hand{
hand: hand,
bid: bid,
value: d07HandValueP2(hand),
}
}
func d07HandValueP2(hand string) int {
count := make(map[rune]byte)
var maxCount byte = 0
var maxFor rune
var secondMax byte = 0
for _, c := range hand {
v := count[c]
v++
if v > maxCount && c != 'J' {
maxCount = v
maxFor = c
}
count[c] = v
}
joker, ok := count['J']
maxCount += joker
if ok {
delete(count, 'J')
}
for c, v := range count {
if secondMax < v && c != maxFor {
secondMax = v
}
}
switch {
case maxCount == 5:
return d07HandFive
case maxCount == 4:
return d07HandFour
case maxCount == 3 && secondMax == 2:
return d07HandHouse
case maxCount == 3 && secondMax == 1:
return d07HandThree
case maxCount == 2 && secondMax == 2:
return d07HandTwoPairs
case maxCount == 2 && secondMax == 1:
return d07HandPair
default:
return d07HandHigh
}
}
func d07CmpHandsP2(a d07Hand, b d07Hand) int {
// cmp(a, b) should return a negative number when a < b, a positive number when
// a > b and zero when a == b.
if a.value < b.value {
return -1
}
if a.value > b.value {
return 1
}
for i := 0; i < len(a.hand); i++ {
aValue := strings.Index(d07CardsP2, a.hand[i:i+1])
bValue := strings.Index(d07CardsP2, b.hand[i:i+1])
if aValue > bValue {
return 1
}
if aValue < bValue {
return -1
}
}
return 0
}

View file

@ -0,0 +1,179 @@
package _023
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"testing"
)
func TestDay07Part1(t *testing.T) {
tests := []testCase{
{"inputs/day07_test1", 6440},
{"inputs/day07", 246424613},
}
for _, test := range tests {
t.Run(test.filename, check(test, Day07Part1))
}
}
func TestDay07Part2(t *testing.T) {
tests := []testCase{
{"inputs/day07_test1", 5905},
{"inputs/day07_test2", 5911},
{"inputs/day07", 248256639},
}
for _, test := range tests {
t.Run(test.filename, check(test, Day07Part2))
}
t.Run("247974245 is too low", func(t *testing.T) {
file, err := os.Open("inputs/day07")
require.NoError(t, err)
got, err := Day07Part2(file)
require.NoError(t, err)
assert.Greater(t, got, 247974245)
})
}
func TestDay07HandValueP1(t *testing.T) {
tests := []struct {
hand string
expected int
}{
{"AAAAA", d07HandFive},
{"AAAA2", d07HandFour},
{"AA2AA", d07HandFour},
{"3KKK3", d07HandHouse},
{"3KKK4", d07HandThree},
{"KKQQT", d07HandTwoPairs},
{"KQTQK", d07HandTwoPairs},
{"QQ567", d07HandPair},
{"T6862", d07HandPair},
{"A2345", d07HandHigh},
}
for _, test := range tests {
t.Run(test.hand, func(t *testing.T) {
assert.Equal(t, test.expected, d07HandValueP1(test.hand))
})
}
}
func TestDay07HandValueP2(t *testing.T) {
tests := []struct {
hand string
expected int
}{
{"JJJJJ", d07HandFive},
{"AAAAA", d07HandFive},
{"AAJJJ", d07HandFive},
{"AAAA2", d07HandFour},
{"JJAJ2", d07HandFour},
{"JKKK2", d07HandFour},
{"QJJQ2", d07HandFour},
{"AA2AA", d07HandFour},
{"AJ2JA", d07HandFour},
{"3KKK3", d07HandHouse},
{"3KJK3", d07HandHouse},
{"3KKK4", d07HandThree},
{"3KKJ4", d07HandThree},
{"KKQQT", d07HandTwoPairs},
{"KQTQK", d07HandTwoPairs},
{"QQ567", d07HandPair},
{"JQ567", d07HandPair},
{"T6862", d07HandPair},
{"T68J2", d07HandPair},
{"A2345", d07HandHigh},
}
for _, test := range tests {
t.Run(test.hand, func(t *testing.T) {
assert.Equal(t, test.expected, d07HandValueP2(test.hand))
})
}
}
func TestD07CmpHands(t *testing.T) {
type args struct {
a string
b string
}
tests := []struct {
name string
args args
want int
}{
{
name: "five and four",
args: args{"AAAAA", "KAAAA"},
want: 1,
},
{
name: "four and four",
args: args{"2AAAA", "33332"},
want: -1,
},
{
name: "house and house",
args: args{"77888", "77788"},
want: 1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, d07CmpHands(newD07Hand(tt.args.a, 0), newD07Hand(tt.args.b, 0)), "d07CmpHands(%v, %v)", tt.args.a, tt.args.b)
})
}
}
func TestD07CmpHandsP2(t *testing.T) {
type args struct {
a string
b string
}
tests := []struct {
args args
want int
}{
{
args: args{"T55J5", "KTJJT"},
want: -1,
},
{
args: args{"KTJJT", "QQQJA"},
want: 1,
},
{
args: args{"T55J5", "QQQJA"},
want: -1,
},
{
args: args{"J55T5", "JQQQA"},
want: -1,
},
{
args: args{"555T5", "JQQQA"},
want: 1,
},
{
args: args{"QQQQ2", "JKKK2"},
want: 1,
},
{
args: args{"QQQQ2", "JJJJJ"},
want: -1,
},
{
args: args{"22222", "JJJJJ"},
want: 1,
},
}
for _, tt := range tests {
char := "<"
if tt.want == 1 {
char = ">"
}
t.Run(fmt.Sprintf("%v%v%v", tt.args.a, char, tt.args.b), func(t *testing.T) {
assert.Equalf(t, tt.want, d07CmpHandsP2(newD07HandP2(tt.args.a, 0), newD07HandP2(tt.args.b, 0)), "d07CmpHandsP2(%v, %v)", tt.args.a, tt.args.b)
})
}
}

109
2023/day08_left_right.go Normal file
View file

@ -0,0 +1,109 @@
package _023
import (
"bufio"
"io"
"strings"
)
func Day08Part1(input io.Reader) (int, error) {
scanner := bufio.NewScanner(input)
scanner.Scan()
leftRight := scanner.Text()
scanner.Scan() // skip blank line
nodes := make(map[string][2]string)
for scanner.Scan() {
line := strings.Split(scanner.Text(), " = ") // AAA = (BBB, CCC)
node := line[0]
rest := strings.Split(strings.NewReplacer("(", "", " ", "", ")", "").Replace(line[1]), ",")
nodes[node] = [2]string{rest[0], rest[1]}
}
current := "AAA"
step := 0
for current != "ZZZ" {
current = move(current, step, leftRight, nodes)
step++
}
return step, nil
}
func move(current string, step int, leftRight string, nodes map[string][2]string) string {
instruction := leftRight[step%len(leftRight)]
paths := nodes[current]
if instruction == 'L' {
return paths[0]
} else {
return paths[1]
}
}
func Day08Part2(input io.Reader) (int, error) {
scanner := bufio.NewScanner(input)
scanner.Scan()
leftRight := scanner.Text()
scanner.Scan() // skip blank line
nodes := make(map[string][2]string)
var positions []string
for scanner.Scan() {
line := strings.Split(scanner.Text(), " = ") // AAA = (BBB, CCC)
node := line[0]
rest := strings.Split(strings.NewReplacer("(", "", " ", "", ")", "").Replace(line[1]), ",")
nodes[node] = [2]string{rest[0], rest[1]}
if strings.HasSuffix(node, "A") {
positions = append(positions, node)
}
}
step := 0
reachedZ := make([]int, len(positions))
for !allFinished(positions, reachedZ, step) {
for i := 0; i < len(positions); i++ {
positions[i] = move(positions[i], step, leftRight, nodes)
}
step++
}
return LCM(reachedZ[0], reachedZ[1], reachedZ[2:]...), nil
}
func allFinished(positions []string, reachedZ []int, step int) bool {
for i, pos := range positions {
if strings.HasSuffix(pos, "Z") && reachedZ[i] == 0 {
reachedZ[i] = step
}
}
for _, z := range reachedZ {
if z == 0 {
return false
}
}
return true
}
// GCD and LCM from https://siongui.github.io/2017/06/03/go-find-lcm-by-gcd/
func GCD(a, b int) int {
for b != 0 {
t := b
b = a % b
a = t
}
return a
}
func LCM(a, b int, integers ...int) int {
result := a * b / GCD(a, b)
for i := 0; i < len(integers); i++ {
result = LCM(result, integers[i])
}
return result
}

View file

@ -0,0 +1,26 @@
package _023
import (
"testing"
)
func TestDay08Part1(t *testing.T) {
tests := []testCase{
{"inputs/day08_test1", 2},
{"inputs/day08_test2", 6},
{"inputs/day08", 16271},
}
for _, test := range tests {
t.Run(test.filename, check(test, Day08Part1))
}
}
func TestDay08Part2(t *testing.T) {
tests := []testCase{
{"inputs/day08_test3", 6},
{"inputs/day08", 14265111103729},
}
for _, test := range tests {
t.Run(test.filename, check(test, Day08Part2))
}
}

75
2023/day09_series.go Normal file
View file

@ -0,0 +1,75 @@
package _023
import (
"bufio"
"io"
"slices"
)
func Day09Part1(input io.Reader) (int, error) {
scanner := bufio.NewScanner(input)
sum := 0
for scanner.Scan() {
line := lineToInts(scanner.Text())
diffs := [][]int{line}
for !day09AllZeros(line) {
line = day09Difference(line)
diffs = append(diffs, line)
}
lenDiffs := len(diffs)
diffs[lenDiffs-1] = append(diffs[lenDiffs-1], 0) // add a zero to the zeros list
for i := lenDiffs - 2; i >= 0; i-- { //starting with the last non 0
current := diffs[i]
prev := diffs[i+1]
current = append(current, current[len(current)-1]+prev[len(prev)-1])
diffs[i] = current
}
sum += diffs[0][len(diffs[0])-1]
}
return sum, nil
}
func day09Difference(line []int) []int {
diff := make([]int, len(line)-1)
for i := 0; i < len(line)-1; i++ {
diff[i] = line[i+1] - line[i]
}
return diff
}
func day09AllZeros(line []int) bool {
for _, d := range line {
if d != 0 {
return false
}
}
return true
}
func Day09Part2(input io.Reader) (int, error) {
scanner := bufio.NewScanner(input)
sum := 0
for scanner.Scan() {
line := lineToInts(scanner.Text())
slices.Reverse(line)
diffs := [][]int{line}
for !day09AllZeros(line) {
line = day09Difference(line)
diffs = append(diffs, line)
}
lenDiffs := len(diffs)
diffs[lenDiffs-1] = append(diffs[lenDiffs-1], 0) // add a zero to the zeros list
for i := lenDiffs - 2; i >= 0; i-- { //starting with the last non 0
current := diffs[i]
prev := diffs[i+1]
current = append(current, current[len(current)-1]+prev[len(prev)-1])
diffs[i] = current
}
sum += diffs[0][len(diffs[0])-1]
}
return sum, nil
}

42
2023/day09_series_test.go Normal file
View file

@ -0,0 +1,42 @@
package _023
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestDay09Part1(t *testing.T) {
tests := []testCase{
{"inputs/day09_test1", 114},
{"inputs/day09", 1904165718},
}
for _, test := range tests {
t.Run(test.filename, check(test, Day09Part1))
}
}
func TestDay09Part2(t *testing.T) {
tests := []testCase{
{"inputs/day09_test1", 2},
{"inputs/day09", 964},
}
for _, test := range tests {
t.Run(test.filename, check(test, Day09Part2))
}
}
func Test_day09Difference(t *testing.T) {
tests := []struct {
line []int
want []int
}{
{[]int{0, 3, 6, 9, 12, 15}, []int{3, 3, 3, 3, 3}},
{[]int{1, 3, 6, 10, 15, 21}, []int{2, 3, 4, 5, 6}},
}
for _, tt := range tests {
t.Run(fmt.Sprint(tt.line), func(t *testing.T) {
assert.Equalf(t, tt.want, day09Difference(tt.line), "day09Difference(%v)", tt.line)
})
}
}

1000
2023/inputs/day07 Normal file

File diff suppressed because it is too large Load diff

5
2023/inputs/day07_test1 Normal file
View file

@ -0,0 +1,5 @@
32T3K 765
T55J5 684
KK677 28
KTJJT 220
QQQJA 483

6
2023/inputs/day07_test2 Normal file
View file

@ -0,0 +1,6 @@
32T3K 765
T55J5 684
KK677 28
KTJJT 220
QQQJA 483
JJJJA 1

736
2023/inputs/day08 Normal file
View file

@ -0,0 +1,736 @@
LRLRRRLRRLRRRLRRRLLLLLRRRLRLRRLRLRLRRLRRLRRRLRLRLRRLLRLRRLRRLRRLRRRLLRRRLRRRLRRLRLLLRRLRRRLRLRRLRRRLRRLRLLLRRRLRRLRRLRRRLRRRLRRRLRLRLRLRRRLRRRLLLRRLLRRRLRLRLRRRLRRRLRRLRRRLRLRLLRRRLRLRRLRLRLRRLLLRRRLRRRLRRLRRLRLRRLLRRLRRRLRRRLLRRRLRRLRLLRRLRLRRLLRRRLLLLRRLRRRLRLRRLLRLLRRRLLRRLLRRRLRRRLRRLLRLRLLRRLLRLLLRRRR
FCG = (PLG, GXC)
PQT = (SQK, GHP)
NVS = (TPQ, PPB)
CTR = (SXS, KCV)
FNM = (KHG, FLD)
TFH = (CLD, CLD)
MLQ = (QQL, JVK)
LQR = (TFH, RRM)
QKX = (VPR, BHD)
QQL = (VBD, CPM)
QST = (HPC, DFJ)
QBX = (HPH, BTM)
TVB = (SHJ, GMF)
HJN = (CGJ, QXT)
PGV = (RXT, DQP)
TPN = (TQR, LJR)
BHV = (TGL, GJH)
DDF = (XLH, TDQ)
XMK = (XVN, RJP)
HXH = (JVM, CVB)
SFX = (VNH, BFS)
TRF = (HVJ, DKF)
GGQ = (NNP, PBL)
KQX = (VXK, FSF)
KGL = (QSJ, CBM)
CLC = (MCJ, JGQ)
GFF = (JBG, TVR)
FQT = (CMR, CKG)
HVJ = (FXB, GBP)
KTF = (PKG, JCL)
BLF = (QQL, JVK)
TVN = (QNN, DPQ)
KVX = (XNV, CJF)
GDK = (DVX, RKS)
CHS = (VCL, PSG)
LFS = (SNS, NTG)
NCR = (LFV, DRN)
NLJ = (RCR, XCF)
SRD = (LGT, PRS)
FQC = (GBX, RGQ)
SJH = (CKG, CMR)
BQP = (PPP, HGT)
LJR = (FPV, FQD)
XTP = (PDT, MTX)
RDG = (JRL, MFF)
TFF = (MJQ, MVB)
NGS = (BDG, KHS)
GXT = (QSJ, CBM)
VVD = (HJJ, RNK)
FRL = (CHS, JNV)
RQS = (CFM, SKM)
PRS = (VTG, PRR)
FCD = (VTN, DJQ)
PDT = (DST, DST)
MND = (MFV, GDR)
GJG = (TMJ, HPJ)
JSL = (DDN, JPZ)
DNX = (RHD, LKM)
BGM = (GFC, JTD)
BPC = (BMN, BKQ)
PPB = (BFT, PVH)
VRK = (TCL, JDS)
MBT = (CBB, JMM)
JGQ = (GGQ, DFH)
BGP = (MGH, VHG)
GGR = (TCX, QLG)
NCD = (XDT, SSK)
TDQ = (VPK, HCF)
PND = (BKV, THD)
RJP = (KRV, FQN)
MFZ = (MRL, MFK)
TCM = (RMM, CLB)
SDF = (LTS, RVQ)
KGS = (CTR, SJQ)
SFK = (SDF, HPF)
DJC = (MKF, PNR)
DPF = (KBH, QQX)
VQJ = (FVB, XPK)
CGX = (MLQ, BLF)
GBS = (DJC, XXQ)
JSV = (RMR, QFK)
KHS = (HSQ, PTD)
MKG = (NLJ, MHQ)
CXQ = (BDG, KHS)
RRQ = (FCT, CDT)
JSK = (LBC, CPT)
VSM = (RGM, VMR)
NNP = (SRD, VNQ)
PRR = (GMX, KQX)
HNP = (GQJ, DGS)
PKB = (KBL, HXJ)
MFS = (RMK, JBX)
RMM = (MFG, BPS)
PJM = (SFK, HLG)
BCH = (SRK, LSG)
VNQ = (LGT, PRS)
LTC = (TJX, DQD)
CKG = (NJG, GMJ)
RPS = (RXT, DQP)
CCV = (DPB, JQT)
JDF = (CFF, XFB)
LQX = (KBD, TVD)
VLL = (FMK, LCD)
RTB = (NTG, SNS)
FBF = (QTH, QFV)
CBB = (VJK, BHB)
BCL = (LJR, TQR)
JDS = (SPS, HRL)
HHB = (RHD, LKM)
PLG = (RBV, NJD)
RNB = (VMR, RGM)
CJT = (HJJ, RNK)
JVK = (VBD, CPM)
HXJ = (JTL, PFD)
JGX = (XMV, RHF)
FGT = (LFR, JSK)
MJQ = (BVP, BXM)
DFJ = (MRS, LTC)
GNG = (DPB, JQT)
VCA = (XFL, JSV)
KLR = (LTN, BXH)
VGN = (DGS, GQJ)
DVX = (JXX, XSH)
BTN = (PFP, FRL)
DTM = (DVD, FCF)
SVN = (PBF, GXR)
RCC = (BTB, CBD)
GMJ = (FCH, CSP)
DVS = (FSV, TVP)
RLG = (QML, XGD)
CVV = (HHB, DNX)
NRG = (NFG, DNL)
PQC = (RNG, KTF)
KGG = (DMD, HQG)
JNV = (PSG, VCL)
SNS = (CGX, MBK)
FRA = (MFK, MRL)
BPN = (QQX, KBH)
HCQ = (XMK, JDV)
RDD = (JGB, VHQ)
HTF = (VLX, RQV)
XFH = (DPH, RGG)
LBC = (JTV, DTK)
RBP = (LLL, MND)
GDV = (SHJ, GMF)
MJV = (JGV, JGV)
BQR = (FPK, HSS)
XDT = (BTN, FXF)
NGM = (NTF, BDN)
HPP = (FQX, FGT)
JPC = (JHC, PPH)
GCV = (CCS, TCM)
VHQ = (PBR, GVP)
MDD = (GGR, LXC)
HSQ = (CKV, KGS)
PPP = (DLP, HPP)
SNA = (BKK, FNM)
VLS = (DPH, RGG)
JGB = (PBR, GVP)
FPK = (RGS, XKQ)
LVB = (XMC, MNX)
FDP = (PFR, GFP)
NKS = (PCH, TJR)
VLX = (TLH, KFD)
DLT = (HGV, XJR)
MBK = (MLQ, BLF)
RNG = (PKG, PKG)
BKV = (DXB, GDQ)
LLL = (GDR, MFV)
LNN = (MVG, CKJ)
FXH = (TCM, CCS)
TPQ = (BFT, PVH)
MRH = (CJR, TFF)
MVG = (BQP, DXC)
LLN = (VTN, DJQ)
MLS = (THD, BKV)
HFR = (HNP, VGN)
XNF = (PVL, TPD)
JQT = (DVS, PST)
LNH = (FHQ, SPG)
MBR = (LQR, VPM)
KNV = (SKG, CKF)
JCV = (XMV, RHF)
JQJ = (TCQ, BGM)
SQF = (NRG, HDK)
FHF = (NNQ, PKB)
BDG = (HSQ, PTD)
PBT = (JRL, MFF)
LNS = (TCQ, BGM)
PTD = (CKV, KGS)
LHX = (GRM, XJQ)
NXN = (SFX, NQC)
VSZ = (XFS, DHL)
DPG = (JTS, VBG)
QTH = (DLT, JNS)
PMG = (TCL, JDS)
CCD = (FCG, GPJ)
SSP = (HTF, MNV)
STX = (HPC, DFJ)
KSR = (GKB, TSX)
KDP = (XGR, LLK)
NNQ = (HXJ, KBL)
TPM = (PDT, PDT)
SJQ = (KCV, SXS)
PJH = (BPN, DPF)
JBG = (FPN, XBP)
XQQ = (TLR, TLR)
XJL = (FTX, DXR)
RXT = (RMD, KVX)
CLD = (NTK, NTK)
SDM = (MRH, TGC)
RQV = (TLH, KFD)
NDL = (VDT, VDT)
CCT = (QFV, QTH)
LXL = (VGH, FRM)
TJR = (KGL, GXT)
VBD = (RSG, NCR)
XBG = (BHV, NPX)
JTS = (QDH, CST)
BFT = (JDF, MXT)
XLH = (HCF, VPK)
XBP = (GCV, FXH)
JPF = (RNG, KTF)
HHN = (TMJ, HPJ)
FSV = (GMC, HJN)
XFB = (JRN, RDD)
JPZ = (FNM, BKK)
BBP = (KDP, KKM)
TGL = (TGX, XRF)
JCL = (JDT, JDP)
RRS = (XPK, FVB)
NSB = (MCJ, JGQ)
DMD = (GFG, FDP)
FFX = (VBG, JTS)
XRF = (XFH, VLS)
LSG = (MFX, CVC)
BJZ = (FNK, QKX)
DLP = (FGT, FQX)
JDV = (RJP, XVN)
HDK = (DNL, NFG)
GQP = (NQC, SFX)
NFG = (PMG, VRK)
CSP = (GDP, NDV)
BKK = (FLD, KHG)
SCK = (KKM, KDP)
DXR = (SCK, BBP)
JVG = (PBT, RDG)
GSV = (QTK, JNT)
QXT = (BPC, NXQ)
GDQ = (LFJ, KSF)
NHG = (VVD, CJT)
DHL = (LNH, RPP)
NFS = (JGV, MFZ)
FCS = (BTB, CBD)
JGH = (VHP, RMG)
VQC = (GDC, VKQ)
PCH = (KGL, GXT)
LGT = (PRR, VTG)
PFV = (QCC, VSZ)
QQX = (FTV, LBD)
QFV = (JNS, DLT)
SCN = (RVX, RBP)
QRH = (BCL, TPN)
GBX = (VRH, CPG)
NTF = (RBK, RRN)
NDQ = (MBR, RDL)
KCP = (GFF, DDG)
JBX = (JPF, PQC)
GMF = (KLR, VTD)
JVM = (TXL, XTR)
BLC = (MNJ, VFF)
VTH = (TGC, MRH)
JHB = (BPN, DPF)
TMJ = (PND, MLS)
PFH = (HSS, FPK)
TDG = (KJV, QTR)
TGC = (TFF, CJR)
TVD = (CCT, FBF)
TKX = (FCT, CDT)
BKS = (HLG, SFK)
CGJ = (NXQ, BPC)
QHN = (SKG, CKF)
CVJ = (DMD, HQG)
BMN = (JLD, NHG)
GRP = (NDL, NDL)
FTX = (BBP, SCK)
DXC = (PPP, HGT)
NJD = (XSP, KSC)
CST = (RRQ, TKX)
SVH = (JHC, PPH)
JTV = (GCM, RLG)
BXJ = (DVD, FCF)
HCV = (XDT, SSK)
RDL = (LQR, VPM)
PSG = (MFS, MFC)
MVQ = (DRH, QBX)
XCF = (FVM, VVS)
DXB = (KSF, LFJ)
GHN = (JGH, FGR)
KLJ = (LSL, QJJ)
DFH = (NNP, PBL)
CDL = (XBG, FGD)
VFF = (KGR, FCJ)
KBD = (FBF, CCT)
NJL = (JGH, FGR)
VHG = (MBT, XPT)
GKB = (GJB, JKK)
KQP = (CXQ, NGS)
VSX = (GDC, VKQ)
RHX = (CDL, RGD)
NTK = (QCC, QCC)
KFD = (SKK, HGC)
ZZZ = (VFF, MNJ)
JLK = (HPL, MDF)
BTB = (PFT, CCD)
HQG = (GFG, FDP)
FVM = (VHC, NGC)
CVD = (NQP, FXM)
VGH = (CCV, GNG)
LSV = (NLJ, MHQ)
PVX = (KGG, CVJ)
THL = (NJL, GHN)
KKM = (XGR, LLK)
XGR = (LRT, DFP)
RRN = (TPM, XTP)
GBP = (GTD, QSL)
KJV = (MDD, QKK)
TBN = (TLV, JLK)
LDG = (TPN, BCL)
JLD = (CJT, VVD)
DKN = (CXQ, NGS)
DGV = (HCV, NCD)
HRL = (QHN, KNV)
RRM = (CLD, TQC)
RJS = (MGH, VHG)
MFF = (QTV, GJF)
PNR = (BTT, TVN)
JKK = (RVV, XPG)
XKQ = (PQT, FJD)
RMK = (JPF, PQC)
LCD = (RJS, BGP)
QTK = (GJG, HHN)
TBK = (CVB, JVM)
VTG = (GMX, KQX)
GFG = (PFR, GFP)
RSG = (LFV, LFV)
VCS = (PCH, TJR)
LJC = (QXF, XQR)
QHD = (XFM, LQM)
TSD = (PPB, TPQ)
RHP = (MXX, MTC)
GLZ = (JSV, XFL)
NXD = (VQJ, RRS)
MTJ = (QJJ, LSL)
XQH = (NQP, FXM)
GLK = (XCX, NDQ)
LSL = (NVS, TSD)
QGC = (LHX, LHT)
RHF = (GHM, TBT)
TQR = (FQD, FPV)
QSC = (XCX, NDQ)
RKS = (JXX, XSH)
HGC = (DCG, GDD)
XNV = (VQG, PVR)
CCS = (RMM, CLB)
RVR = (SJH, FQT)
JCM = (BKS, PJM)
GHM = (FCS, RCC)
PFT = (FCG, GPJ)
XDJ = (DTS, JVG)
RVQ = (FQC, PLV)
LQM = (RMH, XDJ)
CKV = (SJQ, CTR)
HPH = (TLX, RQG)
MTC = (FFX, DPG)
CKJ = (BQP, DXC)
MXT = (CFF, XFB)
VHT = (MQG, GTH)
QJJ = (TSD, NVS)
HNA = (DHL, XFS)
PVS = (TDG, SLR)
FPV = (GMD, GTK)
DDG = (TVR, JBG)
BHD = (LLN, FCD)
LDF = (NNQ, PKB)
CKF = (XXD, MJL)
TJF = (NRG, HDK)
JDT = (BLC, BLC)
GXR = (MGP, FNX)
BPS = (XNF, MXR)
FXB = (QSL, GTD)
TLH = (HGC, SKK)
PKV = (NCD, HCV)
CBM = (NXD, GTR)
JNT = (GJG, HHN)
TCQ = (JTD, GFC)
MRS = (TJX, DQD)
FBP = (VGN, HNP)
HPC = (MRS, LTC)
TJX = (PKV, DGV)
LFV = (MJV, MJV)
XVM = (SQF, TJF)
VVF = (PGV, RPS)
XPG = (DGF, DJK)
RGD = (XBG, FGD)
GMC = (QXT, CGJ)
CFM = (VVF, QPN)
SPS = (QHN, KNV)
JTL = (MNM, PTS)
MNM = (SXH, BDT)
RGG = (LNS, JQJ)
FPN = (GCV, FXH)
XJR = (KCP, HJS)
FQN = (LQX, MVF)
CFF = (JRN, RDD)
KSC = (QGH, LPG)
BHB = (DMR, JTX)
TBT = (RCC, FCS)
SKM = (VVF, QPN)
PVR = (PVS, PQQ)
QDN = (XMK, JDV)
JXX = (STX, QST)
TXL = (LKK, NSD)
XTR = (NSD, LKK)
VKQ = (HXH, TBK)
FQX = (JSK, LFR)
FRM = (CCV, GNG)
AAA = (MNJ, VFF)
BKQ = (NHG, JLD)
DPQ = (MGT, LXL)
KXL = (VQC, VSX)
RVV = (DGF, DGF)
TQC = (NTK, PFV)
NPX = (GJH, TGL)
MGH = (XPT, MBT)
VMR = (HGG, RHX)
DCG = (CLF, GBS)
CVB = (TXL, XTR)
HPJ = (MLS, PND)
NNR = (GDV, TVB)
RVX = (MND, LLL)
BVL = (SKM, CFM)
RFS = (XQR, QXF)
TVR = (XBP, FPN)
VTD = (LTN, BXH)
GPC = (XHK, BMP)
QGH = (RNB, VSM)
GDR = (PJH, JHB)
RMG = (KXL, TBV)
PST = (TVP, FSV)
GPJ = (GXC, PLG)
LBD = (KTN, GVD)
LLK = (LRT, DFP)
KGR = (MVQ, LKQ)
MQG = (XJL, NHN)
QXF = (NSH, STD)
GMD = (PFH, BQR)
BFS = (KGN, QHD)
RCR = (FVM, VVS)
RPP = (SPG, FHQ)
FMK = (BGP, RJS)
FGR = (RMG, VHP)
SXH = (RTB, LFS)
GVD = (GRP, TCF)
TGX = (XFH, VLS)
JTD = (NCJ, TBN)
MFV = (PJH, JHB)
HGV = (KCP, HJS)
HSS = (XKQ, RGS)
PTS = (BDT, SXH)
XSP = (LPG, QGH)
TCX = (PVX, XVF)
LKQ = (QBX, DRH)
FSF = (LSV, MKG)
XJQ = (RHP, NXM)
NHN = (FTX, DXR)
GQJ = (KQP, DKN)
TLX = (XQH, CVD)
HJJ = (VCS, NKS)
GTR = (VQJ, RRS)
RHD = (FJR, RVR)
VXK = (LSV, MKG)
MNX = (HBT, CLM)
PPH = (LVB, MRB)
GDP = (LCB, GDK)
DJQ = (BVL, RQS)
FCJ = (MVQ, LKQ)
VHC = (VHT, BSP)
PVL = (PPR, SSP)
LCB = (DVX, RKS)
PFD = (MNM, PTS)
MVF = (KBD, TVD)
DJK = (XQQ, TVF)
QSL = (GSV, KCF)
NXM = (MXX, MTC)
TJT = (CKJ, MVG)
GTH = (NHN, XJL)
SQK = (SPP, JCM)
DPH = (LNS, JQJ)
QPN = (RPS, PGV)
SRK = (MFX, CVC)
RFJ = (GKB, TSX)
QLG = (XVF, PVX)
QTV = (HLR, VLL)
PLV = (GBX, RGQ)
GHR = (SVH, JPC)
XMV = (GHM, TBT)
PKG = (JDT, JDT)
MGP = (RPG, QGC)
QDH = (TKX, RRQ)
HJR = (RBP, RVX)
NDV = (LCB, GDK)
KRV = (MVF, LQX)
NTM = (TJF, SQF)
NXQ = (BKQ, BMN)
HFF = (VDT, JSL)
SLR = (QTR, KJV)
DDN = (BKK, FNM)
LHT = (XJQ, GRM)
DST = (QKX, FNK)
PPR = (MNV, HTF)
JHC = (LVB, MRB)
MXX = (DPG, FFX)
VDT = (DDN, DDN)
XMC = (HBT, CLM)
TPD = (SSP, PPR)
BSP = (GTH, MQG)
NJG = (FCH, CSP)
MGT = (VGH, FRM)
NCJ = (TLV, JLK)
VCN = (NSB, CLC)
CBD = (CCD, PFT)
NQB = (XHK, BMP)
MFG = (XNF, MXR)
XFL = (RMR, QFK)
KCF = (JNT, QTK)
JTX = (MKB, NGM)
NTG = (MBK, CGX)
XCX = (MBR, RDL)
HGT = (HPP, DLP)
FJD = (GHP, SQK)
FXF = (PFP, FRL)
GFC = (TBN, NCJ)
NSD = (HFR, FBP)
HJS = (DDG, GFF)
MNV = (RQV, VLX)
VRH = (MTJ, KLJ)
GJH = (XRF, TGX)
JMM = (BHB, VJK)
BDN = (RBK, RRN)
JDP = (BLC, ZZZ)
GJK = (HHB, DNX)
TCF = (NDL, HFF)
JGV = (MFK, MRL)
LPG = (VSM, RNB)
KBH = (FTV, LBD)
CDT = (NXN, GQP)
QKK = (GGR, LXC)
RMD = (CJF, XNV)
MKF = (TVN, BTT)
RBV = (XSP, KSC)
RMH = (JVG, DTS)
RPG = (LHT, LHX)
FCH = (NDV, GDP)
HPF = (LTS, RVQ)
DRH = (BTM, HPH)
PFR = (RJR, DBR)
RJR = (SVN, VXJ)
MFK = (HCQ, QDN)
RGQ = (VRH, CPG)
BSX = (GHN, NJL)
TLR = (XFL, JSV)
KCV = (NQF, BCH)
PJC = (JGX, JCV)
XVF = (KGG, CVJ)
DKF = (GBP, FXB)
SKG = (XXD, MJL)
MVB = (BVP, BXM)
MJL = (GJK, CVV)
NSH = (VCN, VXF)
DVD = (BCQ, PJC)
VPR = (LLN, FCD)
HLG = (SDF, HPF)
FLD = (BXJ, DTM)
SKK = (GDD, DCG)
NQF = (SRK, LSG)
QNN = (LXL, MGT)
DMR = (MKB, NGM)
FVB = (NNR, PBH)
MXR = (TPD, PVL)
CLF = (DJC, XXQ)
FCT = (GQP, NXN)
RPA = (QKX, FNK)
MHQ = (XCF, RCR)
XPK = (PBH, NNR)
RBK = (TPM, TPM)
LVX = (TDQ, XLH)
RMR = (SDM, VTH)
PBF = (FNX, MGP)
GCM = (QML, XGD)
KSF = (BSX, THL)
XXD = (GJK, CVV)
DBR = (VXJ, SVN)
THD = (DXB, GDQ)
LFR = (LBC, CPT)
LKK = (FBP, HFR)
GFP = (RJR, DBR)
RNK = (VCS, NKS)
PBL = (VNQ, SRD)
FXM = (DDF, LVX)
KGN = (XFM, LQM)
VPK = (GPC, NQB)
JNS = (HGV, XJR)
GTK = (BQR, PFH)
FTV = (KTN, GVD)
MCJ = (DFH, GGQ)
MDF = (LJC, RFS)
JRL = (GJF, QTV)
MFC = (RMK, JBX)
VVS = (NGC, VHC)
TVF = (TLR, GLZ)
FCF = (BCQ, PJC)
SXS = (NQF, BCH)
GDC = (HXH, TBK)
XXQ = (MKF, PNR)
SPG = (GMR, TRF)
GVP = (LNN, TJT)
PQQ = (SLR, TDG)
HBT = (QRH, LDG)
XGD = (KSR, RFJ)
QML = (KSR, RFJ)
LKM = (RVR, FJR)
DRN = (MJV, NFS)
MKB = (NTF, BDN)
GHP = (JCM, SPP)
XPT = (JMM, CBB)
KTN = (GRP, TCF)
LRT = (SCN, HJR)
BVP = (QKT, GHR)
FNK = (VPR, BHD)
GRM = (RHP, NXM)
BXM = (QKT, GHR)
CPM = (RSG, NCR)
MRL = (HCQ, QDN)
VQG = (PVS, PQQ)
STD = (VXF, VCN)
DQD = (DGV, PKV)
TSX = (GJB, JKK)
GTD = (KCF, GSV)
FNX = (RPG, QGC)
BXH = (LDF, FHF)
CVC = (GLK, QSC)
TLV = (MDF, HPL)
DNL = (PMG, VRK)
FQD = (GTK, GMD)
CPG = (MTJ, KLJ)
SPP = (BKS, PJM)
GJB = (RVV, XPG)
SSK = (FXF, BTN)
PVH = (MXT, JDF)
XVN = (FQN, KRV)
LFJ = (BSX, THL)
VNH = (KGN, QHD)
HLR = (FMK, LCD)
KBL = (JTL, PFD)
BTM = (TLX, RQG)
DPB = (PST, DVS)
LTS = (FQC, PLV)
RQG = (CVD, XQH)
PBR = (LNN, TJT)
CLB = (MFG, BPS)
XFM = (RMH, XDJ)
CJR = (MJQ, MVB)
VTN = (BVL, RQS)
VBG = (QDH, CST)
GMR = (HVJ, DKF)
KHG = (BXJ, DTM)
GDD = (CLF, GBS)
QTR = (QKK, MDD)
VCL = (MFS, MFC)
TBV = (VQC, VSX)
BCQ = (JCV, JGX)
NGC = (VHT, BSP)
GJF = (HLR, VLL)
FGD = (NPX, BHV)
RGS = (PQT, FJD)
VXJ = (PBF, GXR)
FJR = (SJH, FQT)
VXF = (CLC, NSB)
HCF = (GPC, NQB)
DTK = (RLG, GCM)
MRB = (XMC, MNX)
MFX = (QSC, GLK)
GMX = (VXK, FSF)
BDT = (LFS, RTB)
JRN = (VHQ, JGB)
SHJ = (KLR, VTD)
TCL = (HRL, SPS)
CPT = (DTK, JTV)
VPM = (TFH, RRM)
DQP = (RMD, KVX)
CJF = (VQG, PVR)
PBH = (GDV, TVB)
LXC = (QLG, TCX)
FHQ = (GMR, TRF)
BMP = (XVM, NTM)
XHK = (NTM, XVM)
NQP = (LVX, DDF)
TVP = (GMC, HJN)
XFS = (LNH, RPP)
RGM = (RHX, HGG)
NQC = (VNH, BFS)
GXC = (RBV, NJD)
XQR = (NSH, STD)
BTT = (QNN, DPQ)
PFP = (CHS, JNV)
QKT = (SVH, JPC)
QCC = (DHL, XFS)
LTN = (LDF, FHF)
CMR = (GMJ, NJG)
DGF = (XQQ, XQQ)
MTX = (DST, BJZ)
QSJ = (GTR, NXD)
DFP = (HJR, SCN)
MNJ = (FCJ, KGR)
XSH = (QST, STX)
VHP = (KXL, TBV)
DGS = (KQP, DKN)
HPL = (LJC, RFS)
DTS = (RDG, PBT)
VJK = (JTX, DMR)
CLM = (LDG, QRH)
QFK = (SDM, VTH)
HGG = (CDL, RGD)

9
2023/inputs/day08_test1 Normal file
View file

@ -0,0 +1,9 @@
RL
AAA = (BBB, CCC)
BBB = (DDD, EEE)
CCC = (ZZZ, GGG)
DDD = (DDD, DDD)
EEE = (EEE, EEE)
GGG = (GGG, GGG)
ZZZ = (ZZZ, ZZZ)

5
2023/inputs/day08_test2 Normal file
View file

@ -0,0 +1,5 @@
LLR
AAA = (BBB, BBB)
BBB = (AAA, ZZZ)
ZZZ = (ZZZ, ZZZ)

10
2023/inputs/day08_test3 Normal file
View file

@ -0,0 +1,10 @@
LR
11A = (11B, XXX)
11B = (XXX, 11Z)
11Z = (11B, XXX)
22A = (22B, XXX)
22B = (22C, 22C)
22C = (22Z, 22Z)
22Z = (22B, 22B)
XXX = (XXX, XXX)

200
2023/inputs/day09 Normal file
View file

@ -0,0 +1,200 @@
1 2 5 13 33 89 245 643 1565 3535 7495 15128 29479 56181 105913 199391 377649 723582 1407901 2788593 5627669
18 37 79 153 277 493 883 1592 2876 5211 9525 17649 33125 62564 117833 219509 402350 724133 1280307 2228813 3832565
0 -9 -18 -18 16 148 529 1485 3668 8317 17736 36227 71969 140778 273424 529425 1022448 1966692 3762308 7156179 13552786
-6 -13 -17 3 93 334 845 1783 3355 5876 9945 16889 29783 55659 110077 226237 472643 986772 2038810 4152178 8331240
12 16 19 16 -4 -57 -159 -311 -455 -360 650 4330 14992 42932 112235 278107 664353 1542439 3494604 7743519 16805383
5 12 26 67 161 344 682 1315 2533 4892 9378 17627 32209 56984 97538 161707 260197 407308 621770 927699 1355681
14 15 13 22 68 189 435 868 1562 2603 4089 6130 8848 12377 16863 22464 29350 37703 47717 59598 73564
6 11 15 14 9 29 168 636 1824 4383 9317 18090 32747 56049 91622 144120 219402 324723 468939 662726 918813
29 44 60 77 95 114 134 155 177 200 224 249 275 302 330 359 389 420 452 485 519
16 25 54 125 268 531 1000 1831 3295 5837 10154 17307 28901 47401 76712 123255 197946 319769 522078 863433 1445754
8 26 68 151 289 488 741 1023 1286 1454 1418 1031 103 -1604 -4381 -8577 -14604 -22942 -34144 -48841 -67747
2 3 -1 -10 -24 -43 -67 -96 -130 -169 -213 -262 -316 -375 -439 -508 -582 -661 -745 -834 -928
7 13 33 81 180 370 719 1340 2423 4310 7686 14051 26822 53789 112413 240964 521347 1124596 2398905 5035064 10369168
17 22 21 12 1 15 116 414 1089 2461 5198 10830 22847 48812 104152 218701 447889 892160 1731591 3289164 6147909
13 22 26 19 -8 -54 -80 42 631 2416 6993 17716 41328 90818 190303 383279 746505 1413274 2612140 4730633 8418504
12 22 46 96 186 332 564 977 1863 3986 9102 20919 46896 101685 213755 437977 878922 1732618 3358882 6402518 11990162
6 15 45 108 213 359 526 668 721 664 727 1958 7600 26190 78141 209082 515888 1195973 2638517 5590376 11453671
18 33 67 128 234 433 841 1707 3523 7219 14518 28574 55077 104083 192914 350573 624232 1088477 1858133 3105644 5084148
3 13 34 76 154 295 563 1117 2335 5074 11212 24768 54173 116743 247182 513144 1042663 2070807 4016450 7604848 14058056
10 5 9 40 119 275 572 1187 2579 5792 12926 27793 56771 109925 202661 358645 615666 1037945 1741893 2949152 5094209
-5 6 40 101 196 343 575 947 1564 2659 4761 9004 17639 34822 67762 128324 235193 416716 714550 1188255 1920982
-5 -8 -11 -14 -17 -20 -23 -26 -29 -32 -35 -38 -41 -44 -47 -50 -53 -56 -59 -62 -65
-2 -6 -11 -7 23 110 319 800 1899 4371 9760 21063 43912 88761 175106 339921 654922 1262214 2447501 4787903 9443051
1 15 46 115 270 597 1233 2396 4460 8135 14888 27896 54101 108395 221665 455449 927379 1853511 3616170 6869185 12696480
23 35 57 104 213 460 996 2121 4421 9001 17858 34449 64514 117219 206746 354763 595215 985552 1634718 2771420 4902681
12 23 51 103 200 399 833 1791 3871 8244 17069 34114 65717 122501 223058 402809 735727 1385968 2724993 5585195 11787281
16 34 55 81 134 271 599 1290 2596 4864 8551 14239 22650 34661 51319 73856 103704 142510 192151 254749 332686
21 36 58 88 134 237 527 1336 3418 8363 19351 42481 89030 179135 347529 652141 1186880 2101731 3638869 6208271 10561015
9 23 57 129 275 569 1154 2281 4353 7971 13979 23505 37995 59237 89372 130889 186601 259599 353181 470753 615699
24 49 98 189 344 596 1006 1707 3017 5704 11546 24410 52175 109932 224964 443929 842206 1534087 2679674 4478799 7132250
10 18 31 41 39 22 6 51 311 1134 3270 8327 19792 45283 101347 223274 484376 1032454 2156417 4404153 8785029
8 9 15 33 66 112 167 239 398 919 2622 7576 20414 50604 116138 249238 504836 972765 1794801 3187923 5475410
-5 1 20 55 105 162 208 223 238 520 2074 7811 25004 70138 178193 420304 937698 2007916 4175473 8510152 17113700
26 45 76 138 267 516 967 1769 3221 5931 11111 21147 40779 79649 157802 317286 646012 1326146 2732120 5630315 11588031
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6
6 18 57 135 264 456 723 1077 1530 2094 2781 3603 4572 5700 6999 8481 10158 12042 14145 16479 19056
14 20 30 39 40 33 53 236 963 3171 9021 23307 56349 129771 287777 618778 1296332 2655754 5335708 10536103 20479854
-4 -3 9 47 144 368 840 1749 3374 6148 10847 19092 34582 65958 133165 281062 607651 1321275 2854710 6090655 12805047
3 15 32 54 81 113 150 192 239 291 348 410 477 549 626 708 795 887 984 1086 1193
11 9 10 21 49 101 184 305 471 689 966 1309 1725 2221 2804 3481 4259 5145 6146 7269 8521
19 39 63 98 168 320 630 1209 2209 3829 6321 9996 15230 22470 32240 45147 61887 83251 110131 143526 184548
9 21 46 109 247 514 989 1794 3133 5371 9203 16048 28985 54882 108922 223581 465353 964249 1963436 3899455 7527403
15 25 56 117 216 362 565 848 1298 2195 4270 9156 20111 43110 88425 172839 322673 577845 997228 1665631 2702794
22 45 81 150 300 620 1253 2409 4378 7543 12393 19536 29712 43806 62861 88091 120894 162865 215809 281754 362964
6 20 38 60 86 116 150 188 230 276 326 380 438 500 566 636 710 788 870 956 1046
12 24 45 78 135 256 554 1315 3196 7578 17145 36774 74835 145014 268786 478679 822484 1368580 2212557 3485334 5362983
8 14 27 53 96 174 346 757 1723 3905 8671 18833 40092 83754 171627 344514 676430 1297652 2431031 4447737 7950868
25 40 66 110 176 268 397 593 927 1556 2829 5556 11676 25804 58540 133043 297277 645600 1355076 2744138 5364120
18 26 30 38 70 158 346 690 1258 2130 3398 5166 7550 10678 14690 19738 25986 33610 42798 53750 66678
20 34 51 84 163 342 706 1378 2526 4370 7189 11328 17205 25318 36252 50686 69400 93282 123335 160684 206583
20 33 51 83 145 264 487 902 1689 3226 6279 12314 24000 46064 86916 162159 302903 576184 1134732 2334474 5000548
0 8 27 58 102 160 233 322 428 552 695 858 1042 1248 1477 1730 2008 2312 2643 3002 3390
9 11 25 67 166 377 808 1672 3386 6760 13365 26269 51533 101240 199496 393938 776999 1523753 2956889 5654599 10624336
16 35 59 87 118 151 185 219 252 283 311 335 354 367 373 371 360 339 307 263 206
30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300 315 330
14 14 5 -18 -59 -106 -99 122 892 2822 6929 14798 28779 52222 89753 147594 233930 359326 537197 784334 1121489
14 24 35 61 134 309 670 1338 2474 4259 6815 10006 13047 13920 8899 -6703 -33678 -53638 9119 371179 1557720
5 25 68 150 291 510 826 1286 2060 3677 7533 16890 38712 86858 187381 386974 765967 1457721 2676794 4758878 8216233
21 31 47 90 201 450 953 1904 3623 6612 11596 19497 31233 47133 65590 80309 75113 14709 -170955 -612140 -1539311
15 36 64 90 98 58 -72 -321 -630 -664 622 5911 21365 60036 147820 333332 703585 1407972 2693788 4957400 8816188
16 26 39 68 149 358 842 1876 3958 7954 15305 28308 50483 87038 145444 236132 373324 576010 869083 1284644 1863489
-4 -5 8 59 193 500 1167 2582 5523 11474 23119 45074 84926 154657 272540 465603 772766 1248765 1968986 3035341 4583327
11 15 16 20 34 70 156 355 796 1724 3579 7117 13589 24997 44449 76638 128473 209893 334898 522834 799972
2 6 6 10 51 214 673 1744 3981 8381 16841 33155 65084 128405 254368 502689 983157 1890385 3558905 6551449 11805694
6 28 65 117 184 266 363 475 602 744 901 1073 1260 1462 1679 1911 2158 2420 2697 2989 3296
-1 -5 1 30 105 264 563 1072 1850 2879 3944 4478 3462 -404 -7844 -16756 -17455 16251 142523 476766 1231119
17 30 49 81 140 264 551 1222 2719 5846 11961 23227 42930 75872 128847 211208 335533 518398 781265 1151493 1663480
5 20 48 94 169 306 587 1189 2479 5234 11149 23944 51613 110700 233968 483479 971961 1896440 3589502 6595266 11779241
19 40 68 105 167 293 552 1061 2044 3981 7923 16102 33077 67879 138022 276929 547405 1065426 2040890 3845315 7121031
10 1 1 36 145 396 915 1928 3822 7250 13353 24273 44324 82551 158115 311388 626674 1278851 2629519 5425536 11208063
30 60 120 232 435 807 1503 2823 5342 10155 19312 36537 68327 125480 224964 391814 660601 1076521 1698615 2614601 3992682
28 53 90 139 200 273 358 455 564 685 818 963 1120 1289 1470 1663 1868 2085 2314 2555 2808
0 2 17 60 146 290 507 812 1220 1746 2405 3212 4182 5330 6671 8220 9992 12002 14265 16796 19610
-7 -10 -13 -16 -19 -22 -25 -28 -31 -34 -37 -40 -43 -46 -49 -52 -55 -58 -61 -64 -67
5 4 -5 -24 -56 -114 -232 -476 -950 -1784 -3077 -4732 -6015 -4404 7279 47541 160619 445388 1109679 2566468 5595390
13 21 35 55 79 108 164 327 797 1987 4653 10067 20239 38194 68310 116723 191805 304721 470071 706623 1038143
6 21 44 82 149 264 453 763 1299 2298 4270 8308 16883 35943 80166 185159 433863 1010426 2305059 5110949 10984776
13 16 23 29 36 65 168 440 1031 2158 4117 7295 12182 19383 29630 43794 62897 88124 120835 162577 215096
15 26 45 79 135 220 341 505 719 990 1325 1731 2215 2784 3445 4205 5071 6050 7149 8375 9735
-9 -18 -36 -69 -124 -198 -252 -163 354 1860 5344 12416 25578 48756 88713 159042 290781 558322 1137792 2429825 5302996
8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160 168
17 46 103 206 388 712 1300 2382 4375 8011 14548 26123 46346 81289 141077 242285 411165 687140 1124613 1788316 2732208
16 21 31 65 153 353 795 1764 3834 8065 16275 31399 57947 102573 174767 287682 459108 712605 1078807 1596909 2316349
23 34 57 108 201 354 604 1029 1775 3086 5335 9054 14961 23982 37266 56191 82359 117578 163829 223216 297897
9 27 64 142 307 640 1275 2436 4510 8182 14667 26078 45976 80198 138240 235928 401051 685386 1189759 2114918 3863411
10 29 67 136 257 478 899 1708 3234 6028 10999 19667 34657 60655 106187 186773 330258 585439 1035499 1818234 3155625
-2 9 38 108 259 546 1047 1906 3455 6489 12817 26302 54787 113707 233086 471576 945264 1886981 3766784 7530800 15060663
3 7 16 35 82 210 550 1387 3285 7295 15329 30883 60459 116276 221169 416958 778112 1433601 2602525 4656219 8237305
14 24 35 43 35 -3 -70 -128 -78 266 1220 3343 7761 17025 37154 82021 181887 398477 849038 1740376 3409308
-2 8 43 111 218 368 563 803 1086 1408 1763 2143 2538 2936 3323 3683 3998 4248 4411 4463 4378
9 12 26 73 182 401 821 1620 3146 6069 11643 22130 41449 76124 136616 239135 408039 678938 1102632 1750023 2718152
2 17 53 136 311 643 1217 2137 3533 5605 8777 14140 24614 47813 102743 234743 547549 1270106 2892822 6440945 14015310
26 49 93 170 299 513 873 1492 2582 4566 8361 16061 32471 68340 146857 316265 673738 1409615 2887669 5787692 11353195
5 1 10 56 181 454 980 1909 3445 5855 9478 14734 22133 32284 45904 63827 87013 116557 153698 199828 256501
24 39 56 75 96 119 144 171 200 231 264 299 336 375 416 459 504 551 600 651 704
3 13 25 39 55 73 93 115 139 165 193 223 255 289 325 363 403 445 489 535 583
10 21 34 63 134 301 676 1472 3058 6025 11262 20041 34110 55793 88096 134818 200666 291373 413818 576147 787894
-7 -11 -15 -19 -23 -27 -31 -35 -39 -43 -47 -51 -55 -59 -63 -67 -71 -75 -79 -83 -87
14 35 64 112 198 349 598 990 1616 2699 4751 8817 16875 32716 64411 131458 284235 653047 1563605 3793592 9115133
6 10 15 37 112 305 732 1614 3394 6972 14168 28639 57697 115868 231710 460577 908067 1772593 3422433 6536025 12361049
22 33 51 86 161 337 748 1653 3524 7213 14286 27687 53009 100811 190639 357694 663450 1211969 2174197 3823164 6583761
10 21 49 100 187 335 580 965 1545 2437 3999 7299 15157 34267 79375 181502 404343 877384 1863208 3894345 8050454
18 17 26 64 149 302 571 1087 2174 4567 9859 21413 46151 97882 203168 411164 809418 1548293 2877488 5199102 9142817
5 19 53 127 283 596 1185 2224 3953 6689 10837 16901 25495 37354 53345 74478 101917 136991 181205 236251 304019
6 23 52 97 162 251 368 517 702 927 1196 1513 1882 2307 2792 3341 3958 4647 5412 6257 7186
12 9 6 3 0 -3 -6 -9 -12 -15 -18 -21 -24 -27 -30 -33 -36 -39 -42 -45 -48
24 31 47 94 210 472 1034 2180 4392 8433 15445 27062 45538 73890 116056 177068 263240 382371 543963 759454 1042466
13 22 56 135 285 547 999 1790 3182 5604 9753 16858 29415 53137 101829 208993 454391 1022818 2330042 5284217 11811429
15 32 56 90 138 221 403 825 1752 3654 7378 14553 28563 56825 115875 242116 513317 1089460 2286804 4706676 9451240
19 28 37 57 107 213 416 812 1663 3642 8312 18993 42245 90291 184823 362776 684819 1247496 2200151 3767985 6282815
15 25 43 69 103 145 195 253 319 393 475 565 663 769 883 1005 1135 1273 1419 1573 1735
6 4 2 -2 -1 38 201 662 1725 3892 8031 15838 31038 62294 129888 280514 619184 1376564 3048104 6675086 14398641
14 25 54 113 226 449 896 1780 3504 6873 13539 26832 53166 104235 200225 374259 678258 1190337 2023756 3337307 5346834
6 9 14 27 61 145 353 874 2163 5257 12427 28502 63518 137960 293040 610622 1251236 2525101 5021588 9838985 18981275
0 10 43 107 210 360 565 833 1172 1590 2095 2695 3398 4212 5145 6205 7400 8738 10227 11875 13690
12 19 40 76 135 249 496 1035 2168 4458 8968 17755 34867 68262 133308 258844 497196 940061 1742808 3160510 5599927
24 41 64 103 177 314 547 907 1413 2066 2883 4072 6575 13465 33270 87663 229018 579775 1418266 3359281 7719361
8 26 55 102 181 313 526 855 1342 2036 2993 4276 5955 8107 10816 14173 18276 23230 29147 36146 44353
3 5 8 9 8 13 51 206 718 2196 6039 15246 35955 80308 171630 353521 705548 1370539 2604028 4870064 9040319
5 4 18 73 207 470 924 1643 2713 4232 6310 9069 12643 17178 22832 29775 38189 48268 60218 74257 90615
18 26 29 27 20 8 -9 -31 -58 -90 -127 -169 -216 -268 -325 -387 -454 -526 -603 -685 -772
11 32 70 149 301 575 1060 1922 3455 6146 10754 18403 30689 49801 78656 121048 181811 266996 384062 542081 751957
17 27 44 80 161 350 788 1774 3928 8510 18001 37091 74282 144469 273309 505439 921847 1679483 3103634 5900372 11630003
5 6 10 16 23 30 36 40 41 38 30 16 -5 -34 -72 -120 -179 -250 -334 -432 -545
14 27 59 130 273 536 993 1771 3111 5500 9947 18553 35688 70409 141342 286287 580612 1171705 2342559 4628224 9028371
14 35 85 181 342 586 932 1411 2095 3169 5114 9174 18522 41075 96044 228618 541696 1262043 2873511 6376547 13778018
-2 11 39 84 145 218 304 441 790 1822 4666 11680 27309 59358 121095 235432 444375 830890 1567666 3019953 5950526
10 25 57 127 264 515 973 1828 3447 6500 12174 22560 41363 75176 135680 243287 432936 762987 1328439 2280029 3851154
3 6 22 62 140 286 569 1142 2331 4808 9925 20362 41406 83554 168001 338491 686971 1408130 2911732 6045290 12518080
8 3 -7 -21 -31 -22 34 212 732 2170 5847 14484 33241 71282 143976 275617 501802 868691 1422087 2170587 2990755
18 33 70 156 330 643 1162 1979 3226 5114 8071 13185 23415 46497 101268 230447 525022 1168683 2515744 5223422 10470116
26 37 43 41 34 50 189 712 2186 5699 13159 27691 54146 99736 174809 293778 476218 748145 1143491 1705789 2490082
18 46 88 158 289 543 1040 2015 3907 7479 13963 25219 43892 73546 118749 185078 279008 407644 578250 797524 1070563
13 35 71 121 179 244 346 602 1331 3271 7955 18317 39613 80756 156178 288346 511073 873779 1446871 2328425 3652367
-1 -5 -9 -13 -17 -21 -25 -29 -33 -37 -41 -45 -49 -53 -57 -61 -65 -69 -73 -77 -81
27 44 77 135 230 378 610 1021 1904 4041 9267 21519 48795 106902 226811 469346 954751 1922132 3847875 7677889 15273802
15 24 34 53 90 163 325 709 1599 3550 7610 15749 31686 62441 121145 231941 438231 816100 1495514 2692885 4759866
7 10 15 23 39 90 263 783 2162 5467 12781 27974 57991 115082 220915 414631 769109 1423735 2648809 4967614 9378391
17 23 36 79 196 462 993 1956 3579 6161 10082 15813 23926 35104 50151 70002 95733 128571 169904 221291 284472
17 42 73 120 208 390 772 1565 3189 6461 12919 25397 49116 93851 178246 338164 642177 1219036 2304341 4316798 7978560
-6 3 36 118 287 598 1125 1955 3161 4730 6409 7420 5994 -1275 -20021 -57652 -118837 -189150 -188903 140879 1495436
-7 -1 13 35 65 103 149 203 265 335 413 499 593 695 805 923 1049 1183 1325 1475 1633
12 22 54 128 267 503 893 1546 2671 4674 8359 15324 28688 54339 102956 193130 355990 641830 1129332 1938088 3245241
13 26 44 70 107 158 226 314 425 562 728 926 1159 1430 1742 2098 2501 2954 3460 4022 4643
18 36 54 71 86 109 201 556 1637 4377 10455 22656 45323 84908 150628 255231 415876 655130 1002084 1493589 2175612
21 28 35 42 49 56 63 70 77 84 91 98 105 112 119 126 133 140 147 154 161
13 22 48 118 277 593 1162 2113 3613 5872 9148 13752 20053 28483 39542 53803 71917 94618 122728 157162 198933
21 30 30 30 65 222 676 1739 3939 8167 15967 30115 55765 102669 189349 350666 651057 1206868 2222780 4049396 7271729
4 3 -2 5 55 195 489 1018 1878 3175 5016 7495 10673 14551 19035 23892 28696 32763 35074 34185 28123
10 14 21 31 44 60 79 101 126 154 185 219 256 296 339 385 434 486 541 599 660
10 29 74 156 295 526 905 1515 2474 3953 6229 9839 15994 27632 52024 107109 236526 544061 1269300 2946378 6722381
13 25 42 82 174 360 715 1407 2838 5951 12885 28350 62425 136005 290886 607518 1234795 2437881 4671948 8691734 15708864
6 28 75 155 268 396 489 453 147 -602 -1940 -3789 -5220 -2616 15247 79381 268921 773897 2029046 4990204 11689797
-1 -5 0 30 108 268 576 1183 2430 5045 10532 21989 45855 95536 198570 410046 836489 1676471 3286928 6287688 11721190
14 29 54 98 189 384 785 1567 3029 5680 10369 18475 32232 55470 95605 169013 314768 627603 1332540 2945508 6603935
11 26 49 89 173 365 795 1698 3463 6692 12269 21439 35897 57887 90311 136848 202083 291646 412361 572405 781477
-3 -1 20 78 206 463 959 1907 3712 7103 13312 24307 43097 74149 123993 202144 322543 505815 782764 1199676 1826184
22 33 58 106 185 306 487 757 1160 1759 2640 3916 5731 8264 11733 16399 22570 30605 40918 53982 70333
7 6 2 7 47 179 527 1340 3071 6477 12756 23780 42563 74225 127879 220088 380855 663636 1161854 2036313 3561575
5 2 -3 -11 -23 -40 -63 -93 -131 -178 -235 -303 -383 -476 -583 -705 -843 -998 -1171 -1363 -1575
14 17 20 27 45 79 141 302 827 2441 6777 17058 39080 82629 163648 307873 557428 983209 1708058 2949061 5092207
-2 8 25 45 73 129 253 511 1014 1983 3937 8174 17913 40879 94953 220177 503689 1130625 2486718 5363128 11362084
0 0 -1 0 16 70 191 406 728 1140 1575 1892 1848 1066 -1001 -5110 -12272 -23800 -41361 -67032 -103360
11 24 34 45 75 172 448 1152 2811 6472 14082 29061 57189 108121 198337 357476 642443 1168540 2175990 4166445 8171639
1 -9 -16 -14 7 76 275 811 2156 5303 12226 26734 56148 114724 230664 460136 914283 1809175 3554640 6906710 13221141
23 50 98 181 322 559 953 1596 2618 4209 6717 10970 19119 36541 75724 163652 355121 755792 1560820 3117847 6027344
12 25 54 115 226 407 680 1069 1600 2301 3202 4335 5734 7435 9476 11897 14740 18049 21870 26251 31242
11 17 42 107 245 518 1061 2166 4418 8894 17435 33000 60110 105389 178208 291437 462309 713399 1073720 1579937 2277699
7 18 42 96 195 354 603 1021 1795 3310 6276 11898 22095 39774 69165 116223 189103 298714 459358 689460 1012395
11 30 61 109 199 398 851 1842 3907 8067 16343 32918 66722 136990 284713 595242 1241293 2562574 5210887 10413037 20447811
10 16 26 56 130 296 657 1417 2942 5836 11032 19898 34358 57028 91367 141843 214114 315224 453814 640348 887354
-1 8 18 34 76 184 425 907 1807 3417 6214 11002 19332 34819 66873 140099 315719 736558 1715410 3899274 8560724
-10 0 36 108 225 399 651 1029 1669 2960 5913 12882 28842 63495 134550 272607 528168 981400 1755386 3033720 5083431
-6 -3 8 28 58 99 152 218 298 393 504 632 778 943 1128 1334 1562 1813 2088 2388 2714
-2 9 30 68 139 282 594 1289 2786 5854 11909 23715 47076 94778 195322 411328 876600 1867894 3939515 8170112 16610113
23 38 64 107 172 275 483 1002 2339 5570 12752 27523 55940 107611 197183 346254 585783 959078 1525448 2364611 3581956
12 33 76 153 274 446 675 979 1427 2229 3926 7790 16692 37034 83062 186312 415618 917825 1997244 4264543 8905314
27 48 81 131 217 401 843 1902 4322 9571 20449 42167 84252 163892 311749 581896 1068445 1932706 3446441 6059051 10499467
-8 -12 -16 -20 -24 -28 -32 -36 -40 -44 -48 -52 -56 -60 -64 -68 -72 -76 -80 -84 -88
7 11 25 55 107 187 301 455 655 907 1217 1591 2035 2555 3157 3847 4631 5515 6505 7607 8827
-3 -7 -9 -8 7 70 251 671 1530 3189 6411 12975 27039 57847 124650 265035 548215 1095205 2108163 3911470 7007307
2 -6 -10 -8 -8 -23 -53 -48 167 1042 3593 9954 24405 55244 118112 241785 478200 919974 1731648 3206632 5872438
8 15 46 109 204 316 409 426 300 -19 -516 -1037 -1184 -174 3343 11512 27552 56091 103562 178665 292900
12 22 54 115 220 418 830 1702 3480 6925 13313 24819 45290 81834 148135 271439 507282 970208 1896650 3770847 7571598
12 22 49 103 208 418 848 1746 3647 7665 16002 32797 65514 127180 239930 440499 788554 1379188 2361747 3968903 6563344
1 2 -3 -2 32 139 377 847 1760 3599 7494 16032 34867 75680 161286 334051 669387 1297152 2435643 4446058 7920570
21 34 42 51 84 194 483 1127 2407 4746 8752 15267 25422 40698 62993 94695 138761 198802 279174 385075 522648
15 16 14 16 41 122 308 666 1283 2268 3754 5900 8893 12950 18320 25286 34167 45320 59142 76072 96593
-5 -8 -9 -8 -5 0 7 16 27 40 55 72 91 112 135 160 187 216 247 280 315
20 25 40 76 144 255 420 650 956 1349 1840 2440 3160 4011 5004 6150 7460 8945 10616 12484 14560
10 29 57 85 95 71 33 115 721 2806 8342 21042 47428 98342 191012 351798 619756 1051171 1725223 2750963 4275789
1 8 37 110 271 597 1221 2396 4655 9160 18383 37324 75545 150385 291819 549534 1002917 1774784 3049825 5098898 8310475
11 29 60 100 142 182 228 314 524 1034 2183 4587 9313 18133 33881 60939 105881 178307 291902 465758 726000
16 14 20 46 100 184 308 550 1205 3079 8006 19713 45253 97399 198680 388187 732934 1346484 2418808 4263008 7386682
14 30 49 73 113 192 344 609 1024 1610 2355 3193 3979 4460 4242 2753 -798 -7466 -18619 -35991 -61739
19 27 48 90 166 309 606 1278 2854 6527 14864 33218 72550 155093 325726 674733 1383029 2811207 5673012 11369410 22624030
8 18 40 83 174 364 734 1413 2630 4833 8920 16640 31236 58417 107762 194676 343036 588684 983944 1603361 2550882
-9 -7 -4 2 20 65 158 328 629 1210 2514 5733 13710 32556 74340 161313 332243 651567 1222208 2203060 3832312
9 13 9 -9 -42 -81 -94 2 388 1410 3664 8094 16095 29610 51207 84119 132227 199963 292107 413449 568284
15 30 56 104 196 376 718 1335 2403 4231 7442 13395 25089 48958 98197 198569 398106 782967 1503527 2818741 5175193

3
2023/inputs/day09_test1 Normal file
View file

@ -0,0 +1,3 @@
0 3 6 9 12 15
1 3 6 10 15 21
10 13 16 21 30 45

0
2023/inputs/day09_test2 Normal file
View file

View file

@ -7,6 +7,11 @@ import (
"testing"
)
type testCase struct {
filename string
want int
}
func check(test testCase, fn solveFunc) func(t *testing.T) {
return func(t *testing.T) {
file, err := os.Open(test.filename)

View file

@ -2,9 +2,4 @@ package _023
import "io"
type testCase struct {
filename string
want int
}
type solveFunc func(reader io.Reader) (int, error)