diff --git a/day13/input b/day13/input new file mode 100644 index 0000000..3f79a4c --- /dev/null +++ b/day13/input @@ -0,0 +1,1280 @@ +Button A: X+97, Y+12 +Button B: X+52, Y+63 +Prize: X=10471, Y=4350 + +Button A: X+79, Y+41 +Button B: X+29, Y+68 +Prize: X=7216, Y=8987 + +Button A: X+13, Y+68 +Button B: X+46, Y+16 +Prize: X=1226, Y=8336 + +Button A: X+14, Y+42 +Button B: X+63, Y+23 +Prize: X=15649, Y=1769 + +Button A: X+59, Y+19 +Button B: X+53, Y+95 +Prize: X=8976, Y=10450 + +Button A: X+91, Y+84 +Button B: X+19, Y+92 +Prize: X=9023, Y=13020 + +Button A: X+14, Y+33 +Button B: X+26, Y+12 +Prize: X=4032, Y=8054 + +Button A: X+69, Y+83 +Button B: X+70, Y+18 +Prize: X=8868, Y=8284 + +Button A: X+14, Y+47 +Button B: X+83, Y+51 +Prize: X=7081, Y=7154 + +Button A: X+33, Y+67 +Button B: X+50, Y+17 +Prize: X=12916, Y=4279 + +Button A: X+22, Y+75 +Button B: X+77, Y+23 +Prize: X=12981, Y=9742 + +Button A: X+90, Y+30 +Button B: X+17, Y+33 +Prize: X=6270, Y=2910 + +Button A: X+62, Y+11 +Button B: X+43, Y+65 +Prize: X=3850, Y=1601 + +Button A: X+48, Y+21 +Button B: X+21, Y+33 +Prize: X=8108, Y=1334 + +Button A: X+12, Y+40 +Button B: X+49, Y+23 +Prize: X=12471, Y=11957 + +Button A: X+86, Y+11 +Button B: X+56, Y+69 +Prize: X=4404, Y=1058 + +Button A: X+80, Y+26 +Button B: X+11, Y+57 +Prize: X=6899, Y=5923 + +Button A: X+25, Y+51 +Button B: X+59, Y+24 +Prize: X=14076, Y=10916 + +Button A: X+48, Y+46 +Button B: X+13, Y+94 +Prize: X=1915, Y=6320 + +Button A: X+47, Y+32 +Button B: X+20, Y+44 +Prize: X=19516, Y=14572 + +Button A: X+84, Y+21 +Button B: X+13, Y+89 +Prize: X=4350, Y=2631 + +Button A: X+29, Y+85 +Button B: X+33, Y+26 +Prize: X=4361, Y=7973 + +Button A: X+78, Y+35 +Button B: X+11, Y+42 +Prize: X=9808, Y=10623 + +Button A: X+35, Y+64 +Button B: X+38, Y+15 +Prize: X=4993, Y=274 + +Button A: X+18, Y+47 +Button B: X+54, Y+15 +Prize: X=10646, Y=16999 + +Button A: X+99, Y+55 +Button B: X+18, Y+75 +Prize: X=5256, Y=5455 + +Button A: X+83, Y+91 +Button B: X+11, Y+58 +Prize: X=3635, Y=4261 + +Button A: X+60, Y+27 +Button B: X+29, Y+56 +Prize: X=740, Y=11114 + +Button A: X+59, Y+15 +Button B: X+29, Y+75 +Prize: X=14539, Y=13025 + +Button A: X+67, Y+23 +Button B: X+11, Y+57 +Prize: X=2430, Y=2218 + +Button A: X+80, Y+45 +Button B: X+37, Y+82 +Prize: X=9822, Y=10787 + +Button A: X+11, Y+45 +Button B: X+51, Y+23 +Prize: X=1269, Y=18697 + +Button A: X+56, Y+32 +Button B: X+16, Y+50 +Prize: X=9080, Y=15276 + +Button A: X+93, Y+93 +Button B: X+11, Y+90 +Prize: X=4103, Y=11529 + +Button A: X+24, Y+21 +Button B: X+12, Y+51 +Prize: X=2016, Y=3627 + +Button A: X+72, Y+41 +Button B: X+25, Y+80 +Prize: X=3812, Y=3486 + +Button A: X+29, Y+14 +Button B: X+22, Y+53 +Prize: X=2677, Y=14205 + +Button A: X+56, Y+18 +Button B: X+19, Y+69 +Prize: X=4292, Y=8432 + +Button A: X+64, Y+16 +Button B: X+14, Y+50 +Prize: X=3752, Y=536 + +Button A: X+45, Y+31 +Button B: X+26, Y+59 +Prize: X=4694, Y=5247 + +Button A: X+61, Y+21 +Button B: X+19, Y+48 +Prize: X=3931, Y=257 + +Button A: X+13, Y+36 +Button B: X+68, Y+26 +Prize: X=17218, Y=17896 + +Button A: X+15, Y+81 +Button B: X+31, Y+21 +Prize: X=2580, Y=7344 + +Button A: X+78, Y+51 +Button B: X+12, Y+34 +Prize: X=3380, Y=16870 + +Button A: X+86, Y+29 +Button B: X+52, Y+60 +Prize: X=5118, Y=2745 + +Button A: X+12, Y+49 +Button B: X+77, Y+16 +Prize: X=7847, Y=7211 + +Button A: X+30, Y+49 +Button B: X+48, Y+19 +Prize: X=1034, Y=15377 + +Button A: X+25, Y+61 +Button B: X+26, Y+12 +Prize: X=6825, Y=14177 + +Button A: X+59, Y+20 +Button B: X+11, Y+23 +Prize: X=13324, Y=946 + +Button A: X+36, Y+54 +Button B: X+29, Y+13 +Prize: X=4435, Y=12219 + +Button A: X+17, Y+77 +Button B: X+61, Y+17 +Prize: X=2681, Y=5661 + +Button A: X+41, Y+19 +Button B: X+25, Y+55 +Prize: X=4484, Y=9416 + +Button A: X+26, Y+68 +Button B: X+70, Y+26 +Prize: X=8284, Y=10434 + +Button A: X+54, Y+11 +Button B: X+25, Y+78 +Prize: X=11040, Y=7758 + +Button A: X+85, Y+23 +Button B: X+54, Y+74 +Prize: X=2400, Y=2728 + +Button A: X+93, Y+29 +Button B: X+13, Y+22 +Prize: X=7293, Y=2328 + +Button A: X+23, Y+87 +Button B: X+48, Y+20 +Prize: X=2279, Y=4743 + +Button A: X+83, Y+34 +Button B: X+32, Y+43 +Prize: X=7734, Y=4035 + +Button A: X+25, Y+61 +Button B: X+83, Y+44 +Prize: X=6884, Y=5225 + +Button A: X+27, Y+58 +Button B: X+98, Y+47 +Prize: X=7921, Y=3934 + +Button A: X+31, Y+57 +Button B: X+33, Y+14 +Prize: X=3052, Y=3838 + +Button A: X+96, Y+18 +Button B: X+77, Y+97 +Prize: X=6503, Y=6751 + +Button A: X+11, Y+29 +Button B: X+71, Y+36 +Prize: X=1000, Y=671 + +Button A: X+25, Y+53 +Button B: X+44, Y+20 +Prize: X=13129, Y=17325 + +Button A: X+33, Y+13 +Button B: X+50, Y+66 +Prize: X=3194, Y=9314 + +Button A: X+54, Y+15 +Button B: X+24, Y+64 +Prize: X=19418, Y=8601 + +Button A: X+13, Y+46 +Button B: X+56, Y+14 +Prize: X=10671, Y=11208 + +Button A: X+35, Y+91 +Button B: X+25, Y+14 +Prize: X=2700, Y=6153 + +Button A: X+85, Y+25 +Button B: X+16, Y+97 +Prize: X=2407, Y=1354 + +Button A: X+24, Y+12 +Button B: X+13, Y+30 +Prize: X=3299, Y=3318 + +Button A: X+17, Y+46 +Button B: X+50, Y+24 +Prize: X=17242, Y=6760 + +Button A: X+20, Y+43 +Button B: X+26, Y+14 +Prize: X=2474, Y=748 + +Button A: X+19, Y+78 +Button B: X+90, Y+12 +Prize: X=9966, Y=7668 + +Button A: X+96, Y+77 +Button B: X+26, Y+73 +Prize: X=3708, Y=5790 + +Button A: X+37, Y+77 +Button B: X+51, Y+15 +Prize: X=13364, Y=12440 + +Button A: X+30, Y+78 +Button B: X+76, Y+31 +Prize: X=6378, Y=3588 + +Button A: X+60, Y+26 +Button B: X+13, Y+25 +Prize: X=10780, Y=7426 + +Button A: X+33, Y+40 +Button B: X+59, Y+16 +Prize: X=4212, Y=3440 + +Button A: X+30, Y+11 +Button B: X+25, Y+40 +Prize: X=1145, Y=1499 + +Button A: X+14, Y+30 +Button B: X+48, Y+15 +Prize: X=4416, Y=3840 + +Button A: X+45, Y+68 +Button B: X+59, Y+25 +Prize: X=6633, Y=5404 + +Button A: X+34, Y+62 +Button B: X+44, Y+19 +Prize: X=9234, Y=16930 + +Button A: X+65, Y+12 +Button B: X+16, Y+42 +Prize: X=13586, Y=10016 + +Button A: X+16, Y+86 +Button B: X+63, Y+54 +Prize: X=2515, Y=5264 + +Button A: X+40, Y+88 +Button B: X+91, Y+56 +Prize: X=3728, Y=7048 + +Button A: X+43, Y+79 +Button B: X+91, Y+30 +Prize: X=5407, Y=1977 + +Button A: X+87, Y+16 +Button B: X+86, Y+76 +Prize: X=3366, Y=2244 + +Button A: X+39, Y+74 +Button B: X+94, Y+32 +Prize: X=6130, Y=6216 + +Button A: X+91, Y+50 +Button B: X+24, Y+71 +Prize: X=9174, Y=7411 + +Button A: X+81, Y+55 +Button B: X+14, Y+95 +Prize: X=4359, Y=7320 + +Button A: X+26, Y+78 +Button B: X+79, Y+58 +Prize: X=8792, Y=11698 + +Button A: X+81, Y+58 +Button B: X+21, Y+70 +Prize: X=8145, Y=9130 + +Button A: X+29, Y+60 +Button B: X+83, Y+29 +Prize: X=9583, Y=6839 + +Button A: X+72, Y+27 +Button B: X+23, Y+63 +Prize: X=16485, Y=8540 + +Button A: X+18, Y+30 +Button B: X+47, Y+13 +Prize: X=3031, Y=8157 + +Button A: X+36, Y+14 +Button B: X+52, Y+70 +Prize: X=19584, Y=5184 + +Button A: X+13, Y+36 +Button B: X+32, Y+23 +Prize: X=12901, Y=6580 + +Button A: X+34, Y+66 +Button B: X+57, Y+24 +Prize: X=13320, Y=4832 + +Button A: X+79, Y+26 +Button B: X+65, Y+85 +Prize: X=7528, Y=2732 + +Button A: X+20, Y+58 +Button B: X+96, Y+75 +Prize: X=3288, Y=5874 + +Button A: X+89, Y+24 +Button B: X+35, Y+67 +Prize: X=3458, Y=5595 + +Button A: X+63, Y+81 +Button B: X+67, Y+22 +Prize: X=4988, Y=3206 + +Button A: X+17, Y+55 +Button B: X+54, Y+13 +Prize: X=17532, Y=19258 + +Button A: X+30, Y+94 +Button B: X+93, Y+32 +Prize: X=2874, Y=4336 + +Button A: X+31, Y+17 +Button B: X+24, Y+40 +Prize: X=2311, Y=8105 + +Button A: X+58, Y+27 +Button B: X+19, Y+60 +Prize: X=6022, Y=6398 + +Button A: X+13, Y+67 +Button B: X+84, Y+29 +Prize: X=2843, Y=2323 + +Button A: X+56, Y+12 +Button B: X+23, Y+81 +Prize: X=2380, Y=11120 + +Button A: X+15, Y+65 +Button B: X+56, Y+24 +Prize: X=5230, Y=5170 + +Button A: X+19, Y+47 +Button B: X+72, Y+34 +Prize: X=17967, Y=11841 + +Button A: X+16, Y+41 +Button B: X+78, Y+60 +Prize: X=5144, Y=4789 + +Button A: X+52, Y+15 +Button B: X+16, Y+65 +Prize: X=19732, Y=7355 + +Button A: X+21, Y+81 +Button B: X+71, Y+16 +Prize: X=17221, Y=9366 + +Button A: X+61, Y+33 +Button B: X+49, Y+87 +Prize: X=8507, Y=9381 + +Button A: X+67, Y+21 +Button B: X+15, Y+52 +Prize: X=16737, Y=7411 + +Button A: X+33, Y+49 +Button B: X+34, Y+11 +Prize: X=6660, Y=4300 + +Button A: X+19, Y+81 +Button B: X+96, Y+33 +Prize: X=10734, Y=10392 + +Button A: X+60, Y+13 +Button B: X+63, Y+65 +Prize: X=7395, Y=3913 + +Button A: X+15, Y+21 +Button B: X+96, Y+35 +Prize: X=6417, Y=3815 + +Button A: X+20, Y+39 +Button B: X+57, Y+27 +Prize: X=611, Y=4760 + +Button A: X+68, Y+97 +Button B: X+87, Y+37 +Prize: X=11894, Y=9824 + +Button A: X+13, Y+81 +Button B: X+59, Y+12 +Prize: X=18946, Y=3392 + +Button A: X+30, Y+83 +Button B: X+57, Y+11 +Prize: X=3482, Y=19301 + +Button A: X+94, Y+11 +Button B: X+35, Y+92 +Prize: X=11544, Y=7680 + +Button A: X+45, Y+19 +Button B: X+30, Y+45 +Prize: X=11315, Y=17659 + +Button A: X+25, Y+42 +Button B: X+79, Y+21 +Prize: X=7695, Y=3990 + +Button A: X+95, Y+91 +Button B: X+55, Y+13 +Prize: X=10575, Y=9217 + +Button A: X+27, Y+46 +Button B: X+81, Y+26 +Prize: X=5508, Y=2776 + +Button A: X+20, Y+53 +Button B: X+29, Y+17 +Prize: X=10985, Y=16700 + +Button A: X+55, Y+74 +Button B: X+58, Y+20 +Prize: X=8888, Y=8128 + +Button A: X+40, Y+27 +Button B: X+19, Y+43 +Prize: X=5535, Y=1095 + +Button A: X+19, Y+72 +Button B: X+54, Y+22 +Prize: X=3261, Y=2678 + +Button A: X+79, Y+39 +Button B: X+38, Y+75 +Prize: X=7120, Y=6102 + +Button A: X+26, Y+91 +Button B: X+99, Y+25 +Prize: X=1223, Y=2673 + +Button A: X+15, Y+28 +Button B: X+58, Y+23 +Prize: X=1519, Y=5600 + +Button A: X+18, Y+53 +Button B: X+71, Y+27 +Prize: X=11055, Y=3487 + +Button A: X+14, Y+50 +Button B: X+52, Y+18 +Prize: X=3908, Y=8576 + +Button A: X+38, Y+17 +Button B: X+23, Y+50 +Prize: X=7788, Y=8394 + +Button A: X+72, Y+20 +Button B: X+19, Y+68 +Prize: X=10586, Y=4272 + +Button A: X+28, Y+66 +Button B: X+62, Y+12 +Prize: X=19418, Y=7934 + +Button A: X+11, Y+20 +Button B: X+49, Y+24 +Prize: X=2957, Y=2252 + +Button A: X+60, Y+11 +Button B: X+27, Y+84 +Prize: X=3146, Y=1936 + +Button A: X+18, Y+11 +Button B: X+11, Y+41 +Prize: X=9360, Y=18112 + +Button A: X+70, Y+31 +Button B: X+15, Y+62 +Prize: X=13135, Y=7958 + +Button A: X+74, Y+35 +Button B: X+11, Y+41 +Prize: X=19668, Y=14478 + +Button A: X+53, Y+89 +Button B: X+54, Y+23 +Prize: X=9521, Y=10100 + +Button A: X+13, Y+61 +Button B: X+68, Y+28 +Prize: X=11028, Y=12380 + +Button A: X+42, Y+29 +Button B: X+20, Y+74 +Prize: X=1906, Y=1617 + +Button A: X+44, Y+13 +Button B: X+23, Y+60 +Prize: X=13690, Y=9554 + +Button A: X+54, Y+16 +Button B: X+11, Y+23 +Prize: X=3792, Y=4614 + +Button A: X+28, Y+11 +Button B: X+34, Y+63 +Prize: X=13092, Y=15599 + +Button A: X+61, Y+14 +Button B: X+33, Y+73 +Prize: X=18520, Y=772 + +Button A: X+64, Y+29 +Button B: X+14, Y+78 +Prize: X=3988, Y=4530 + +Button A: X+18, Y+45 +Button B: X+54, Y+26 +Prize: X=18170, Y=10118 + +Button A: X+70, Y+26 +Button B: X+11, Y+43 +Prize: X=6905, Y=329 + +Button A: X+72, Y+17 +Button B: X+27, Y+58 +Prize: X=7461, Y=6253 + +Button A: X+57, Y+45 +Button B: X+18, Y+85 +Prize: X=2340, Y=5670 + +Button A: X+17, Y+81 +Button B: X+47, Y+35 +Prize: X=5532, Y=8220 + +Button A: X+14, Y+60 +Button B: X+78, Y+22 +Prize: X=10172, Y=5672 + +Button A: X+62, Y+13 +Button B: X+17, Y+65 +Prize: X=7711, Y=8089 + +Button A: X+22, Y+38 +Button B: X+40, Y+21 +Prize: X=15254, Y=15785 + +Button A: X+83, Y+39 +Button B: X+32, Y+71 +Prize: X=2416, Y=3038 + +Button A: X+29, Y+62 +Button B: X+68, Y+18 +Prize: X=6454, Y=3990 + +Button A: X+15, Y+38 +Button B: X+72, Y+33 +Prize: X=3575, Y=8334 + +Button A: X+81, Y+15 +Button B: X+13, Y+83 +Prize: X=11268, Y=10108 + +Button A: X+67, Y+17 +Button B: X+12, Y+76 +Prize: X=11957, Y=5399 + +Button A: X+13, Y+97 +Button B: X+44, Y+54 +Prize: X=2788, Y=7636 + +Button A: X+14, Y+47 +Button B: X+68, Y+30 +Prize: X=2678, Y=9911 + +Button A: X+75, Y+16 +Button B: X+22, Y+26 +Prize: X=1049, Y=586 + +Button A: X+16, Y+77 +Button B: X+38, Y+25 +Prize: X=2368, Y=7607 + +Button A: X+75, Y+91 +Button B: X+77, Y+20 +Prize: X=4076, Y=3991 + +Button A: X+64, Y+19 +Button B: X+35, Y+74 +Prize: X=8653, Y=7594 + +Button A: X+33, Y+81 +Button B: X+57, Y+15 +Prize: X=10661, Y=2849 + +Button A: X+11, Y+52 +Button B: X+70, Y+22 +Prize: X=1390, Y=2864 + +Button A: X+21, Y+40 +Button B: X+21, Y+13 +Prize: X=5954, Y=5203 + +Button A: X+52, Y+21 +Button B: X+13, Y+64 +Prize: X=11131, Y=9958 + +Button A: X+11, Y+42 +Button B: X+95, Y+52 +Prize: X=1604, Y=4260 + +Button A: X+63, Y+13 +Button B: X+22, Y+82 +Prize: X=670, Y=17610 + +Button A: X+16, Y+88 +Button B: X+84, Y+74 +Prize: X=3184, Y=6648 + +Button A: X+77, Y+14 +Button B: X+92, Y+88 +Prize: X=13208, Y=8816 + +Button A: X+63, Y+67 +Button B: X+82, Y+13 +Prize: X=8310, Y=3940 + +Button A: X+57, Y+16 +Button B: X+17, Y+48 +Prize: X=10242, Y=5248 + +Button A: X+17, Y+72 +Button B: X+36, Y+37 +Prize: X=3710, Y=5667 + +Button A: X+69, Y+22 +Button B: X+29, Y+54 +Prize: X=5207, Y=5330 + +Button A: X+23, Y+82 +Button B: X+49, Y+11 +Prize: X=2320, Y=2070 + +Button A: X+66, Y+27 +Button B: X+16, Y+45 +Prize: X=11344, Y=9314 + +Button A: X+56, Y+12 +Button B: X+23, Y+66 +Prize: X=13879, Y=14258 + +Button A: X+60, Y+22 +Button B: X+18, Y+91 +Prize: X=1668, Y=4494 + +Button A: X+33, Y+11 +Button B: X+31, Y+68 +Prize: X=6069, Y=13315 + +Button A: X+14, Y+37 +Button B: X+59, Y+14 +Prize: X=2210, Y=5344 + +Button A: X+80, Y+18 +Button B: X+33, Y+94 +Prize: X=4128, Y=9240 + +Button A: X+40, Y+17 +Button B: X+28, Y+45 +Prize: X=3436, Y=3526 + +Button A: X+16, Y+53 +Button B: X+50, Y+22 +Prize: X=642, Y=18961 + +Button A: X+17, Y+39 +Button B: X+65, Y+23 +Prize: X=9566, Y=11794 + +Button A: X+66, Y+35 +Button B: X+30, Y+76 +Prize: X=8010, Y=8394 + +Button A: X+52, Y+75 +Button B: X+37, Y+15 +Prize: X=335, Y=19220 + +Button A: X+36, Y+29 +Button B: X+30, Y+89 +Prize: X=3690, Y=4334 + +Button A: X+31, Y+58 +Button B: X+50, Y+20 +Prize: X=8178, Y=17844 + +Button A: X+82, Y+22 +Button B: X+89, Y+90 +Prize: X=4306, Y=1552 + +Button A: X+12, Y+42 +Button B: X+99, Y+75 +Prize: X=1173, Y=3291 + +Button A: X+23, Y+57 +Button B: X+40, Y+19 +Prize: X=2246, Y=9772 + +Button A: X+18, Y+42 +Button B: X+95, Y+15 +Prize: X=9610, Y=4650 + +Button A: X+20, Y+57 +Button B: X+59, Y+21 +Prize: X=10072, Y=16868 + +Button A: X+23, Y+34 +Button B: X+42, Y+15 +Prize: X=6683, Y=16946 + +Button A: X+55, Y+73 +Button B: X+30, Y+11 +Prize: X=4150, Y=3001 + +Button A: X+22, Y+82 +Button B: X+73, Y+12 +Prize: X=16713, Y=15870 + +Button A: X+14, Y+53 +Button B: X+65, Y+35 +Prize: X=3017, Y=4034 + +Button A: X+25, Y+53 +Button B: X+46, Y+19 +Prize: X=13804, Y=8575 + +Button A: X+29, Y+13 +Button B: X+38, Y+60 +Prize: X=14048, Y=11678 + +Button A: X+57, Y+21 +Button B: X+61, Y+83 +Prize: X=6297, Y=7041 + +Button A: X+18, Y+99 +Button B: X+77, Y+75 +Prize: X=2549, Y=3216 + +Button A: X+59, Y+22 +Button B: X+17, Y+33 +Prize: X=11044, Y=13465 + +Button A: X+40, Y+17 +Button B: X+47, Y+77 +Prize: X=17101, Y=14482 + +Button A: X+34, Y+14 +Button B: X+20, Y+38 +Prize: X=594, Y=572 + +Button A: X+26, Y+62 +Button B: X+35, Y+11 +Prize: X=6771, Y=8811 + +Button A: X+20, Y+33 +Button B: X+93, Y+21 +Prize: X=5259, Y=2982 + +Button A: X+89, Y+60 +Button B: X+13, Y+91 +Prize: X=9182, Y=14167 + +Button A: X+28, Y+98 +Button B: X+98, Y+63 +Prize: X=5712, Y=8792 + +Button A: X+67, Y+94 +Button B: X+39, Y+15 +Prize: X=7520, Y=7532 + +Button A: X+38, Y+17 +Button B: X+25, Y+38 +Prize: X=19009, Y=14132 + +Button A: X+18, Y+51 +Button B: X+85, Y+39 +Prize: X=9247, Y=7833 + +Button A: X+40, Y+92 +Button B: X+55, Y+23 +Prize: X=2390, Y=1978 + +Button A: X+63, Y+39 +Button B: X+24, Y+51 +Prize: X=7448, Y=17612 + +Button A: X+95, Y+25 +Button B: X+33, Y+64 +Prize: X=11557, Y=8241 + +Button A: X+40, Y+23 +Button B: X+21, Y+73 +Prize: X=3186, Y=5853 + +Button A: X+89, Y+81 +Button B: X+13, Y+91 +Prize: X=5270, Y=6538 + +Button A: X+69, Y+17 +Button B: X+21, Y+64 +Prize: X=10955, Y=8181 + +Button A: X+59, Y+15 +Button B: X+21, Y+77 +Prize: X=6203, Y=4791 + +Button A: X+25, Y+45 +Button B: X+36, Y+21 +Prize: X=12604, Y=18854 + +Button A: X+67, Y+17 +Button B: X+21, Y+70 +Prize: X=7506, Y=17163 + +Button A: X+78, Y+53 +Button B: X+27, Y+89 +Prize: X=2391, Y=7065 + +Button A: X+68, Y+26 +Button B: X+23, Y+62 +Prize: X=13179, Y=7794 + +Button A: X+18, Y+44 +Button B: X+54, Y+16 +Prize: X=18710, Y=4780 + +Button A: X+16, Y+36 +Button B: X+69, Y+48 +Prize: X=6028, Y=5412 + +Button A: X+45, Y+24 +Button B: X+34, Y+73 +Prize: X=4185, Y=4701 + +Button A: X+12, Y+26 +Button B: X+64, Y+29 +Prize: X=8628, Y=3714 + +Button A: X+53, Y+16 +Button B: X+26, Y+65 +Prize: X=15387, Y=3502 + +Button A: X+48, Y+17 +Button B: X+49, Y+80 +Prize: X=19364, Y=6034 + +Button A: X+34, Y+70 +Button B: X+45, Y+21 +Prize: X=3861, Y=2289 + +Button A: X+39, Y+76 +Button B: X+80, Y+14 +Prize: X=8169, Y=3574 + +Button A: X+79, Y+35 +Button B: X+45, Y+74 +Prize: X=7247, Y=6887 + +Button A: X+33, Y+19 +Button B: X+12, Y+49 +Prize: X=7163, Y=16959 + +Button A: X+24, Y+11 +Button B: X+30, Y+49 +Prize: X=11852, Y=4499 + +Button A: X+32, Y+11 +Button B: X+25, Y+70 +Prize: X=5331, Y=15303 + +Button A: X+98, Y+63 +Button B: X+18, Y+68 +Prize: X=5564, Y=5044 + +Button A: X+85, Y+11 +Button B: X+41, Y+76 +Prize: X=10558, Y=6527 + +Button A: X+20, Y+48 +Button B: X+45, Y+11 +Prize: X=10755, Y=17297 + +Button A: X+37, Y+23 +Button B: X+23, Y+51 +Prize: X=12782, Y=14840 + +Button A: X+37, Y+69 +Button B: X+44, Y+11 +Prize: X=4057, Y=15396 + +Button A: X+21, Y+43 +Button B: X+55, Y+30 +Prize: X=6148, Y=18269 + +Button A: X+32, Y+63 +Button B: X+32, Y+17 +Prize: X=8032, Y=16179 + +Button A: X+81, Y+68 +Button B: X+18, Y+51 +Prize: X=3429, Y=6001 + +Button A: X+90, Y+27 +Button B: X+36, Y+96 +Prize: X=8910, Y=3099 + +Button A: X+68, Y+36 +Button B: X+18, Y+44 +Prize: X=494, Y=6740 + +Button A: X+65, Y+11 +Button B: X+13, Y+71 +Prize: X=809, Y=7803 + +Button A: X+29, Y+40 +Button B: X+97, Y+24 +Prize: X=10076, Y=3248 + +Button A: X+83, Y+33 +Button B: X+17, Y+81 +Prize: X=5639, Y=4395 + +Button A: X+22, Y+33 +Button B: X+47, Y+22 +Prize: X=7651, Y=1299 + +Button A: X+58, Y+25 +Button B: X+16, Y+31 +Prize: X=10590, Y=3747 + +Button A: X+36, Y+14 +Button B: X+36, Y+71 +Prize: X=7856, Y=1885 + +Button A: X+64, Y+18 +Button B: X+74, Y+89 +Prize: X=9164, Y=5714 + +Button A: X+82, Y+51 +Button B: X+22, Y+99 +Prize: X=7542, Y=10407 + +Button A: X+43, Y+18 +Button B: X+34, Y+65 +Prize: X=17803, Y=6032 + +Button A: X+62, Y+39 +Button B: X+19, Y+44 +Prize: X=15584, Y=11902 + +Button A: X+32, Y+24 +Button B: X+33, Y+83 +Prize: X=2199, Y=4853 + +Button A: X+14, Y+60 +Button B: X+80, Y+18 +Prize: X=1010, Y=6134 + +Button A: X+71, Y+24 +Button B: X+18, Y+62 +Prize: X=3079, Y=5296 + +Button A: X+17, Y+54 +Button B: X+53, Y+12 +Prize: X=11314, Y=7550 + +Button A: X+42, Y+20 +Button B: X+13, Y+41 +Prize: X=7760, Y=9208 + +Button A: X+26, Y+48 +Button B: X+46, Y+25 +Prize: X=16412, Y=3732 + +Button A: X+20, Y+64 +Button B: X+65, Y+21 +Prize: X=6165, Y=11225 + +Button A: X+14, Y+58 +Button B: X+68, Y+27 +Prize: X=7972, Y=15348 + +Button A: X+46, Y+17 +Button B: X+29, Y+96 +Prize: X=3598, Y=8664 + +Button A: X+93, Y+32 +Button B: X+28, Y+76 +Prize: X=11382, Y=9292 + +Button A: X+65, Y+24 +Button B: X+11, Y+35 +Prize: X=2252, Y=10494 + +Button A: X+28, Y+61 +Button B: X+46, Y+16 +Prize: X=14138, Y=7874 + +Button A: X+49, Y+28 +Button B: X+29, Y+66 +Prize: X=2640, Y=4672 + +Button A: X+14, Y+99 +Button B: X+98, Y+68 +Prize: X=2730, Y=5555 + +Button A: X+54, Y+54 +Button B: X+89, Y+22 +Prize: X=5618, Y=3340 + +Button A: X+18, Y+46 +Button B: X+76, Y+48 +Prize: X=5930, Y=2346 + +Button A: X+78, Y+75 +Button B: X+87, Y+21 +Prize: X=3906, Y=2628 + +Button A: X+14, Y+22 +Button B: X+41, Y+19 +Prize: X=3378, Y=12850 + +Button A: X+69, Y+18 +Button B: X+18, Y+73 +Prize: X=6411, Y=2697 + +Button A: X+33, Y+78 +Button B: X+70, Y+37 +Prize: X=3122, Y=6737 + +Button A: X+14, Y+74 +Button B: X+86, Y+20 +Prize: X=6300, Y=2880 + +Button A: X+11, Y+28 +Button B: X+48, Y+11 +Prize: X=6804, Y=16815 + +Button A: X+62, Y+17 +Button B: X+31, Y+65 +Prize: X=6448, Y=4141 + +Button A: X+70, Y+11 +Button B: X+72, Y+59 +Prize: X=4918, Y=1202 + +Button A: X+97, Y+67 +Button B: X+13, Y+33 +Prize: X=8935, Y=7805 + +Button A: X+34, Y+78 +Button B: X+76, Y+49 +Prize: X=8860, Y=10423 + +Button A: X+27, Y+69 +Button B: X+37, Y+21 +Prize: X=1124, Y=960 + +Button A: X+25, Y+11 +Button B: X+15, Y+53 +Prize: X=11185, Y=17987 + +Button A: X+12, Y+57 +Button B: X+67, Y+20 +Prize: X=10831, Y=11898 + +Button A: X+21, Y+52 +Button B: X+68, Y+37 +Prize: X=488, Y=19181 + +Button A: X+27, Y+12 +Button B: X+30, Y+67 +Prize: X=4040, Y=8930 + +Button A: X+84, Y+30 +Button B: X+58, Y+99 +Prize: X=4462, Y=6369 + +Button A: X+32, Y+59 +Button B: X+37, Y+20 +Prize: X=12149, Y=3281 + +Button A: X+44, Y+12 +Button B: X+86, Y+94 +Prize: X=7916, Y=8508 + +Button A: X+11, Y+42 +Button B: X+64, Y+29 +Prize: X=1438, Y=7055 + +Button A: X+13, Y+58 +Button B: X+71, Y+30 +Prize: X=1136, Y=7488 + +Button A: X+29, Y+32 +Button B: X+15, Y+73 +Prize: X=466, Y=740 + +Button A: X+18, Y+40 +Button B: X+60, Y+14 +Prize: X=3758, Y=16800 + +Button A: X+29, Y+48 +Button B: X+46, Y+11 +Prize: X=823, Y=4172 + +Button A: X+12, Y+36 +Button B: X+84, Y+21 +Prize: X=2916, Y=1818 + +Button A: X+57, Y+98 +Button B: X+99, Y+38 +Prize: X=11955, Y=7862 + +Button A: X+11, Y+59 +Button B: X+54, Y+19 +Prize: X=5556, Y=8121 + +Button A: X+42, Y+16 +Button B: X+25, Y+46 +Prize: X=6595, Y=7886 + +Button A: X+18, Y+38 +Button B: X+51, Y+33 +Prize: X=10826, Y=15950 + +Button A: X+30, Y+52 +Button B: X+24, Y+11 +Prize: X=18374, Y=18262 + +Button A: X+43, Y+17 +Button B: X+20, Y+51 +Prize: X=6909, Y=5174 + +Button A: X+12, Y+49 +Button B: X+73, Y+35 +Prize: X=19520, Y=7473 + +Button A: X+26, Y+54 +Button B: X+81, Y+18 +Prize: X=2771, Y=1098 + +Button A: X+38, Y+16 +Button B: X+35, Y+56 +Prize: X=9775, Y=16248 + +Button A: X+74, Y+12 +Button B: X+13, Y+83 +Prize: X=17184, Y=8706 + +Button A: X+47, Y+15 +Button B: X+59, Y+68 +Prize: X=6455, Y=5207 + +Button A: X+51, Y+75 +Button B: X+73, Y+35 +Prize: X=3535, Y=4475 + +Button A: X+11, Y+49 +Button B: X+43, Y+19 +Prize: X=15272, Y=2282 + +Button A: X+64, Y+12 +Button B: X+12, Y+73 +Prize: X=2236, Y=7049 + +Button A: X+80, Y+36 +Button B: X+18, Y+61 +Prize: X=19208, Y=11960 + +Button A: X+52, Y+21 +Button B: X+11, Y+35 +Prize: X=4204, Y=354 + diff --git a/day13/main.go b/day13/main.go new file mode 100644 index 0000000..d56a3c6 --- /dev/null +++ b/day13/main.go @@ -0,0 +1,128 @@ +package main + +import ( + "fmt" + "regexp" + "strconv" + "strings" + + "git.mstar.dev/mstar/aoc24/util" + "git.mstar.dev/mstar/goutils/other" + "git.mstar.dev/mstar/goutils/sliceutils" +) + +type Machine struct { + A, B, Price util.Vec2 +} + +var buttonARegex = regexp.MustCompile(`Button A: X\+(\d+), Y\+(\d+)`) +var buttonBRegex = regexp.MustCompile(`Button B: X\+(\d+), Y\+(\d+)`) +var prizeRegex = regexp.MustCompile(`Prize: X=(\d+), Y=(\d+)`) + +func dataToGroups(data []byte) [][]string { + bigGroups := strings.Split(string(data), "\n\n") + return sliceutils.Map( + sliceutils.Filter(bigGroups, func(t string) bool { return len(t) != 0 }), + func(t string) []string { + return sliceutils.Filter( + strings.Split(t, "\n"), + func(t string) bool { return len(t) != 0 }, + ) + }, + ) +} + +func groupsToMachines(groups [][]string) []Machine { + return sliceutils.Map(groups, func(t []string) Machine { + return groupToMachine(t[0], t[1], t[2]) + }) +} + +func groupToMachine(a, b, p string) Machine { + aMatches := buttonARegex.FindStringSubmatch(a) + vecA := util.Vec2{ + X: int64(other.Must(strconv.Atoi(aMatches[1]))), + Y: int64(other.Must(strconv.Atoi(aMatches[2]))), + } + bMatches := buttonBRegex.FindStringSubmatch(b) + vecb := util.Vec2{ + X: int64(other.Must(strconv.Atoi(bMatches[1]))), + Y: int64(other.Must(strconv.Atoi(bMatches[2]))), + } + pMatches := prizeRegex.FindStringSubmatch(p) + vecp := util.Vec2{ + X: int64(other.Must(strconv.Atoi(pMatches[1]))), + Y: int64(other.Must(strconv.Atoi(pMatches[2]))), + } + return Machine{vecA, vecb, vecp} +} + +func totalCost(a, b uint64) uint64 { + return a*3 + b +} + +func (m *Machine) CalcLowest() (aCount, bCount int, found bool) { + smallestTotal := totalCost(1000, 1000) + smallestA := 1000 + smallestB := 1000 + + for a := 100; a >= 1; a-- { + for b := 100; b >= 1; b-- { + if m.A.Mult(int64(a)).Add(m.B.Mult(int64(b))).Eq(m.Price) { + if smallestTotal > uint64(a)*3+uint64(b) { + smallestA = a + smallestB = b + smallestTotal = totalCost(uint64(a), uint64(b)) + } + } + } + } + return smallestA, smallestB, smallestTotal < totalCost(1000, 1000) +} + +func (m *Machine) CalcLowest2() (int64, bool) { + truePrice := m.Price.Add(util.Vec2{X: 10000000000000, Y: 10000000000000}) + // Determinant of the two buttons + determinant := m.A.X*m.B.Y - m.A.Y*m.B.X + if determinant == 0 { + return 0, false + } + // Determinant of button B and true price + numA := truePrice.X*m.B.Y - truePrice.Y*m.B.X + // Determinant of button A and true price + numB := truePrice.Y*m.A.X - truePrice.X*m.A.Y + + if numA%determinant != 0 || numB%determinant != 0 { + return 0, false + } + + a := numA / determinant + b := numB / determinant + + if a >= 0 && b >= 0 { + return a*3 + b, true + } else { + return 0, false + } +} + +func main() { + groups := dataToGroups(util.LoadFileFromArgs()) + machines := groupsToMachines(groups) + var acc uint64 = 0 + var maxAcc uint64 = 0 + // fmt.Println(machines[0].CalcLowest()) + for _, machine := range machines { + if a, b, ok := machine.CalcLowest(); ok { + // fmt.Printf("Machine %d is ok\n", i) + acc += totalCost(uint64(a), uint64(b)) + } + // fmt.Println("lowest 1 done") + if a, ok := machine.CalcLowest2(); ok { + maxAcc += uint64(a) + } + // fmt.Println("lowest 2 done") + } + fmt.Printf("Task 1: %d\n", acc) + fmt.Printf("Task 2: %d\n", maxAcc) +} diff --git a/day13/sample b/day13/sample new file mode 100644 index 0000000..912f482 --- /dev/null +++ b/day13/sample @@ -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 diff --git a/util/vec.go b/util/vec.go new file mode 100644 index 0000000..c723afb --- /dev/null +++ b/util/vec.go @@ -0,0 +1,17 @@ +package util + +type Vec2 struct { + X, Y int64 +} + +func (v Vec2) Mult(by int64) Vec2 { + return Vec2{v.X * by, v.Y * by} +} + +func (v Vec2) Add(a Vec2) Vec2 { + return Vec2{v.X + a.X, v.Y + a.Y} +} + +func (v Vec2) Eq(a Vec2) bool { + return v.X == a.X && v.Y == a.Y +}