commit c72df487f665a9a74670e0aecb6449348c6e85e0
parent 6de410490f9ed7ec54732f0cc1517c93d2e9e0df
Author: bsandro <email@bsandro.tech>
Date: Sat, 14 Dec 2024 21:50:39 +0200
Day 13 parsing
Diffstat:
4 files changed, 1429 insertions(+), 0 deletions(-)
diff --git a/day13/Makefile b/day13/Makefile
@@ -0,0 +1,28 @@
+NAME=$(shell basename ${PWD})
+SRC=$(wildcard *.cpp)
+DEPS:=$(wildcard *.hpp)
+OBJ:=$(SRC:.cpp=.o)
+CXXFLAGS=-O2 -std=c++23 -Werror -Wall -Wextra -I. -I../include
+LDFLAGS=-lstdc++
+
+all: $(NAME)
+
+.PHONY: clean run
+
+clean:
+ rm -f $(OBJ) $(NAME)
+
+%.o : %.c $(DEPS)
+ @$(CC) $(CFLAGS) -c $< -o $@
+
+$(NAME): $(OBJ)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
+
+run: $(NAME)
+ @./$(NAME) input.txt
+
+test1: $(NAME)
+ @./$(NAME) test1.txt
+
+test2: $(NAME)
+ @./$(NAME) test2.txt
diff --git a/day13/input.txt b/day13/input.txt
@@ -0,0 +1,1279 @@
+Button A: X+31, Y+85
+Button B: X+30, Y+24
+Prize: X=3096, Y=8256
+
+Button A: X+59, Y+62
+Button B: X+11, Y+57
+Prize: X=4193, Y=6860
+
+Button A: X+39, Y+12
+Button B: X+26, Y+72
+Prize: X=19360, Y=8576
+
+Button A: X+34, Y+60
+Button B: X+32, Y+14
+Prize: X=512, Y=13392
+
+Button A: X+28, Y+12
+Button B: X+33, Y+71
+Prize: X=2039, Y=4001
+
+Button A: X+26, Y+54
+Button B: X+66, Y+32
+Prize: X=6556, Y=12006
+
+Button A: X+68, Y+36
+Button B: X+22, Y+46
+Prize: X=6894, Y=8086
+
+Button A: X+37, Y+62
+Button B: X+35, Y+19
+Prize: X=18851, Y=2351
+
+Button A: X+11, Y+72
+Button B: X+80, Y+54
+Prize: X=1178, Y=5832
+
+Button A: X+14, Y+45
+Button B: X+67, Y+15
+Prize: X=11622, Y=6170
+
+Button A: X+72, Y+88
+Button B: X+73, Y+22
+Prize: X=10610, Y=6380
+
+Button A: X+21, Y+86
+Button B: X+79, Y+15
+Prize: X=4955, Y=2089
+
+Button A: X+53, Y+12
+Button B: X+37, Y+70
+Prize: X=17268, Y=2956
+
+Button A: X+44, Y+93
+Button B: X+74, Y+27
+Prize: X=7244, Y=7029
+
+Button A: X+16, Y+65
+Button B: X+98, Y+63
+Prize: X=6230, Y=8218
+
+Button A: X+28, Y+57
+Button B: X+59, Y+29
+Prize: X=2501, Y=14956
+
+Button A: X+56, Y+22
+Button B: X+59, Y+99
+Prize: X=7907, Y=10461
+
+Button A: X+93, Y+29
+Button B: X+24, Y+44
+Prize: X=9333, Y=5649
+
+Button A: X+50, Y+77
+Button B: X+47, Y+19
+Prize: X=18445, Y=2610
+
+Button A: X+83, Y+23
+Button B: X+26, Y+59
+Prize: X=4068, Y=1956
+
+Button A: X+41, Y+80
+Button B: X+59, Y+32
+Prize: X=5288, Y=4832
+
+Button A: X+12, Y+21
+Button B: X+47, Y+22
+Prize: X=7045, Y=7860
+
+Button A: X+74, Y+83
+Button B: X+17, Y+85
+Prize: X=2423, Y=4366
+
+Button A: X+85, Y+42
+Button B: X+45, Y+95
+Prize: X=8310, Y=10946
+
+Button A: X+16, Y+34
+Button B: X+53, Y+36
+Prize: X=1753, Y=9464
+
+Button A: X+70, Y+19
+Button B: X+18, Y+58
+Prize: X=16504, Y=18135
+
+Button A: X+73, Y+20
+Button B: X+68, Y+84
+Prize: X=4742, Y=5156
+
+Button A: X+67, Y+15
+Button B: X+74, Y+77
+Prize: X=7922, Y=7696
+
+Button A: X+76, Y+41
+Button B: X+18, Y+50
+Prize: X=15882, Y=5599
+
+Button A: X+63, Y+29
+Button B: X+18, Y+42
+Prize: X=11195, Y=10957
+
+Button A: X+19, Y+55
+Button B: X+55, Y+26
+Prize: X=4334, Y=4142
+
+Button A: X+55, Y+21
+Button B: X+31, Y+68
+Prize: X=3889, Y=526
+
+Button A: X+15, Y+31
+Button B: X+58, Y+35
+Prize: X=3296, Y=4956
+
+Button A: X+46, Y+30
+Button B: X+20, Y+44
+Prize: X=12904, Y=15480
+
+Button A: X+14, Y+31
+Button B: X+64, Y+34
+Prize: X=5750, Y=14425
+
+Button A: X+61, Y+69
+Button B: X+99, Y+32
+Prize: X=9981, Y=6331
+
+Button A: X+26, Y+49
+Button B: X+35, Y+21
+Prize: X=16844, Y=11512
+
+Button A: X+13, Y+47
+Button B: X+89, Y+66
+Prize: X=7439, Y=5666
+
+Button A: X+25, Y+13
+Button B: X+35, Y+55
+Prize: X=8920, Y=896
+
+Button A: X+34, Y+13
+Button B: X+17, Y+30
+Prize: X=9645, Y=6071
+
+Button A: X+55, Y+18
+Button B: X+13, Y+45
+Prize: X=15692, Y=611
+
+Button A: X+15, Y+47
+Button B: X+64, Y+17
+Prize: X=14398, Y=19293
+
+Button A: X+27, Y+86
+Button B: X+83, Y+61
+Prize: X=6769, Y=5901
+
+Button A: X+14, Y+73
+Button B: X+58, Y+11
+Prize: X=2464, Y=3888
+
+Button A: X+24, Y+91
+Button B: X+64, Y+16
+Prize: X=4488, Y=5457
+
+Button A: X+22, Y+42
+Button B: X+62, Y+38
+Prize: X=5982, Y=8262
+
+Button A: X+26, Y+83
+Button B: X+98, Y+25
+Prize: X=2838, Y=3015
+
+Button A: X+23, Y+11
+Button B: X+12, Y+23
+Prize: X=16176, Y=247
+
+Button A: X+16, Y+81
+Button B: X+68, Y+13
+Prize: X=2320, Y=3120
+
+Button A: X+56, Y+22
+Button B: X+39, Y+72
+Prize: X=9611, Y=10688
+
+Button A: X+15, Y+49
+Button B: X+70, Y+14
+Prize: X=12990, Y=16846
+
+Button A: X+20, Y+42
+Button B: X+69, Y+43
+Prize: X=17421, Y=11009
+
+Button A: X+44, Y+17
+Button B: X+36, Y+67
+Prize: X=6204, Y=9733
+
+Button A: X+69, Y+58
+Button B: X+19, Y+56
+Prize: X=7605, Y=8314
+
+Button A: X+42, Y+26
+Button B: X+13, Y+43
+Prize: X=14897, Y=19635
+
+Button A: X+95, Y+12
+Button B: X+49, Y+39
+Prize: X=5462, Y=2757
+
+Button A: X+91, Y+47
+Button B: X+11, Y+69
+Prize: X=5799, Y=9137
+
+Button A: X+32, Y+63
+Button B: X+40, Y+16
+Prize: X=4488, Y=3753
+
+Button A: X+24, Y+26
+Button B: X+67, Y+13
+Prize: X=4057, Y=1833
+
+Button A: X+56, Y+28
+Button B: X+41, Y+72
+Prize: X=2960, Y=4776
+
+Button A: X+17, Y+37
+Button B: X+22, Y+14
+Prize: X=2352, Y=3696
+
+Button A: X+61, Y+15
+Button B: X+25, Y+39
+Prize: X=4483, Y=2745
+
+Button A: X+31, Y+89
+Button B: X+92, Y+74
+Prize: X=4558, Y=7382
+
+Button A: X+92, Y+90
+Button B: X+88, Y+16
+Prize: X=12928, Y=8652
+
+Button A: X+23, Y+54
+Button B: X+75, Y+44
+Prize: X=13273, Y=2702
+
+Button A: X+92, Y+35
+Button B: X+69, Y+87
+Prize: X=6486, Y=4776
+
+Button A: X+11, Y+42
+Button B: X+57, Y+22
+Prize: X=10231, Y=15522
+
+Button A: X+32, Y+77
+Button B: X+39, Y+13
+Prize: X=1008, Y=19784
+
+Button A: X+58, Y+33
+Button B: X+23, Y+85
+Prize: X=4499, Y=7378
+
+Button A: X+52, Y+94
+Button B: X+44, Y+23
+Prize: X=3920, Y=6860
+
+Button A: X+55, Y+53
+Button B: X+16, Y+81
+Prize: X=5253, Y=11489
+
+Button A: X+93, Y+17
+Button B: X+13, Y+20
+Prize: X=9229, Y=1969
+
+Button A: X+14, Y+72
+Button B: X+93, Y+49
+Prize: X=3526, Y=3538
+
+Button A: X+31, Y+75
+Button B: X+58, Y+16
+Prize: X=9764, Y=4452
+
+Button A: X+59, Y+11
+Button B: X+15, Y+59
+Prize: X=18486, Y=2694
+
+Button A: X+55, Y+23
+Button B: X+14, Y+43
+Prize: X=9234, Y=19372
+
+Button A: X+58, Y+15
+Button B: X+13, Y+50
+Prize: X=7834, Y=15825
+
+Button A: X+18, Y+52
+Button B: X+76, Y+37
+Prize: X=19406, Y=19423
+
+Button A: X+80, Y+31
+Button B: X+35, Y+56
+Prize: X=3185, Y=4417
+
+Button A: X+37, Y+71
+Button B: X+49, Y+12
+Prize: X=7053, Y=10444
+
+Button A: X+24, Y+51
+Button B: X+50, Y+30
+Prize: X=3854, Y=16391
+
+Button A: X+47, Y+15
+Button B: X+11, Y+99
+Prize: X=1783, Y=5439
+
+Button A: X+50, Y+13
+Button B: X+39, Y+61
+Prize: X=4118, Y=4224
+
+Button A: X+37, Y+21
+Button B: X+21, Y+54
+Prize: X=4810, Y=7871
+
+Button A: X+32, Y+78
+Button B: X+95, Y+48
+Prize: X=5756, Y=7422
+
+Button A: X+62, Y+68
+Button B: X+18, Y+99
+Prize: X=3684, Y=6339
+
+Button A: X+48, Y+18
+Button B: X+30, Y+72
+Prize: X=7766, Y=11222
+
+Button A: X+14, Y+30
+Button B: X+74, Y+47
+Prize: X=8212, Y=1767
+
+Button A: X+12, Y+30
+Button B: X+73, Y+39
+Prize: X=2459, Y=2847
+
+Button A: X+42, Y+46
+Button B: X+88, Y+25
+Prize: X=10008, Y=4751
+
+Button A: X+16, Y+99
+Button B: X+97, Y+88
+Prize: X=10202, Y=17028
+
+Button A: X+29, Y+75
+Button B: X+91, Y+30
+Prize: X=7720, Y=4770
+
+Button A: X+42, Y+53
+Button B: X+87, Y+19
+Prize: X=9531, Y=3221
+
+Button A: X+18, Y+55
+Button B: X+70, Y+35
+Prize: X=10724, Y=18660
+
+Button A: X+25, Y+71
+Button B: X+47, Y+37
+Prize: X=2412, Y=2412
+
+Button A: X+16, Y+28
+Button B: X+54, Y+24
+Prize: X=8254, Y=12076
+
+Button A: X+72, Y+21
+Button B: X+16, Y+60
+Prize: X=2808, Y=3875
+
+Button A: X+30, Y+70
+Button B: X+53, Y+20
+Prize: X=12179, Y=11940
+
+Button A: X+97, Y+47
+Button B: X+20, Y+49
+Prize: X=7442, Y=5650
+
+Button A: X+26, Y+81
+Button B: X+66, Y+42
+Prize: X=5260, Y=8697
+
+Button A: X+20, Y+57
+Button B: X+74, Y+23
+Prize: X=1916, Y=4709
+
+Button A: X+29, Y+62
+Button B: X+52, Y+13
+Prize: X=9832, Y=6736
+
+Button A: X+56, Y+40
+Button B: X+28, Y+98
+Prize: X=4900, Y=11222
+
+Button A: X+18, Y+70
+Button B: X+91, Y+59
+Prize: X=8890, Y=8622
+
+Button A: X+39, Y+63
+Button B: X+31, Y+16
+Prize: X=4286, Y=13712
+
+Button A: X+53, Y+60
+Button B: X+94, Y+13
+Prize: X=9291, Y=2391
+
+Button A: X+75, Y+77
+Button B: X+18, Y+81
+Prize: X=5658, Y=7747
+
+Button A: X+70, Y+35
+Button B: X+64, Y+98
+Prize: X=2294, Y=2863
+
+Button A: X+88, Y+16
+Button B: X+22, Y+45
+Prize: X=4884, Y=1298
+
+Button A: X+78, Y+27
+Button B: X+13, Y+65
+Prize: X=16396, Y=17208
+
+Button A: X+35, Y+15
+Button B: X+43, Y+67
+Prize: X=6514, Y=12966
+
+Button A: X+12, Y+50
+Button B: X+34, Y+14
+Prize: X=11440, Y=4888
+
+Button A: X+56, Y+28
+Button B: X+21, Y+65
+Prize: X=6013, Y=5241
+
+Button A: X+48, Y+16
+Button B: X+37, Y+63
+Prize: X=6942, Y=7866
+
+Button A: X+59, Y+15
+Button B: X+14, Y+31
+Prize: X=9266, Y=7349
+
+Button A: X+44, Y+64
+Button B: X+48, Y+15
+Prize: X=4360, Y=3272
+
+Button A: X+31, Y+96
+Button B: X+82, Y+40
+Prize: X=7611, Y=8808
+
+Button A: X+76, Y+28
+Button B: X+14, Y+54
+Prize: X=17116, Y=5740
+
+Button A: X+42, Y+23
+Button B: X+15, Y+45
+Prize: X=5741, Y=6774
+
+Button A: X+54, Y+90
+Button B: X+81, Y+38
+Prize: X=8910, Y=6314
+
+Button A: X+11, Y+65
+Button B: X+60, Y+11
+Prize: X=17751, Y=18609
+
+Button A: X+35, Y+11
+Button B: X+38, Y+73
+Prize: X=9697, Y=14514
+
+Button A: X+29, Y+89
+Button B: X+86, Y+59
+Prize: X=2972, Y=6047
+
+Button A: X+28, Y+75
+Button B: X+63, Y+14
+Prize: X=16622, Y=14291
+
+Button A: X+12, Y+51
+Button B: X+78, Y+31
+Prize: X=14348, Y=11996
+
+Button A: X+58, Y+25
+Button B: X+21, Y+60
+Prize: X=4510, Y=6835
+
+Button A: X+58, Y+13
+Button B: X+15, Y+56
+Prize: X=18050, Y=6227
+
+Button A: X+73, Y+13
+Button B: X+18, Y+64
+Prize: X=15496, Y=12872
+
+Button A: X+92, Y+12
+Button B: X+62, Y+57
+Prize: X=11486, Y=4971
+
+Button A: X+28, Y+73
+Button B: X+83, Y+62
+Prize: X=4125, Y=3498
+
+Button A: X+25, Y+61
+Button B: X+80, Y+59
+Prize: X=4300, Y=3682
+
+Button A: X+13, Y+89
+Button B: X+85, Y+63
+Prize: X=6446, Y=5730
+
+Button A: X+70, Y+31
+Button B: X+36, Y+57
+Prize: X=4956, Y=4494
+
+Button A: X+57, Y+18
+Button B: X+38, Y+75
+Prize: X=16707, Y=7106
+
+Button A: X+46, Y+12
+Button B: X+22, Y+64
+Prize: X=2646, Y=9092
+
+Button A: X+39, Y+19
+Button B: X+15, Y+46
+Prize: X=5456, Y=9580
+
+Button A: X+18, Y+92
+Button B: X+20, Y+12
+Prize: X=2682, Y=5588
+
+Button A: X+83, Y+87
+Button B: X+87, Y+22
+Prize: X=8592, Y=3955
+
+Button A: X+22, Y+44
+Button B: X+44, Y+23
+Prize: X=13938, Y=13586
+
+Button A: X+88, Y+85
+Button B: X+11, Y+97
+Prize: X=8437, Y=12209
+
+Button A: X+21, Y+45
+Button B: X+58, Y+25
+Prize: X=2918, Y=4565
+
+Button A: X+52, Y+32
+Button B: X+20, Y+49
+Prize: X=15176, Y=1670
+
+Button A: X+95, Y+59
+Button B: X+44, Y+95
+Prize: X=2309, Y=4547
+
+Button A: X+15, Y+45
+Button B: X+67, Y+34
+Prize: X=12188, Y=15341
+
+Button A: X+79, Y+23
+Button B: X+14, Y+61
+Prize: X=18404, Y=3995
+
+Button A: X+33, Y+13
+Button B: X+44, Y+73
+Prize: X=5787, Y=14728
+
+Button A: X+67, Y+31
+Button B: X+25, Y+57
+Prize: X=10265, Y=1785
+
+Button A: X+30, Y+11
+Button B: X+23, Y+59
+Prize: X=16691, Y=10624
+
+Button A: X+61, Y+30
+Button B: X+35, Y+65
+Prize: X=1705, Y=19620
+
+Button A: X+52, Y+12
+Button B: X+29, Y+80
+Prize: X=18572, Y=11200
+
+Button A: X+44, Y+12
+Button B: X+29, Y+77
+Prize: X=2974, Y=5182
+
+Button A: X+36, Y+62
+Button B: X+49, Y+21
+Prize: X=10460, Y=1406
+
+Button A: X+77, Y+43
+Button B: X+27, Y+84
+Prize: X=7799, Y=8146
+
+Button A: X+28, Y+48
+Button B: X+39, Y+18
+Prize: X=12722, Y=3212
+
+Button A: X+51, Y+21
+Button B: X+26, Y+55
+Prize: X=6510, Y=10255
+
+Button A: X+36, Y+11
+Button B: X+26, Y+59
+Prize: X=5402, Y=5684
+
+Button A: X+34, Y+79
+Button B: X+65, Y+22
+Prize: X=7764, Y=5395
+
+Button A: X+28, Y+52
+Button B: X+50, Y+17
+Prize: X=18074, Y=5915
+
+Button A: X+32, Y+11
+Button B: X+21, Y+40
+Prize: X=6955, Y=12543
+
+Button A: X+63, Y+28
+Button B: X+11, Y+46
+Prize: X=4208, Y=5118
+
+Button A: X+35, Y+62
+Button B: X+55, Y+27
+Prize: X=6030, Y=1585
+
+Button A: X+68, Y+31
+Button B: X+14, Y+43
+Prize: X=9228, Y=9991
+
+Button A: X+33, Y+93
+Button B: X+75, Y+35
+Prize: X=3273, Y=7813
+
+Button A: X+60, Y+32
+Button B: X+34, Y+61
+Prize: X=7250, Y=6479
+
+Button A: X+63, Y+20
+Button B: X+17, Y+34
+Prize: X=2996, Y=3554
+
+Button A: X+20, Y+43
+Button B: X+53, Y+36
+Prize: X=5590, Y=16608
+
+Button A: X+24, Y+56
+Button B: X+50, Y+21
+Prize: X=15338, Y=11169
+
+Button A: X+43, Y+11
+Button B: X+43, Y+79
+Prize: X=6928, Y=3880
+
+Button A: X+98, Y+26
+Button B: X+28, Y+30
+Prize: X=9478, Y=3756
+
+Button A: X+26, Y+30
+Button B: X+56, Y+15
+Prize: X=4470, Y=2925
+
+Button A: X+39, Y+60
+Button B: X+51, Y+25
+Prize: X=17102, Y=10135
+
+Button A: X+96, Y+38
+Button B: X+38, Y+50
+Prize: X=6820, Y=5706
+
+Button A: X+15, Y+45
+Button B: X+65, Y+20
+Prize: X=12825, Y=19350
+
+Button A: X+50, Y+14
+Button B: X+55, Y+81
+Prize: X=5905, Y=4343
+
+Button A: X+11, Y+75
+Button B: X+68, Y+16
+Prize: X=10709, Y=17713
+
+Button A: X+64, Y+12
+Button B: X+11, Y+58
+Prize: X=3722, Y=18036
+
+Button A: X+19, Y+87
+Button B: X+51, Y+13
+Prize: X=1912, Y=816
+
+Button A: X+76, Y+21
+Button B: X+38, Y+80
+Prize: X=4826, Y=6963
+
+Button A: X+13, Y+65
+Button B: X+78, Y+26
+Prize: X=1898, Y=5850
+
+Button A: X+78, Y+14
+Button B: X+22, Y+38
+Prize: X=3040, Y=784
+
+Button A: X+72, Y+36
+Button B: X+33, Y+80
+Prize: X=7893, Y=8328
+
+Button A: X+89, Y+19
+Button B: X+19, Y+39
+Prize: X=6117, Y=3717
+
+Button A: X+58, Y+20
+Button B: X+25, Y+71
+Prize: X=15562, Y=1008
+
+Button A: X+83, Y+56
+Button B: X+24, Y+50
+Prize: X=8392, Y=8130
+
+Button A: X+50, Y+47
+Button B: X+96, Y+12
+Prize: X=11662, Y=5329
+
+Button A: X+59, Y+32
+Button B: X+23, Y+44
+Prize: X=4088, Y=2564
+
+Button A: X+56, Y+51
+Button B: X+18, Y+66
+Prize: X=5410, Y=6564
+
+Button A: X+71, Y+82
+Button B: X+84, Y+12
+Prize: X=10998, Y=7176
+
+Button A: X+32, Y+13
+Button B: X+13, Y+19
+Prize: X=1284, Y=1235
+
+Button A: X+13, Y+60
+Button B: X+66, Y+16
+Prize: X=3424, Y=9816
+
+Button A: X+18, Y+34
+Button B: X+27, Y+12
+Prize: X=3024, Y=3840
+
+Button A: X+71, Y+12
+Button B: X+12, Y+45
+Prize: X=6270, Y=3681
+
+Button A: X+62, Y+87
+Button B: X+82, Y+17
+Prize: X=3450, Y=1605
+
+Button A: X+36, Y+94
+Button B: X+99, Y+16
+Prize: X=7668, Y=2562
+
+Button A: X+92, Y+62
+Button B: X+19, Y+56
+Prize: X=6111, Y=6926
+
+Button A: X+22, Y+69
+Button B: X+74, Y+25
+Prize: X=11560, Y=15128
+
+Button A: X+51, Y+31
+Button B: X+11, Y+29
+Prize: X=8486, Y=13262
+
+Button A: X+50, Y+19
+Button B: X+16, Y+30
+Prize: X=18834, Y=9771
+
+Button A: X+66, Y+15
+Button B: X+53, Y+99
+Prize: X=2105, Y=3174
+
+Button A: X+33, Y+11
+Button B: X+21, Y+50
+Prize: X=18119, Y=3119
+
+Button A: X+60, Y+17
+Button B: X+12, Y+45
+Prize: X=2292, Y=1731
+
+Button A: X+44, Y+42
+Button B: X+92, Y+19
+Prize: X=12016, Y=5345
+
+Button A: X+57, Y+27
+Button B: X+11, Y+41
+Prize: X=3153, Y=3483
+
+Button A: X+19, Y+62
+Button B: X+92, Y+28
+Prize: X=7951, Y=6074
+
+Button A: X+25, Y+78
+Button B: X+53, Y+13
+Prize: X=9787, Y=13653
+
+Button A: X+28, Y+55
+Button B: X+58, Y+18
+Prize: X=742, Y=11404
+
+Button A: X+36, Y+46
+Button B: X+96, Y+34
+Prize: X=8964, Y=5868
+
+Button A: X+18, Y+40
+Button B: X+68, Y+48
+Prize: X=16366, Y=1272
+
+Button A: X+70, Y+92
+Button B: X+85, Y+19
+Prize: X=6130, Y=3050
+
+Button A: X+78, Y+40
+Button B: X+11, Y+76
+Prize: X=6375, Y=8124
+
+Button A: X+74, Y+21
+Button B: X+14, Y+53
+Prize: X=12394, Y=4011
+
+Button A: X+57, Y+29
+Button B: X+18, Y+51
+Prize: X=2372, Y=17349
+
+Button A: X+15, Y+64
+Button B: X+74, Y+17
+Prize: X=14831, Y=10060
+
+Button A: X+57, Y+96
+Button B: X+40, Y+13
+Prize: X=4537, Y=4651
+
+Button A: X+36, Y+81
+Button B: X+93, Y+40
+Prize: X=9309, Y=4528
+
+Button A: X+39, Y+65
+Button B: X+44, Y+17
+Prize: X=807, Y=7219
+
+Button A: X+15, Y+22
+Button B: X+51, Y+21
+Prize: X=1824, Y=1653
+
+Button A: X+41, Y+26
+Button B: X+28, Y+54
+Prize: X=7326, Y=3010
+
+Button A: X+26, Y+68
+Button B: X+51, Y+14
+Prize: X=6235, Y=12190
+
+Button A: X+24, Y+45
+Button B: X+59, Y+29
+Prize: X=9878, Y=16586
+
+Button A: X+73, Y+24
+Button B: X+22, Y+87
+Prize: X=7200, Y=9945
+
+Button A: X+59, Y+12
+Button B: X+17, Y+62
+Prize: X=13527, Y=11308
+
+Button A: X+74, Y+12
+Button B: X+18, Y+62
+Prize: X=13170, Y=15556
+
+Button A: X+76, Y+38
+Button B: X+29, Y+77
+Prize: X=2488, Y=3494
+
+Button A: X+25, Y+56
+Button B: X+76, Y+50
+Prize: X=6000, Y=4422
+
+Button A: X+74, Y+45
+Button B: X+22, Y+48
+Prize: X=6676, Y=13205
+
+Button A: X+24, Y+12
+Button B: X+17, Y+55
+Prize: X=3891, Y=12109
+
+Button A: X+13, Y+67
+Button B: X+79, Y+13
+Prize: X=2690, Y=4010
+
+Button A: X+15, Y+36
+Button B: X+34, Y+25
+Prize: X=18036, Y=9471
+
+Button A: X+40, Y+12
+Button B: X+56, Y+86
+Prize: X=18760, Y=4302
+
+Button A: X+11, Y+63
+Button B: X+73, Y+16
+Prize: X=17098, Y=11612
+
+Button A: X+65, Y+51
+Button B: X+11, Y+68
+Prize: X=4856, Y=4760
+
+Button A: X+60, Y+92
+Button B: X+98, Y+17
+Prize: X=11144, Y=5360
+
+Button A: X+17, Y+45
+Button B: X+52, Y+11
+Prize: X=19479, Y=7265
+
+Button A: X+43, Y+84
+Button B: X+61, Y+26
+Prize: X=5611, Y=3508
+
+Button A: X+60, Y+12
+Button B: X+14, Y+81
+Prize: X=12958, Y=14765
+
+Button A: X+25, Y+64
+Button B: X+38, Y+16
+Prize: X=1866, Y=2848
+
+Button A: X+46, Y+23
+Button B: X+25, Y+52
+Prize: X=5926, Y=12403
+
+Button A: X+95, Y+41
+Button B: X+17, Y+71
+Prize: X=7469, Y=5579
+
+Button A: X+89, Y+12
+Button B: X+65, Y+89
+Prize: X=3110, Y=3709
+
+Button A: X+46, Y+69
+Button B: X+43, Y+16
+Prize: X=2011, Y=1319
+
+Button A: X+84, Y+30
+Button B: X+40, Y+53
+Prize: X=8484, Y=4656
+
+Button A: X+11, Y+38
+Button B: X+27, Y+12
+Prize: X=7720, Y=16168
+
+Button A: X+54, Y+28
+Button B: X+32, Y+77
+Prize: X=4902, Y=7616
+
+Button A: X+28, Y+58
+Button B: X+55, Y+25
+Prize: X=15939, Y=5079
+
+Button A: X+17, Y+40
+Button B: X+37, Y+12
+Prize: X=19305, Y=14804
+
+Button A: X+11, Y+51
+Button B: X+32, Y+11
+Prize: X=16918, Y=9484
+
+Button A: X+12, Y+79
+Button B: X+71, Y+14
+Prize: X=1407, Y=5459
+
+Button A: X+58, Y+16
+Button B: X+28, Y+85
+Prize: X=3006, Y=8325
+
+Button A: X+32, Y+65
+Button B: X+93, Y+61
+Prize: X=9151, Y=8995
+
+Button A: X+65, Y+20
+Button B: X+15, Y+57
+Prize: X=5285, Y=1502
+
+Button A: X+11, Y+49
+Button B: X+71, Y+18
+Prize: X=5974, Y=7407
+
+Button A: X+42, Y+31
+Button B: X+11, Y+30
+Prize: X=15007, Y=353
+
+Button A: X+43, Y+12
+Button B: X+21, Y+33
+Prize: X=14784, Y=11570
+
+Button A: X+16, Y+43
+Button B: X+51, Y+11
+Prize: X=1247, Y=7498
+
+Button A: X+11, Y+41
+Button B: X+53, Y+34
+Prize: X=605, Y=8336
+
+Button A: X+68, Y+21
+Button B: X+35, Y+38
+Prize: X=7367, Y=3825
+
+Button A: X+40, Y+14
+Button B: X+37, Y+79
+Prize: X=4076, Y=3276
+
+Button A: X+36, Y+96
+Button B: X+67, Y+30
+Prize: X=8755, Y=10710
+
+Button A: X+42, Y+99
+Button B: X+66, Y+36
+Prize: X=6066, Y=6048
+
+Button A: X+30, Y+82
+Button B: X+63, Y+14
+Prize: X=428, Y=16660
+
+Button A: X+46, Y+80
+Button B: X+81, Y+25
+Prize: X=3686, Y=5020
+
+Button A: X+11, Y+19
+Button B: X+26, Y+11
+Prize: X=18842, Y=11157
+
+Button A: X+27, Y+54
+Button B: X+75, Y+41
+Prize: X=4368, Y=2741
+
+Button A: X+76, Y+43
+Button B: X+13, Y+32
+Prize: X=19094, Y=13020
+
+Button A: X+15, Y+35
+Button B: X+41, Y+12
+Prize: X=7257, Y=10139
+
+Button A: X+38, Y+61
+Button B: X+42, Y+11
+Prize: X=18860, Y=2346
+
+Button A: X+17, Y+36
+Button B: X+44, Y+15
+Prize: X=1985, Y=19601
+
+Button A: X+21, Y+31
+Button B: X+92, Y+16
+Prize: X=2127, Y=2421
+
+Button A: X+20, Y+55
+Button B: X+94, Y+25
+Prize: X=3960, Y=1550
+
+Button A: X+14, Y+52
+Button B: X+67, Y+23
+Prize: X=15899, Y=7175
+
+Button A: X+41, Y+68
+Button B: X+67, Y+13
+Prize: X=3721, Y=3424
+
+Button A: X+57, Y+19
+Button B: X+26, Y+64
+Prize: X=2836, Y=9752
+
+Button A: X+58, Y+17
+Button B: X+18, Y+72
+Prize: X=17924, Y=6536
+
+Button A: X+22, Y+79
+Button B: X+83, Y+19
+Prize: X=6208, Y=7782
+
+Button A: X+11, Y+55
+Button B: X+71, Y+23
+Prize: X=18429, Y=3449
+
+Button A: X+13, Y+76
+Button B: X+69, Y+82
+Prize: X=4805, Y=10736
+
+Button A: X+30, Y+44
+Button B: X+44, Y+21
+Prize: X=10066, Y=14602
+
+Button A: X+14, Y+36
+Button B: X+19, Y+13
+Prize: X=15186, Y=1550
+
+Button A: X+32, Y+56
+Button B: X+98, Y+20
+Prize: X=9530, Y=2588
+
+Button A: X+94, Y+43
+Button B: X+11, Y+98
+Prize: X=3537, Y=4500
+
+Button A: X+82, Y+17
+Button B: X+23, Y+60
+Prize: X=10372, Y=7563
+
+Button A: X+29, Y+95
+Button B: X+89, Y+55
+Prize: X=4491, Y=8325
+
+Button A: X+74, Y+50
+Button B: X+12, Y+31
+Prize: X=18242, Y=19036
+
+Button A: X+94, Y+96
+Button B: X+66, Y+18
+Prize: X=7298, Y=4242
+
+Button A: X+92, Y+61
+Button B: X+14, Y+71
+Prize: X=1382, Y=2953
+
+Button A: X+12, Y+35
+Button B: X+77, Y+35
+Prize: X=10507, Y=17735
+
+Button A: X+13, Y+48
+Button B: X+54, Y+17
+Prize: X=12088, Y=2129
+
+Button A: X+38, Y+19
+Button B: X+19, Y+64
+Prize: X=1900, Y=3784
+
+Button A: X+99, Y+12
+Button B: X+27, Y+24
+Prize: X=2871, Y=1032
+
+Button A: X+14, Y+30
+Button B: X+77, Y+52
+Prize: X=13213, Y=12702
+
+Button A: X+20, Y+46
+Button B: X+60, Y+36
+Prize: X=2540, Y=9734
+
+Button A: X+69, Y+27
+Button B: X+71, Y+89
+Prize: X=2467, Y=2557
+
+Button A: X+60, Y+15
+Button B: X+62, Y+83
+Prize: X=3362, Y=2933
+
+Button A: X+21, Y+62
+Button B: X+86, Y+33
+Prize: X=2246, Y=4422
+
+Button A: X+19, Y+72
+Button B: X+76, Y+15
+Prize: X=13363, Y=7820
+
+Button A: X+44, Y+73
+Button B: X+50, Y+20
+Prize: X=15466, Y=11257
+
+Button A: X+13, Y+72
+Button B: X+41, Y+13
+Prize: X=4132, Y=3618
+
+Button A: X+18, Y+48
+Button B: X+55, Y+27
+Prize: X=2806, Y=3414
+
+Button A: X+90, Y+22
+Button B: X+71, Y+86
+Prize: X=573, Y=346
+
+Button A: X+81, Y+71
+Button B: X+17, Y+59
+Prize: X=1598, Y=1974
+
+Button A: X+53, Y+30
+Button B: X+11, Y+48
+Prize: X=1661, Y=5034
+
+Button A: X+44, Y+21
+Button B: X+28, Y+64
+Prize: X=3288, Y=10147
+
+Button A: X+83, Y+23
+Button B: X+39, Y+43
+Prize: X=9245, Y=3753
+
+Button A: X+47, Y+13
+Button B: X+50, Y+67
+Prize: X=6439, Y=6779
+
+Button A: X+18, Y+83
+Button B: X+76, Y+58
+Prize: X=7258, Y=6855
+
+Button A: X+21, Y+80
+Button B: X+61, Y+27
+Prize: X=4236, Y=2582
+
+Button A: X+57, Y+26
+Button B: X+29, Y+65
+Prize: X=16648, Y=2720
+
+Button A: X+14, Y+40
+Button B: X+79, Y+47
+Prize: X=2127, Y=5683
+
+Button A: X+49, Y+12
+Button B: X+41, Y+76
+Prize: X=18691, Y=8548
+
+Button A: X+57, Y+22
+Button B: X+46, Y+83
+Prize: X=8941, Y=9584
+
+Button A: X+72, Y+23
+Button B: X+13, Y+38
+Prize: X=12327, Y=10708
+
+Button A: X+89, Y+21
+Button B: X+28, Y+75
+Prize: X=7466, Y=2172
+
+Button A: X+52, Y+23
+Button B: X+25, Y+42
+Prize: X=8514, Y=8187
+
+Button A: X+88, Y+61
+Button B: X+18, Y+98
+Prize: X=5110, Y=4825
+
+Button A: X+46, Y+14
+Button B: X+34, Y+72
+Prize: X=2146, Y=17272
+
+Button A: X+51, Y+24
+Button B: X+47, Y+73
+Prize: X=5035, Y=18165
+
+Button A: X+80, Y+31
+Button B: X+17, Y+27
+Prize: X=3266, Y=3266
+
+Button A: X+51, Y+15
+Button B: X+18, Y+75
+Prize: X=1217, Y=14870
+
+Button A: X+35, Y+17
+Button B: X+24, Y+57
+Prize: X=6471, Y=11508
diff --git a/day13/main.cpp b/day13/main.cpp
@@ -0,0 +1,107 @@
+#include <iostream>
+#include <filesystem>
+#include <fstream>
+#include <vector>
+#include <cstring>
+#include <cstdio>
+#include <tuple>
+#include <algorithm>
+#include <thread>
+#include "utils.hpp"
+
+struct Vec2 {
+ int x;
+ int y;
+ void fromStr(const std::string &s) {
+ [[ maybe_unused ]] char btn;
+ std::sscanf(s.c_str(), "Button %c: X+%d, Y+%d", &btn, &x, &y);
+ }
+};
+
+struct Machine {
+ Vec2 btnA;
+ Vec2 btnB;
+ Vec2 prize;
+ void setPrize(const std::string &s) {
+ std::sscanf(s.c_str(), "Prize: X=%d, Y=%d", &prize.x, &prize.y);
+ }
+ void print() const {
+ std::printf("A(%d,%d), B(%d,%d), prize at (%d,%d)\n", btnA.x, btnA.y, btnB.x, btnB.y, prize.x, prize.y);
+ }
+};
+
+struct State {
+ const Machine &m;
+ int pressesA;
+ int pressesB;
+};
+
+typedef std::vector<Machine> Data;
+
+template<typename T>
+T read_file(const std::string &path) {
+ std::ifstream ifs(path, std::ios::binary);
+ if (!ifs.is_open()) {
+ throw std::runtime_error(path+":"+std::strerror(errno));
+ }
+ T buf;
+ int lines = 0;
+ while (1) {
+ std::string str;
+ std::getline(ifs, str);
+ if (!str.empty()) {
+ int c = lines % 4;
+ if (c==0) {
+ Machine m;
+ m.btnA.fromStr(str);
+ buf.push_back(m);
+ }
+ if (c==1) buf.back().btnB.fromStr(str);
+ if (c==2) buf.back().setPrize(str);
+ }
+ if (!ifs) break;
+ lines++;
+ }
+ return buf;
+}
+
+void simulate(const Machine &m, int pA, int pB, std::vector<int> &out) {
+ if (pA>100||pB>100) return;
+ int curX = m.btnA.x*pA + m.btnB.x*pB;
+ int curY = m.btnA.y*pA + m.btnB.y*pB;
+ //std::printf("pA=%d, pB=%d, curX=%d, curY=%d\n", pA, pB, curX, curY);
+ if (curX>m.prize.x||curY>m.prize.y) return;
+ if (m.btnA.x*pA==m.prize.x&&m.btnB.y*pB==m.prize.y) {
+ out.push_back(pA*3+pB);
+ } else {
+ simulate(m, ++pA, pB, out);
+ simulate(m, pA, ++pB, out);
+ }
+}
+
+int64_t part1(Data &input [[ maybe_unused ]]) {
+ int64_t res = 0;
+ for (auto &m:input) {
+ m.print();
+ std::vector<int> runs;
+ simulate(m, 0, 0, runs);
+ std::sort(runs.begin(), runs.end());
+ std::printf("%ld successful results\n", runs.size());
+ }
+
+ return res;
+}
+int64_t part2(Data &input [[ maybe_unused ]]) {
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ Performance perf;
+ const std::string fname = argc>1 ? argv[1] : "test1.txt";
+ std::cout << "AoC 2024 day 13 " << fname << std::endl;
+ Data input = read_file<Data>(fname);
+ std::cout << "part1: " << part1(input) << std::endl;
+ std::cout << "part2: " << part2(input) << std::endl;
+
+ return 0;
+}
diff --git a/day13/test1.txt b/day13/test1.txt
@@ -0,0 +1,15 @@
+Button A: X+94, Y+34
+Button B: X+22, Y+67
+Prize: X=8400, Y=5400
+
+Button A: X+26, Y+66
+Button B: X+67, Y+21
+Prize: X=12748, Y=12176
+
+Button A: X+17, Y+86
+Button B: X+84, Y+37
+Prize: X=7870, Y=6450
+
+Button A: X+69, Y+23
+Button B: X+27, Y+71
+Prize: X=18641, Y=10279