From 9c5e0fa48bfb52063822065fa9cf507f62f257b5 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Fri, 13 Dec 2024 07:13:29 -0600 Subject: [PATCH] 2024 Day 13 Complete! --- 2024/day13/input | 1279 ++++++++++++++++++++++++++++++++++++++++++ 2024/day13/main.go | 93 +++ 2024/day13/testinput | 15 + 3 files changed, 1387 insertions(+) create mode 100644 2024/day13/input create mode 100644 2024/day13/main.go create mode 100644 2024/day13/testinput diff --git a/2024/day13/input b/2024/day13/input new file mode 100644 index 0000000..96c8a6a --- /dev/null +++ b/2024/day13/input @@ -0,0 +1,1279 @@ +Button A: X+46, Y+68 +Button B: X+34, Y+14 +Prize: X=11306, Y=10856 + +Button A: X+90, Y+16 +Button B: X+53, Y+99 +Prize: X=5781, Y=8821 + +Button A: X+76, Y+97 +Button B: X+66, Y+11 +Prize: X=7930, Y=6972 + +Button A: X+11, Y+56 +Button B: X+56, Y+13 +Prize: X=17583, Y=11336 + +Button A: X+18, Y+59 +Button B: X+49, Y+12 +Prize: X=620, Y=7885 + +Button A: X+67, Y+21 +Button B: X+28, Y+71 +Prize: X=11649, Y=10243 + +Button A: X+45, Y+12 +Button B: X+19, Y+60 +Prize: X=3017, Y=16292 + +Button A: X+51, Y+87 +Button B: X+72, Y+30 +Prize: X=9009, Y=10263 + +Button A: X+88, Y+53 +Button B: X+21, Y+82 +Prize: X=7077, Y=9325 + +Button A: X+73, Y+22 +Button B: X+20, Y+67 +Prize: X=9471, Y=17593 + +Button A: X+21, Y+51 +Button B: X+66, Y+29 +Prize: X=17174, Y=15951 + +Button A: X+60, Y+27 +Button B: X+18, Y+57 +Prize: X=4298, Y=3557 + +Button A: X+93, Y+38 +Button B: X+20, Y+59 +Prize: X=3721, Y=2232 + +Button A: X+26, Y+45 +Button B: X+98, Y+23 +Prize: X=4554, Y=2897 + +Button A: X+34, Y+13 +Button B: X+36, Y+49 +Prize: X=268, Y=12318 + +Button A: X+71, Y+86 +Button B: X+90, Y+22 +Prize: X=9376, Y=6136 + +Button A: X+51, Y+17 +Button B: X+14, Y+65 +Prize: X=3077, Y=11339 + +Button A: X+18, Y+45 +Button B: X+26, Y+16 +Prize: X=18058, Y=18567 + +Button A: X+72, Y+11 +Button B: X+23, Y+84 +Prize: X=18944, Y=8147 + +Button A: X+21, Y+38 +Button B: X+51, Y+29 +Prize: X=2816, Y=6732 + +Button A: X+82, Y+64 +Button B: X+13, Y+94 +Prize: X=3078, Y=10620 + +Button A: X+80, Y+13 +Button B: X+28, Y+65 +Prize: X=7636, Y=5291 + +Button A: X+12, Y+40 +Button B: X+36, Y+16 +Prize: X=5216, Y=432 + +Button A: X+85, Y+48 +Button B: X+33, Y+95 +Prize: X=10053, Y=13008 + +Button A: X+11, Y+51 +Button B: X+58, Y+13 +Prize: X=11285, Y=9700 + +Button A: X+92, Y+38 +Button B: X+34, Y+70 +Prize: X=8376, Y=5586 + +Button A: X+17, Y+77 +Button B: X+93, Y+85 +Prize: X=8862, Y=9206 + +Button A: X+32, Y+56 +Button B: X+60, Y+28 +Prize: X=4928, Y=4312 + +Button A: X+62, Y+17 +Button B: X+43, Y+92 +Prize: X=4471, Y=8525 + +Button A: X+48, Y+14 +Button B: X+23, Y+50 +Prize: X=16261, Y=4674 + +Button A: X+17, Y+50 +Button B: X+49, Y+15 +Prize: X=4344, Y=17580 + +Button A: X+49, Y+23 +Button B: X+32, Y+67 +Prize: X=5161, Y=16455 + +Button A: X+65, Y+13 +Button B: X+19, Y+80 +Prize: X=3634, Y=10296 + +Button A: X+94, Y+17 +Button B: X+17, Y+66 +Prize: X=2585, Y=3425 + +Button A: X+42, Y+75 +Button B: X+86, Y+44 +Prize: X=6556, Y=6886 + +Button A: X+36, Y+89 +Button B: X+49, Y+38 +Prize: X=5300, Y=8447 + +Button A: X+54, Y+23 +Button B: X+42, Y+98 +Prize: X=1932, Y=2345 + +Button A: X+96, Y+41 +Button B: X+34, Y+68 +Prize: X=1266, Y=1022 + +Button A: X+30, Y+45 +Button B: X+85, Y+39 +Prize: X=8575, Y=6402 + +Button A: X+18, Y+42 +Button B: X+77, Y+11 +Prize: X=3451, Y=2149 + +Button A: X+41, Y+11 +Button B: X+11, Y+60 +Prize: X=3314, Y=10795 + +Button A: X+54, Y+27 +Button B: X+23, Y+59 +Prize: X=6809, Y=19472 + +Button A: X+11, Y+34 +Button B: X+53, Y+19 +Prize: X=19286, Y=2321 + +Button A: X+65, Y+32 +Button B: X+15, Y+40 +Prize: X=4820, Y=4216 + +Button A: X+17, Y+87 +Button B: X+39, Y+11 +Prize: X=2199, Y=3333 + +Button A: X+86, Y+29 +Button B: X+23, Y+64 +Prize: X=1631, Y=2856 + +Button A: X+53, Y+79 +Button B: X+37, Y+13 +Prize: X=5954, Y=5292 + +Button A: X+17, Y+56 +Button B: X+61, Y+26 +Prize: X=16099, Y=5820 + +Button A: X+15, Y+47 +Button B: X+40, Y+20 +Prize: X=10555, Y=19023 + +Button A: X+69, Y+33 +Button B: X+27, Y+81 +Prize: X=8967, Y=10893 + +Button A: X+43, Y+23 +Button B: X+12, Y+45 +Prize: X=10726, Y=2562 + +Button A: X+78, Y+58 +Button B: X+17, Y+92 +Prize: X=4422, Y=9002 + +Button A: X+54, Y+12 +Button B: X+13, Y+57 +Prize: X=10999, Y=6479 + +Button A: X+19, Y+42 +Button B: X+45, Y+11 +Prize: X=10603, Y=5806 + +Button A: X+32, Y+59 +Button B: X+79, Y+11 +Prize: X=3861, Y=3483 + +Button A: X+42, Y+72 +Button B: X+95, Y+16 +Prize: X=10830, Y=7992 + +Button A: X+41, Y+13 +Button B: X+33, Y+59 +Prize: X=10070, Y=13340 + +Button A: X+89, Y+20 +Button B: X+18, Y+28 +Prize: X=8586, Y=2696 + +Button A: X+73, Y+22 +Button B: X+18, Y+54 +Prize: X=18612, Y=9264 + +Button A: X+11, Y+57 +Button B: X+68, Y+37 +Prize: X=4435, Y=5321 + +Button A: X+88, Y+80 +Button B: X+96, Y+17 +Prize: X=10168, Y=6503 + +Button A: X+38, Y+12 +Button B: X+17, Y+37 +Prize: X=4611, Y=3955 + +Button A: X+11, Y+32 +Button B: X+57, Y+12 +Prize: X=9215, Y=10088 + +Button A: X+17, Y+62 +Button B: X+35, Y+11 +Prize: X=5521, Y=4354 + +Button A: X+59, Y+35 +Button B: X+18, Y+49 +Prize: X=12769, Y=16895 + +Button A: X+25, Y+70 +Button B: X+66, Y+16 +Prize: X=19790, Y=9000 + +Button A: X+46, Y+16 +Button B: X+23, Y+69 +Prize: X=10657, Y=15685 + +Button A: X+19, Y+11 +Button B: X+26, Y+50 +Prize: X=11223, Y=12479 + +Button A: X+62, Y+20 +Button B: X+19, Y+43 +Prize: X=5561, Y=3131 + +Button A: X+31, Y+58 +Button B: X+81, Y+21 +Prize: X=2472, Y=3189 + +Button A: X+84, Y+19 +Button B: X+59, Y+64 +Prize: X=8949, Y=7039 + +Button A: X+58, Y+14 +Button B: X+18, Y+66 +Prize: X=11504, Y=18632 + +Button A: X+50, Y+20 +Button B: X+12, Y+38 +Prize: X=18372, Y=368 + +Button A: X+52, Y+31 +Button B: X+40, Y+88 +Prize: X=3144, Y=5916 + +Button A: X+31, Y+58 +Button B: X+50, Y+11 +Prize: X=10401, Y=1713 + +Button A: X+92, Y+25 +Button B: X+23, Y+41 +Prize: X=5727, Y=3259 + +Button A: X+16, Y+59 +Button B: X+50, Y+13 +Prize: X=17018, Y=5204 + +Button A: X+20, Y+42 +Button B: X+71, Y+42 +Prize: X=18765, Y=19226 + +Button A: X+29, Y+54 +Button B: X+25, Y+15 +Prize: X=4529, Y=2339 + +Button A: X+63, Y+41 +Button B: X+11, Y+35 +Prize: X=12014, Y=18546 + +Button A: X+45, Y+69 +Button B: X+46, Y+18 +Prize: X=4311, Y=17831 + +Button A: X+82, Y+39 +Button B: X+37, Y+87 +Prize: X=4611, Y=6843 + +Button A: X+48, Y+22 +Button B: X+23, Y+51 +Prize: X=647, Y=17871 + +Button A: X+92, Y+35 +Button B: X+20, Y+53 +Prize: X=9388, Y=5251 + +Button A: X+51, Y+23 +Button B: X+23, Y+56 +Prize: X=18192, Y=5625 + +Button A: X+71, Y+21 +Button B: X+18, Y+53 +Prize: X=16874, Y=15689 + +Button A: X+43, Y+40 +Button B: X+53, Y+11 +Prize: X=2879, Y=2027 + +Button A: X+72, Y+26 +Button B: X+11, Y+51 +Prize: X=8373, Y=13165 + +Button A: X+12, Y+32 +Button B: X+99, Y+30 +Prize: X=792, Y=1176 + +Button A: X+35, Y+15 +Button B: X+29, Y+55 +Prize: X=16492, Y=14030 + +Button A: X+12, Y+78 +Button B: X+61, Y+14 +Prize: X=6324, Y=17086 + +Button A: X+35, Y+12 +Button B: X+37, Y+76 +Prize: X=15217, Y=9180 + +Button A: X+46, Y+11 +Button B: X+28, Y+58 +Prize: X=18696, Y=15616 + +Button A: X+12, Y+37 +Button B: X+72, Y+32 +Prize: X=11348, Y=3263 + +Button A: X+84, Y+11 +Button B: X+25, Y+94 +Prize: X=6302, Y=7539 + +Button A: X+11, Y+32 +Button B: X+65, Y+49 +Prize: X=8461, Y=17341 + +Button A: X+20, Y+61 +Button B: X+65, Y+48 +Prize: X=7635, Y=9614 + +Button A: X+24, Y+97 +Button B: X+62, Y+40 +Prize: X=2724, Y=7219 + +Button A: X+20, Y+52 +Button B: X+46, Y+23 +Prize: X=19098, Y=2929 + +Button A: X+94, Y+94 +Button B: X+93, Y+22 +Prize: X=8622, Y=6776 + +Button A: X+11, Y+97 +Button B: X+49, Y+25 +Prize: X=4716, Y=3320 + +Button A: X+92, Y+67 +Button B: X+21, Y+56 +Prize: X=5073, Y=3898 + +Button A: X+76, Y+40 +Button B: X+22, Y+99 +Prize: X=4294, Y=7243 + +Button A: X+29, Y+30 +Button B: X+16, Y+67 +Prize: X=3040, Y=3952 + +Button A: X+18, Y+37 +Button B: X+56, Y+29 +Prize: X=18778, Y=5902 + +Button A: X+27, Y+41 +Button B: X+44, Y+19 +Prize: X=2945, Y=3707 + +Button A: X+49, Y+13 +Button B: X+19, Y+35 +Prize: X=14917, Y=3765 + +Button A: X+49, Y+25 +Button B: X+18, Y+57 +Prize: X=6838, Y=6400 + +Button A: X+16, Y+63 +Button B: X+57, Y+37 +Prize: X=5095, Y=8253 + +Button A: X+24, Y+36 +Button B: X+37, Y+11 +Prize: X=6584, Y=11024 + +Button A: X+24, Y+13 +Button B: X+16, Y+31 +Prize: X=6744, Y=19621 + +Button A: X+40, Y+22 +Button B: X+13, Y+40 +Prize: X=10050, Y=8160 + +Button A: X+12, Y+34 +Button B: X+41, Y+27 +Prize: X=7015, Y=15285 + +Button A: X+49, Y+22 +Button B: X+50, Y+89 +Prize: X=989, Y=1043 + +Button A: X+20, Y+34 +Button B: X+34, Y+18 +Prize: X=8100, Y=10782 + +Button A: X+18, Y+52 +Button B: X+59, Y+24 +Prize: X=11451, Y=6060 + +Button A: X+56, Y+32 +Button B: X+14, Y+40 +Prize: X=5394, Y=19544 + +Button A: X+20, Y+75 +Button B: X+61, Y+16 +Prize: X=12470, Y=9975 + +Button A: X+12, Y+56 +Button B: X+90, Y+80 +Prize: X=5886, Y=8768 + +Button A: X+64, Y+25 +Button B: X+28, Y+60 +Prize: X=3552, Y=10805 + +Button A: X+26, Y+11 +Button B: X+44, Y+62 +Prize: X=9204, Y=16638 + +Button A: X+40, Y+59 +Button B: X+44, Y+20 +Prize: X=4688, Y=2784 + +Button A: X+12, Y+78 +Button B: X+99, Y+44 +Prize: X=4470, Y=8672 + +Button A: X+26, Y+98 +Button B: X+82, Y+63 +Prize: X=7812, Y=9513 + +Button A: X+71, Y+16 +Button B: X+13, Y+62 +Prize: X=12098, Y=16466 + +Button A: X+25, Y+75 +Button B: X+59, Y+11 +Prize: X=16822, Y=17738 + +Button A: X+12, Y+48 +Button B: X+84, Y+38 +Prize: X=2904, Y=5060 + +Button A: X+66, Y+36 +Button B: X+22, Y+43 +Prize: X=10440, Y=18237 + +Button A: X+29, Y+51 +Button B: X+48, Y+23 +Prize: X=2945, Y=2784 + +Button A: X+70, Y+98 +Button B: X+88, Y+40 +Prize: X=9142, Y=8722 + +Button A: X+80, Y+75 +Button B: X+99, Y+20 +Prize: X=8778, Y=3715 + +Button A: X+20, Y+75 +Button B: X+65, Y+12 +Prize: X=12115, Y=8597 + +Button A: X+67, Y+17 +Button B: X+13, Y+58 +Prize: X=337, Y=14372 + +Button A: X+54, Y+31 +Button B: X+12, Y+21 +Prize: X=1814, Y=6951 + +Button A: X+15, Y+34 +Button B: X+64, Y+36 +Prize: X=11327, Y=8486 + +Button A: X+98, Y+49 +Button B: X+23, Y+79 +Prize: X=4453, Y=5804 + +Button A: X+72, Y+33 +Button B: X+20, Y+45 +Prize: X=2420, Y=1575 + +Button A: X+48, Y+14 +Button B: X+24, Y+50 +Prize: X=10448, Y=12828 + +Button A: X+11, Y+42 +Button B: X+76, Y+15 +Prize: X=4340, Y=3087 + +Button A: X+49, Y+20 +Button B: X+24, Y+38 +Prize: X=12604, Y=18494 + +Button A: X+19, Y+40 +Button B: X+33, Y+13 +Prize: X=6314, Y=1526 + +Button A: X+77, Y+73 +Button B: X+81, Y+15 +Prize: X=8388, Y=6840 + +Button A: X+72, Y+25 +Button B: X+14, Y+43 +Prize: X=11748, Y=18575 + +Button A: X+36, Y+87 +Button B: X+85, Y+19 +Prize: X=5951, Y=3383 + +Button A: X+93, Y+27 +Button B: X+45, Y+51 +Prize: X=4983, Y=3609 + +Button A: X+18, Y+75 +Button B: X+61, Y+53 +Prize: X=2817, Y=2685 + +Button A: X+75, Y+30 +Button B: X+15, Y+52 +Prize: X=5150, Y=1430 + +Button A: X+79, Y+49 +Button B: X+13, Y+44 +Prize: X=2408, Y=1158 + +Button A: X+94, Y+82 +Button B: X+16, Y+70 +Prize: X=4674, Y=7608 + +Button A: X+24, Y+58 +Button B: X+71, Y+38 +Prize: X=6721, Y=11846 + +Button A: X+86, Y+31 +Button B: X+58, Y+70 +Prize: X=8576, Y=5546 + +Button A: X+21, Y+47 +Button B: X+52, Y+23 +Prize: X=708, Y=18513 + +Button A: X+34, Y+13 +Button B: X+29, Y+68 +Prize: X=9296, Y=5777 + +Button A: X+36, Y+19 +Button B: X+26, Y+47 +Prize: X=13828, Y=14644 + +Button A: X+54, Y+22 +Button B: X+22, Y+51 +Prize: X=18732, Y=1301 + +Button A: X+73, Y+14 +Button B: X+32, Y+45 +Prize: X=3099, Y=1255 + +Button A: X+51, Y+67 +Button B: X+98, Y+30 +Prize: X=4858, Y=2926 + +Button A: X+61, Y+23 +Button B: X+16, Y+66 +Prize: X=9529, Y=4189 + +Button A: X+27, Y+80 +Button B: X+40, Y+28 +Prize: X=2464, Y=6124 + +Button A: X+24, Y+93 +Button B: X+28, Y+28 +Prize: X=1724, Y=3863 + +Button A: X+96, Y+14 +Button B: X+50, Y+94 +Prize: X=9356, Y=3272 + +Button A: X+15, Y+41 +Button B: X+88, Y+45 +Prize: X=1452, Y=2209 + +Button A: X+16, Y+50 +Button B: X+69, Y+27 +Prize: X=17931, Y=6301 + +Button A: X+66, Y+20 +Button B: X+14, Y+65 +Prize: X=1966, Y=6550 + +Button A: X+76, Y+34 +Button B: X+17, Y+60 +Prize: X=15517, Y=11952 + +Button A: X+13, Y+92 +Button B: X+36, Y+22 +Prize: X=2037, Y=6036 + +Button A: X+15, Y+46 +Button B: X+74, Y+23 +Prize: X=9446, Y=5712 + +Button A: X+43, Y+73 +Button B: X+86, Y+46 +Prize: X=4902, Y=5522 + +Button A: X+71, Y+43 +Button B: X+36, Y+76 +Prize: X=3695, Y=2563 + +Button A: X+38, Y+93 +Button B: X+81, Y+30 +Prize: X=2429, Y=4767 + +Button A: X+13, Y+21 +Button B: X+55, Y+16 +Prize: X=4681, Y=2171 + +Button A: X+42, Y+31 +Button B: X+14, Y+92 +Prize: X=2030, Y=7215 + +Button A: X+55, Y+13 +Button B: X+16, Y+42 +Prize: X=11411, Y=3201 + +Button A: X+64, Y+59 +Button B: X+84, Y+15 +Prize: X=10316, Y=5077 + +Button A: X+46, Y+21 +Button B: X+51, Y+75 +Prize: X=19776, Y=7790 + +Button A: X+58, Y+28 +Button B: X+26, Y+58 +Prize: X=8782, Y=6332 + +Button A: X+83, Y+77 +Button B: X+11, Y+67 +Prize: X=888, Y=3266 + +Button A: X+52, Y+28 +Button B: X+20, Y+47 +Prize: X=9332, Y=19559 + +Button A: X+87, Y+94 +Button B: X+95, Y+12 +Prize: X=7138, Y=3724 + +Button A: X+19, Y+68 +Button B: X+58, Y+16 +Prize: X=5479, Y=3708 + +Button A: X+11, Y+43 +Button B: X+47, Y+18 +Prize: X=2587, Y=3318 + +Button A: X+16, Y+54 +Button B: X+58, Y+21 +Prize: X=7916, Y=5654 + +Button A: X+29, Y+14 +Button B: X+24, Y+55 +Prize: X=11740, Y=10338 + +Button A: X+96, Y+53 +Button B: X+45, Y+94 +Prize: X=11376, Y=9600 + +Button A: X+76, Y+52 +Button B: X+11, Y+23 +Prize: X=13614, Y=10134 + +Button A: X+38, Y+79 +Button B: X+82, Y+26 +Prize: X=7172, Y=5086 + +Button A: X+17, Y+53 +Button B: X+48, Y+42 +Prize: X=2518, Y=5482 + +Button A: X+34, Y+17 +Button B: X+18, Y+38 +Prize: X=6984, Y=14760 + +Button A: X+24, Y+60 +Button B: X+72, Y+55 +Prize: X=7584, Y=8085 + +Button A: X+61, Y+14 +Button B: X+32, Y+35 +Prize: X=1448, Y=1162 + +Button A: X+11, Y+41 +Button B: X+23, Y+11 +Prize: X=14610, Y=17214 + +Button A: X+81, Y+31 +Button B: X+43, Y+71 +Prize: X=9536, Y=6704 + +Button A: X+64, Y+21 +Button B: X+70, Y+96 +Prize: X=6726, Y=4617 + +Button A: X+71, Y+36 +Button B: X+22, Y+51 +Prize: X=1039, Y=14288 + +Button A: X+20, Y+48 +Button B: X+50, Y+23 +Prize: X=16480, Y=870 + +Button A: X+33, Y+12 +Button B: X+39, Y+64 +Prize: X=17681, Y=5564 + +Button A: X+24, Y+19 +Button B: X+13, Y+99 +Prize: X=878, Y=6195 + +Button A: X+37, Y+72 +Button B: X+40, Y+24 +Prize: X=3083, Y=5784 + +Button A: X+16, Y+70 +Button B: X+59, Y+41 +Prize: X=1896, Y=3084 + +Button A: X+11, Y+92 +Button B: X+85, Y+63 +Prize: X=2206, Y=5492 + +Button A: X+27, Y+50 +Button B: X+39, Y+21 +Prize: X=15932, Y=14863 + +Button A: X+73, Y+41 +Button B: X+14, Y+88 +Prize: X=7912, Y=10454 + +Button A: X+38, Y+38 +Button B: X+15, Y+66 +Prize: X=977, Y=3782 + +Button A: X+48, Y+22 +Button B: X+13, Y+37 +Prize: X=5409, Y=19791 + +Button A: X+73, Y+31 +Button B: X+16, Y+64 +Prize: X=2526, Y=2274 + +Button A: X+61, Y+26 +Button B: X+38, Y+67 +Prize: X=7745, Y=7213 + +Button A: X+17, Y+68 +Button B: X+56, Y+11 +Prize: X=3081, Y=2640 + +Button A: X+26, Y+50 +Button B: X+59, Y+12 +Prize: X=2568, Y=3518 + +Button A: X+11, Y+69 +Button B: X+74, Y+12 +Prize: X=3096, Y=332 + +Button A: X+20, Y+28 +Button B: X+33, Y+13 +Prize: X=10311, Y=19211 + +Button A: X+53, Y+12 +Button B: X+23, Y+49 +Prize: X=9651, Y=5329 + +Button A: X+11, Y+33 +Button B: X+96, Y+82 +Prize: X=1515, Y=2073 + +Button A: X+30, Y+71 +Button B: X+67, Y+14 +Prize: X=2738, Y=4456 + +Button A: X+31, Y+99 +Button B: X+88, Y+15 +Prize: X=8084, Y=4002 + +Button A: X+27, Y+56 +Button B: X+47, Y+20 +Prize: X=14745, Y=4924 + +Button A: X+19, Y+66 +Button B: X+57, Y+18 +Prize: X=17524, Y=12956 + +Button A: X+18, Y+60 +Button B: X+58, Y+11 +Prize: X=9522, Y=3289 + +Button A: X+90, Y+90 +Button B: X+96, Y+22 +Prize: X=15054, Y=9208 + +Button A: X+48, Y+60 +Button B: X+55, Y+12 +Prize: X=3675, Y=2040 + +Button A: X+33, Y+63 +Button B: X+79, Y+37 +Prize: X=2348, Y=3572 + +Button A: X+18, Y+67 +Button B: X+76, Y+22 +Prize: X=15582, Y=4669 + +Button A: X+72, Y+35 +Button B: X+16, Y+48 +Prize: X=2488, Y=19783 + +Button A: X+14, Y+96 +Button B: X+86, Y+17 +Prize: X=5412, Y=2748 + +Button A: X+74, Y+18 +Button B: X+19, Y+42 +Prize: X=1847, Y=1608 + +Button A: X+20, Y+74 +Button B: X+75, Y+16 +Prize: X=4245, Y=2232 + +Button A: X+30, Y+58 +Button B: X+47, Y+24 +Prize: X=1214, Y=1632 + +Button A: X+66, Y+14 +Button B: X+54, Y+80 +Prize: X=7788, Y=6930 + +Button A: X+45, Y+13 +Button B: X+12, Y+34 +Prize: X=11087, Y=11611 + +Button A: X+32, Y+78 +Button B: X+65, Y+20 +Prize: X=355, Y=19180 + +Button A: X+20, Y+70 +Button B: X+61, Y+16 +Prize: X=17574, Y=3644 + +Button A: X+92, Y+31 +Button B: X+40, Y+66 +Prize: X=4852, Y=5469 + +Button A: X+68, Y+86 +Button B: X+59, Y+14 +Prize: X=4819, Y=1912 + +Button A: X+62, Y+14 +Button B: X+35, Y+52 +Prize: X=4956, Y=2442 + +Button A: X+24, Y+16 +Button B: X+14, Y+30 +Prize: X=15778, Y=5442 + +Button A: X+66, Y+27 +Button B: X+47, Y+73 +Prize: X=5637, Y=2790 + +Button A: X+67, Y+32 +Button B: X+11, Y+36 +Prize: X=13909, Y=17424 + +Button A: X+63, Y+32 +Button B: X+17, Y+47 +Prize: X=3090, Y=8064 + +Button A: X+68, Y+70 +Button B: X+86, Y+22 +Prize: X=7898, Y=4072 + +Button A: X+29, Y+94 +Button B: X+80, Y+26 +Prize: X=3334, Y=4974 + +Button A: X+89, Y+24 +Button B: X+16, Y+93 +Prize: X=1334, Y=4794 + +Button A: X+30, Y+58 +Button B: X+81, Y+41 +Prize: X=7995, Y=5631 + +Button A: X+78, Y+21 +Button B: X+62, Y+81 +Prize: X=7610, Y=5007 + +Button A: X+13, Y+40 +Button B: X+65, Y+17 +Prize: X=17215, Y=17419 + +Button A: X+46, Y+57 +Button B: X+82, Y+19 +Prize: X=5774, Y=2033 + +Button A: X+14, Y+30 +Button B: X+41, Y+15 +Prize: X=971, Y=13085 + +Button A: X+32, Y+15 +Button B: X+18, Y+42 +Prize: X=19752, Y=3536 + +Button A: X+50, Y+22 +Button B: X+18, Y+49 +Prize: X=17052, Y=4968 + +Button A: X+72, Y+28 +Button B: X+60, Y+76 +Prize: X=9360, Y=6484 + +Button A: X+14, Y+54 +Button B: X+28, Y+20 +Prize: X=3304, Y=4560 + +Button A: X+12, Y+47 +Button B: X+36, Y+13 +Prize: X=17996, Y=4607 + +Button A: X+14, Y+80 +Button B: X+64, Y+68 +Prize: X=4904, Y=10160 + +Button A: X+36, Y+13 +Button B: X+52, Y+82 +Prize: X=2960, Y=16775 + +Button A: X+55, Y+29 +Button B: X+31, Y+63 +Prize: X=7125, Y=1397 + +Button A: X+17, Y+63 +Button B: X+62, Y+11 +Prize: X=10508, Y=10217 + +Button A: X+24, Y+48 +Button B: X+30, Y+14 +Prize: X=14318, Y=13678 + +Button A: X+43, Y+52 +Button B: X+13, Y+98 +Prize: X=3314, Y=6476 + +Button A: X+62, Y+80 +Button B: X+65, Y+24 +Prize: X=5718, Y=4624 + +Button A: X+14, Y+25 +Button B: X+43, Y+12 +Prize: X=13119, Y=4030 + +Button A: X+80, Y+25 +Button B: X+32, Y+82 +Prize: X=4144, Y=2519 + +Button A: X+61, Y+95 +Button B: X+85, Y+32 +Prize: X=4813, Y=5990 + +Button A: X+34, Y+70 +Button B: X+61, Y+24 +Prize: X=12114, Y=17004 + +Button A: X+27, Y+95 +Button B: X+80, Y+25 +Prize: X=3924, Y=9190 + +Button A: X+58, Y+27 +Button B: X+24, Y+47 +Prize: X=2220, Y=3343 + +Button A: X+14, Y+44 +Button B: X+63, Y+29 +Prize: X=1677, Y=6865 + +Button A: X+48, Y+52 +Button B: X+59, Y+11 +Prize: X=6689, Y=3701 + +Button A: X+70, Y+77 +Button B: X+99, Y+16 +Prize: X=12972, Y=7023 + +Button A: X+24, Y+46 +Button B: X+54, Y+25 +Prize: X=1022, Y=7155 + +Button A: X+31, Y+16 +Button B: X+24, Y+41 +Prize: X=10135, Y=12486 + +Button A: X+42, Y+20 +Button B: X+11, Y+31 +Prize: X=14686, Y=5090 + +Button A: X+28, Y+76 +Button B: X+68, Y+17 +Prize: X=2468, Y=5246 + +Button A: X+13, Y+27 +Button B: X+43, Y+13 +Prize: X=15476, Y=5516 + +Button A: X+55, Y+85 +Button B: X+44, Y+19 +Prize: X=6490, Y=7335 + +Button A: X+90, Y+12 +Button B: X+24, Y+91 +Prize: X=8844, Y=9169 + +Button A: X+12, Y+82 +Button B: X+64, Y+20 +Prize: X=2428, Y=3654 + +Button A: X+35, Y+59 +Button B: X+32, Y+14 +Prize: X=11513, Y=12557 + +Button A: X+61, Y+21 +Button B: X+27, Y+60 +Prize: X=3146, Y=7082 + +Button A: X+13, Y+40 +Button B: X+68, Y+16 +Prize: X=2114, Y=1504 + +Button A: X+29, Y+62 +Button B: X+40, Y+13 +Prize: X=13690, Y=17677 + +Button A: X+68, Y+16 +Button B: X+52, Y+93 +Prize: X=4032, Y=6683 + +Button A: X+15, Y+42 +Button B: X+65, Y+40 +Prize: X=4180, Y=8478 + +Button A: X+11, Y+50 +Button B: X+62, Y+50 +Prize: X=1456, Y=4300 + +Button A: X+20, Y+62 +Button B: X+46, Y+26 +Prize: X=5838, Y=7254 + +Button A: X+31, Y+60 +Button B: X+98, Y+16 +Prize: X=10370, Y=4440 + +Button A: X+13, Y+38 +Button B: X+66, Y+13 +Prize: X=11705, Y=17386 + +Button A: X+87, Y+52 +Button B: X+26, Y+55 +Prize: X=1043, Y=1018 + +Button A: X+38, Y+23 +Button B: X+16, Y+39 +Prize: X=19014, Y=13080 + +Button A: X+23, Y+39 +Button B: X+30, Y+12 +Prize: X=17929, Y=13841 + +Button A: X+44, Y+12 +Button B: X+16, Y+69 +Prize: X=6948, Y=6548 + +Button A: X+46, Y+13 +Button B: X+47, Y+84 +Prize: X=4533, Y=6302 + +Button A: X+31, Y+95 +Button B: X+80, Y+62 +Prize: X=3847, Y=7027 + +Button A: X+53, Y+12 +Button B: X+21, Y+68 +Prize: X=8142, Y=672 + +Button A: X+44, Y+63 +Button B: X+38, Y+15 +Prize: X=2894, Y=18809 + +Button A: X+17, Y+45 +Button B: X+66, Y+32 +Prize: X=15292, Y=1478 + +Button A: X+60, Y+27 +Button B: X+32, Y+90 +Prize: X=4344, Y=3996 + +Button A: X+12, Y+55 +Button B: X+69, Y+24 +Prize: X=11840, Y=14259 + +Button A: X+58, Y+33 +Button B: X+17, Y+48 +Prize: X=8994, Y=10850 + +Button A: X+88, Y+74 +Button B: X+25, Y+70 +Prize: X=2300, Y=2130 + +Button A: X+73, Y+29 +Button B: X+66, Y+88 +Prize: X=5273, Y=2589 + +Button A: X+56, Y+89 +Button B: X+93, Y+42 +Prize: X=9102, Y=6213 + +Button A: X+66, Y+26 +Button B: X+14, Y+52 +Prize: X=7358, Y=17644 + +Button A: X+21, Y+73 +Button B: X+79, Y+42 +Prize: X=4021, Y=4673 + +Button A: X+12, Y+64 +Button B: X+83, Y+14 +Prize: X=17054, Y=16084 + +Button A: X+99, Y+25 +Button B: X+60, Y+64 +Prize: X=10740, Y=5008 + +Button A: X+42, Y+23 +Button B: X+16, Y+32 +Prize: X=17830, Y=7753 + +Button A: X+42, Y+62 +Button B: X+97, Y+45 +Prize: X=1761, Y=2305 + +Button A: X+35, Y+63 +Button B: X+46, Y+19 +Prize: X=4237, Y=5585 + +Button A: X+27, Y+74 +Button B: X+59, Y+12 +Prize: X=7882, Y=18974 + +Button A: X+71, Y+70 +Button B: X+15, Y+97 +Prize: X=1891, Y=7948 + +Button A: X+19, Y+52 +Button B: X+31, Y+19 +Prize: X=3859, Y=5755 + +Button A: X+24, Y+70 +Button B: X+47, Y+13 +Prize: X=15682, Y=16772 + +Button A: X+47, Y+13 +Button B: X+15, Y+29 +Prize: X=10038, Y=11202 + +Button A: X+22, Y+84 +Button B: X+97, Y+30 +Prize: X=8182, Y=4692 + +Button A: X+17, Y+89 +Button B: X+55, Y+16 +Prize: X=4515, Y=6777 + +Button A: X+23, Y+46 +Button B: X+90, Y+19 +Prize: X=2884, Y=4641 + +Button A: X+56, Y+13 +Button B: X+24, Y+68 +Prize: X=10376, Y=13054 + +Button A: X+64, Y+33 +Button B: X+11, Y+38 +Prize: X=17703, Y=16249 + +Button A: X+23, Y+12 +Button B: X+23, Y+59 +Prize: X=1012, Y=2079 + +Button A: X+46, Y+86 +Button B: X+95, Y+17 +Prize: X=4597, Y=1367 + +Button A: X+73, Y+13 +Button B: X+19, Y+63 +Prize: X=13320, Y=13352 + +Button A: X+42, Y+18 +Button B: X+40, Y+78 +Prize: X=2180, Y=3612 diff --git a/2024/day13/main.go b/2024/day13/main.go new file mode 100644 index 0000000..cf1d402 --- /dev/null +++ b/2024/day13/main.go @@ -0,0 +1,93 @@ +package main + +import ( + "fmt" + "math" + + h "git.bullercodeworks.com/brian/adventofcode/helpers" +) + +func main() { + inp := h.StdinToStringSlice() + part1(inp) + fmt.Println() + part2(inp) +} + +func part1(inp []string) { + fmt.Println("# Part 1") + games := parseInput(inp) + var total int + for i := range games { + tokens := games[i].Solve() + if tokens > 0 { + total = total + tokens + } + } + fmt.Println("Total Tokens:", total) +} + +func part2(inp []string) { + fmt.Println("# Part 2") + games := parseInput(inp) + var total int + for i := range games { + games[i].Prize.X += 10000000000000 + games[i].Prize.Y += 10000000000000 + tokens := games[i].Solve() + if tokens > 0 { + total = total + tokens + } + } + fmt.Println("Total Tokens:", total) +} + +type Game struct { + Line1 h.Coordinate + Line2 h.Coordinate + Prize h.Coordinate +} + +/* +Our answer is, in algebraic terms: +(g.Line1.X * n) + (g.Line2.X * m) = g.Prize.X +(g.Line1.Y * n) + (g.Line2.Y * m) = g.Prize.Y +where n is the number of 'A' button presses +and m is the number of 'B' button presses + +Solving for n & m gives us these formulas: +n = (g.Prize.X * g.Line2.Y - g.Prize.Y * g.Line2.X) / (g.Line1.X * g.Line2.Y - g.Line2.x * g.Line1.Y) +m = (g.Prize.X - g.Line1.X * n) / g.Line2.X +Then just make sure that n and m are integers +*/ +func (g *Game) Solve() int { + n := float64(g.Prize.X*g.Line2.Y-g.Prize.Y*g.Line2.X) / float64(g.Line1.X*g.Line2.Y-g.Line2.X*g.Line1.Y) + m := (float64(g.Prize.X) - float64(g.Line1.X)*n) / float64(g.Line2.X) + if math.Mod(n, 1) != 0 || math.Mod(m, 1) != 0 { + return -1 + } + return int(n)*3 + int(m) +} + +func parseInput(inp []string) []Game { + var res []Game + for i := 0; i < len(inp); { + var line1, line2, prize h.Coordinate + fmt.Sscanf(inp[i], "Button A: X+%d, Y+%d", &line1.X, &line1.Y) + fmt.Sscanf(inp[i+1], "Button B: X+%d, Y+%d", &line2.X, &line2.Y) + fmt.Sscanf(inp[i+2], "Prize: X=%d, Y=%d", &prize.X, &prize.Y) + g := Game{ + Line1: line1, Line2: line2, Prize: prize, + } + res = append(res, g) + i = i + 4 + } + return res +} + +func (g Game) String() string { + res := fmt.Sprintf("Button A: X+%d, Y+%d\n", g.Line1.X, g.Line1.Y) + res = fmt.Sprintf("%sButton B: X+%d, Y+%d\n", res, g.Line2.X, g.Line2.Y) + res = fmt.Sprintf("%sPrize: X=%d, Y=%d", res, g.Prize.X, g.Prize.Y) + return res +} diff --git a/2024/day13/testinput b/2024/day13/testinput new file mode 100644 index 0000000..912f482 --- /dev/null +++ b/2024/day13/testinput @@ -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