From a01ab600602e1efcfcbd37ffb6c95f90d2691d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borna=20Rajkovi=C4=87?= Date: Fri, 13 Dec 2024 09:38:49 +0100 Subject: [PATCH] Day 13. --- data.go | 3 + day_13/data.txt | 1279 +++++++++++++++++++++++++++++++++++++++ day_13/example_data.txt | 15 + day_13/solution.go | 80 +++ day_13/solution_test.go | 15 + solutions.go | 3 + 6 files changed, 1395 insertions(+) create mode 100644 day_13/data.txt create mode 100644 day_13/example_data.txt create mode 100644 day_13/solution.go create mode 100644 day_13/solution_test.go diff --git a/data.go b/data.go index a4233d8..fe3a252 100644 --- a/data.go +++ b/data.go @@ -39,3 +39,6 @@ var Day11Data string //go:embed day_12/data.txt var Day12Data string + +//go:embed day_13/data.txt +var Day13Data string diff --git a/day_13/data.txt b/day_13/data.txt new file mode 100644 index 0000000..42ed3dd --- /dev/null +++ b/day_13/data.txt @@ -0,0 +1,1279 @@ +Button A: X+63, Y+14 +Button B: X+12, Y+37 +Prize: X=5921, Y=10432 + +Button A: X+48, Y+23 +Button B: X+38, Y+74 +Prize: X=1820, Y=1430 + +Button A: X+17, Y+64 +Button B: X+72, Y+31 +Prize: X=1801, Y=2437 + +Button A: X+76, Y+21 +Button B: X+20, Y+53 +Prize: X=4836, Y=1811 + +Button A: X+53, Y+18 +Button B: X+30, Y+54 +Prize: X=692, Y=17702 + +Button A: X+99, Y+33 +Button B: X+58, Y+70 +Prize: X=10829, Y=7967 + +Button A: X+15, Y+42 +Button B: X+33, Y+13 +Prize: X=8585, Y=18017 + +Button A: X+17, Y+70 +Button B: X+50, Y+14 +Prize: X=14945, Y=12142 + +Button A: X+80, Y+99 +Button B: X+81, Y+31 +Prize: X=10257, Y=5977 + +Button A: X+62, Y+27 +Button B: X+11, Y+34 +Prize: X=13026, Y=6898 + +Button A: X+12, Y+36 +Button B: X+62, Y+19 +Prize: X=2540, Y=4934 + +Button A: X+13, Y+65 +Button B: X+73, Y+66 +Prize: X=5014, Y=7728 + +Button A: X+60, Y+21 +Button B: X+21, Y+43 +Prize: X=16754, Y=1966 + +Button A: X+89, Y+33 +Button B: X+11, Y+54 +Prize: X=3645, Y=2949 + +Button A: X+56, Y+20 +Button B: X+24, Y+48 +Prize: X=1264, Y=11536 + +Button A: X+68, Y+21 +Button B: X+15, Y+42 +Prize: X=17409, Y=746 + +Button A: X+23, Y+66 +Button B: X+75, Y+32 +Prize: X=11223, Y=3354 + +Button A: X+19, Y+58 +Button B: X+47, Y+18 +Prize: X=6869, Y=7398 + +Button A: X+28, Y+47 +Button B: X+46, Y+18 +Prize: X=12204, Y=3852 + +Button A: X+25, Y+57 +Button B: X+43, Y+11 +Prize: X=3309, Y=15501 + +Button A: X+95, Y+55 +Button B: X+32, Y+79 +Prize: X=5845, Y=6710 + +Button A: X+18, Y+12 +Button B: X+43, Y+93 +Prize: X=2658, Y=4860 + +Button A: X+88, Y+12 +Button B: X+86, Y+83 +Prize: X=3684, Y=930 + +Button A: X+51, Y+18 +Button B: X+44, Y+75 +Prize: X=19780, Y=17984 + +Button A: X+59, Y+30 +Button B: X+19, Y+55 +Prize: X=13898, Y=19160 + +Button A: X+12, Y+51 +Button B: X+49, Y+15 +Prize: X=15071, Y=17144 + +Button A: X+22, Y+46 +Button B: X+70, Y+45 +Prize: X=10238, Y=3734 + +Button A: X+24, Y+47 +Button B: X+84, Y+35 +Prize: X=6444, Y=3684 + +Button A: X+32, Y+15 +Button B: X+24, Y+49 +Prize: X=18208, Y=2148 + +Button A: X+11, Y+67 +Button B: X+51, Y+11 +Prize: X=10173, Y=645 + +Button A: X+57, Y+28 +Button B: X+22, Y+41 +Prize: X=9124, Y=4647 + +Button A: X+13, Y+58 +Button B: X+51, Y+13 +Prize: X=9979, Y=12131 + +Button A: X+27, Y+95 +Button B: X+94, Y+60 +Prize: X=2096, Y=1960 + +Button A: X+43, Y+11 +Button B: X+36, Y+75 +Prize: X=16958, Y=1706 + +Button A: X+54, Y+35 +Button B: X+12, Y+85 +Prize: X=5958, Y=9190 + +Button A: X+40, Y+11 +Button B: X+19, Y+49 +Prize: X=12563, Y=11351 + +Button A: X+12, Y+65 +Button B: X+62, Y+24 +Prize: X=14148, Y=17166 + +Button A: X+77, Y+84 +Button B: X+82, Y+17 +Prize: X=9019, Y=4115 + +Button A: X+20, Y+11 +Button B: X+25, Y+56 +Prize: X=5480, Y=6240 + +Button A: X+14, Y+62 +Button B: X+40, Y+13 +Prize: X=3306, Y=1887 + +Button A: X+19, Y+49 +Button B: X+34, Y+13 +Prize: X=3547, Y=5488 + +Button A: X+85, Y+19 +Button B: X+14, Y+89 +Prize: X=5778, Y=2322 + +Button A: X+57, Y+82 +Button B: X+67, Y+31 +Prize: X=8692, Y=6358 + +Button A: X+76, Y+11 +Button B: X+20, Y+76 +Prize: X=16664, Y=5282 + +Button A: X+73, Y+14 +Button B: X+25, Y+29 +Prize: X=3114, Y=2340 + +Button A: X+91, Y+60 +Button B: X+12, Y+27 +Prize: X=2905, Y=3786 + +Button A: X+54, Y+12 +Button B: X+14, Y+80 +Prize: X=11888, Y=6320 + +Button A: X+51, Y+25 +Button B: X+49, Y+98 +Prize: X=6132, Y=10108 + +Button A: X+16, Y+67 +Button B: X+43, Y+15 +Prize: X=11996, Y=4341 + +Button A: X+33, Y+66 +Button B: X+36, Y+11 +Prize: X=16502, Y=13454 + +Button A: X+32, Y+42 +Button B: X+96, Y+37 +Prize: X=4960, Y=4196 + +Button A: X+50, Y+27 +Button B: X+13, Y+35 +Prize: X=5495, Y=3285 + +Button A: X+12, Y+39 +Button B: X+42, Y+13 +Prize: X=10070, Y=471 + +Button A: X+74, Y+52 +Button B: X+13, Y+36 +Prize: X=3061, Y=7244 + +Button A: X+41, Y+72 +Button B: X+43, Y+14 +Prize: X=7933, Y=19074 + +Button A: X+29, Y+58 +Button B: X+60, Y+17 +Prize: X=6839, Y=3481 + +Button A: X+62, Y+33 +Button B: X+16, Y+55 +Prize: X=18434, Y=17183 + +Button A: X+56, Y+57 +Button B: X+19, Y+78 +Prize: X=3999, Y=8118 + +Button A: X+13, Y+78 +Button B: X+93, Y+27 +Prize: X=2304, Y=2673 + +Button A: X+50, Y+20 +Button B: X+12, Y+43 +Prize: X=1330, Y=2930 + +Button A: X+40, Y+98 +Button B: X+46, Y+28 +Prize: X=4532, Y=7546 + +Button A: X+11, Y+16 +Button B: X+32, Y+15 +Prize: X=1004, Y=18942 + +Button A: X+40, Y+14 +Button B: X+31, Y+54 +Prize: X=12706, Y=17506 + +Button A: X+20, Y+37 +Button B: X+55, Y+19 +Prize: X=15140, Y=6215 + +Button A: X+95, Y+39 +Button B: X+13, Y+64 +Prize: X=5747, Y=7287 + +Button A: X+35, Y+68 +Button B: X+48, Y+20 +Prize: X=17403, Y=2672 + +Button A: X+14, Y+35 +Button B: X+60, Y+37 +Prize: X=6716, Y=5474 + +Button A: X+21, Y+44 +Button B: X+26, Y+11 +Prize: X=13336, Y=6502 + +Button A: X+12, Y+73 +Button B: X+49, Y+13 +Prize: X=8933, Y=11056 + +Button A: X+56, Y+79 +Button B: X+96, Y+42 +Prize: X=5384, Y=3391 + +Button A: X+73, Y+31 +Button B: X+19, Y+62 +Prize: X=10634, Y=16142 + +Button A: X+41, Y+64 +Button B: X+67, Y+26 +Prize: X=8227, Y=7184 + +Button A: X+23, Y+42 +Button B: X+29, Y+12 +Prize: X=15139, Y=4604 + +Button A: X+56, Y+30 +Button B: X+23, Y+49 +Prize: X=5897, Y=14529 + +Button A: X+15, Y+24 +Button B: X+45, Y+19 +Prize: X=4595, Y=5858 + +Button A: X+15, Y+44 +Button B: X+71, Y+46 +Prize: X=5683, Y=9788 + +Button A: X+30, Y+62 +Button B: X+47, Y+30 +Prize: X=1449, Y=1182 + +Button A: X+22, Y+50 +Button B: X+61, Y+23 +Prize: X=13134, Y=8314 + +Button A: X+14, Y+55 +Button B: X+71, Y+25 +Prize: X=1105, Y=12165 + +Button A: X+16, Y+38 +Button B: X+47, Y+27 +Prize: X=14274, Y=14866 + +Button A: X+72, Y+13 +Button B: X+18, Y+62 +Prize: X=16262, Y=5148 + +Button A: X+30, Y+72 +Button B: X+38, Y+15 +Prize: X=3466, Y=3594 + +Button A: X+27, Y+64 +Button B: X+62, Y+26 +Prize: X=8459, Y=16958 + +Button A: X+18, Y+50 +Button B: X+66, Y+35 +Prize: X=17492, Y=13125 + +Button A: X+94, Y+16 +Button B: X+98, Y+86 +Prize: X=5924, Y=2672 + +Button A: X+51, Y+12 +Button B: X+14, Y+26 +Prize: X=368, Y=4586 + +Button A: X+73, Y+24 +Button B: X+47, Y+99 +Prize: X=6932, Y=4869 + +Button A: X+41, Y+18 +Button B: X+12, Y+52 +Prize: X=3183, Y=15770 + +Button A: X+31, Y+14 +Button B: X+42, Y+73 +Prize: X=1830, Y=1745 + +Button A: X+56, Y+20 +Button B: X+18, Y+62 +Prize: X=16986, Y=15838 + +Button A: X+16, Y+35 +Button B: X+33, Y+23 +Prize: X=17558, Y=5165 + +Button A: X+84, Y+57 +Button B: X+11, Y+31 +Prize: X=8262, Y=3847 + +Button A: X+85, Y+12 +Button B: X+67, Y+81 +Prize: X=8788, Y=6177 + +Button A: X+46, Y+11 +Button B: X+31, Y+68 +Prize: X=18210, Y=8428 + +Button A: X+50, Y+12 +Button B: X+18, Y+76 +Prize: X=11006, Y=10004 + +Button A: X+14, Y+94 +Button B: X+59, Y+73 +Prize: X=1505, Y=3319 + +Button A: X+16, Y+25 +Button B: X+60, Y+14 +Prize: X=5384, Y=2511 + +Button A: X+40, Y+54 +Button B: X+34, Y+13 +Prize: X=420, Y=8904 + +Button A: X+39, Y+65 +Button B: X+40, Y+21 +Prize: X=14227, Y=9457 + +Button A: X+59, Y+56 +Button B: X+88, Y+15 +Prize: X=4145, Y=1947 + +Button A: X+14, Y+54 +Button B: X+66, Y+23 +Prize: X=11230, Y=7239 + +Button A: X+18, Y+53 +Button B: X+56, Y+19 +Prize: X=13534, Y=15652 + +Button A: X+46, Y+18 +Button B: X+16, Y+49 +Prize: X=13450, Y=1538 + +Button A: X+11, Y+49 +Button B: X+57, Y+20 +Prize: X=14617, Y=17561 + +Button A: X+20, Y+62 +Button B: X+91, Y+79 +Prize: X=4726, Y=5308 + +Button A: X+60, Y+39 +Button B: X+24, Y+49 +Prize: X=3008, Y=4805 + +Button A: X+72, Y+25 +Button B: X+17, Y+65 +Prize: X=2880, Y=12150 + +Button A: X+38, Y+84 +Button B: X+91, Y+29 +Prize: X=2180, Y=3786 + +Button A: X+29, Y+91 +Button B: X+30, Y+21 +Prize: X=1955, Y=5257 + +Button A: X+14, Y+25 +Button B: X+29, Y+17 +Prize: X=18496, Y=14119 + +Button A: X+16, Y+63 +Button B: X+75, Y+14 +Prize: X=3515, Y=12576 + +Button A: X+23, Y+11 +Button B: X+36, Y+58 +Prize: X=15711, Y=15311 + +Button A: X+75, Y+29 +Button B: X+12, Y+83 +Prize: X=3159, Y=5688 + +Button A: X+40, Y+26 +Button B: X+12, Y+32 +Prize: X=284, Y=12368 + +Button A: X+15, Y+60 +Button B: X+74, Y+12 +Prize: X=16442, Y=14336 + +Button A: X+89, Y+14 +Button B: X+69, Y+56 +Prize: X=7113, Y=4550 + +Button A: X+74, Y+20 +Button B: X+11, Y+51 +Prize: X=1498, Y=17164 + +Button A: X+55, Y+14 +Button B: X+22, Y+57 +Prize: X=14202, Y=3972 + +Button A: X+53, Y+16 +Button B: X+28, Y+69 +Prize: X=10197, Y=4823 + +Button A: X+11, Y+69 +Button B: X+74, Y+48 +Prize: X=4182, Y=6672 + +Button A: X+12, Y+28 +Button B: X+34, Y+19 +Prize: X=8522, Y=9575 + +Button A: X+35, Y+12 +Button B: X+24, Y+63 +Prize: X=15331, Y=5276 + +Button A: X+71, Y+28 +Button B: X+19, Y+39 +Prize: X=6737, Y=3350 + +Button A: X+43, Y+81 +Button B: X+46, Y+14 +Prize: X=8639, Y=15389 + +Button A: X+26, Y+35 +Button B: X+54, Y+21 +Prize: X=4168, Y=3388 + +Button A: X+58, Y+14 +Button B: X+23, Y+73 +Prize: X=16511, Y=10001 + +Button A: X+71, Y+16 +Button B: X+39, Y+98 +Prize: X=6042, Y=7874 + +Button A: X+69, Y+13 +Button B: X+12, Y+71 +Prize: X=14381, Y=9962 + +Button A: X+45, Y+20 +Button B: X+25, Y+64 +Prize: X=9955, Y=19248 + +Button A: X+20, Y+78 +Button B: X+57, Y+12 +Prize: X=886, Y=18314 + +Button A: X+31, Y+58 +Button B: X+59, Y+30 +Prize: X=6111, Y=18934 + +Button A: X+72, Y+49 +Button B: X+11, Y+31 +Prize: X=4216, Y=10597 + +Button A: X+79, Y+19 +Button B: X+17, Y+77 +Prize: X=7349, Y=3809 + +Button A: X+56, Y+21 +Button B: X+18, Y+92 +Prize: X=5464, Y=7505 + +Button A: X+98, Y+16 +Button B: X+48, Y+65 +Prize: X=10860, Y=5603 + +Button A: X+95, Y+15 +Button B: X+37, Y+36 +Prize: X=2821, Y=1893 + +Button A: X+12, Y+93 +Button B: X+64, Y+24 +Prize: X=3816, Y=4086 + +Button A: X+74, Y+26 +Button B: X+14, Y+46 +Prize: X=1548, Y=16972 + +Button A: X+20, Y+42 +Button B: X+39, Y+26 +Prize: X=8419, Y=3192 + +Button A: X+26, Y+62 +Button B: X+62, Y+31 +Prize: X=10956, Y=8392 + +Button A: X+25, Y+64 +Button B: X+35, Y+13 +Prize: X=930, Y=3332 + +Button A: X+17, Y+60 +Button B: X+58, Y+41 +Prize: X=2898, Y=6463 + +Button A: X+58, Y+86 +Button B: X+82, Y+36 +Prize: X=10222, Y=9936 + +Button A: X+29, Y+85 +Button B: X+95, Y+83 +Prize: X=9017, Y=8057 + +Button A: X+19, Y+67 +Button B: X+58, Y+18 +Prize: X=6909, Y=9797 + +Button A: X+35, Y+16 +Button B: X+41, Y+66 +Prize: X=6650, Y=13838 + +Button A: X+41, Y+12 +Button B: X+27, Y+70 +Prize: X=8502, Y=17916 + +Button A: X+42, Y+22 +Button B: X+31, Y+50 +Prize: X=9598, Y=1236 + +Button A: X+69, Y+21 +Button B: X+20, Y+69 +Prize: X=15843, Y=12128 + +Button A: X+21, Y+64 +Button B: X+44, Y+11 +Prize: X=9320, Y=445 + +Button A: X+52, Y+28 +Button B: X+37, Y+63 +Prize: X=13057, Y=9363 + +Button A: X+18, Y+61 +Button B: X+56, Y+21 +Prize: X=980, Y=10681 + +Button A: X+18, Y+30 +Button B: X+49, Y+25 +Prize: X=9663, Y=9675 + +Button A: X+60, Y+23 +Button B: X+25, Y+67 +Prize: X=19355, Y=7228 + +Button A: X+89, Y+13 +Button B: X+50, Y+69 +Prize: X=5953, Y=5250 + +Button A: X+34, Y+14 +Button B: X+26, Y+62 +Prize: X=15374, Y=9738 + +Button A: X+16, Y+85 +Button B: X+81, Y+46 +Prize: X=4306, Y=9809 + +Button A: X+19, Y+59 +Button B: X+31, Y+24 +Prize: X=2311, Y=4358 + +Button A: X+48, Y+70 +Button B: X+26, Y+12 +Prize: X=18182, Y=2026 + +Button A: X+53, Y+20 +Button B: X+56, Y+72 +Prize: X=6993, Y=5284 + +Button A: X+25, Y+80 +Button B: X+86, Y+22 +Prize: X=2657, Y=5464 + +Button A: X+16, Y+31 +Button B: X+83, Y+52 +Prize: X=4281, Y=4486 + +Button A: X+34, Y+25 +Button B: X+21, Y+56 +Prize: X=3677, Y=3961 + +Button A: X+23, Y+14 +Button B: X+22, Y+51 +Prize: X=5099, Y=14177 + +Button A: X+21, Y+21 +Button B: X+79, Y+12 +Prize: X=9164, Y=2799 + +Button A: X+88, Y+49 +Button B: X+29, Y+87 +Prize: X=9884, Y=12022 + +Button A: X+19, Y+79 +Button B: X+86, Y+45 +Prize: X=5530, Y=4551 + +Button A: X+95, Y+87 +Button B: X+82, Y+15 +Prize: X=5539, Y=3450 + +Button A: X+47, Y+13 +Button B: X+24, Y+42 +Prize: X=8476, Y=14658 + +Button A: X+40, Y+25 +Button B: X+16, Y+31 +Prize: X=2408, Y=14978 + +Button A: X+31, Y+83 +Button B: X+66, Y+14 +Prize: X=12489, Y=19145 + +Button A: X+21, Y+51 +Button B: X+43, Y+17 +Prize: X=19484, Y=11600 + +Button A: X+58, Y+22 +Button B: X+15, Y+52 +Prize: X=6102, Y=13788 + +Button A: X+62, Y+17 +Button B: X+24, Y+53 +Prize: X=16042, Y=5798 + +Button A: X+37, Y+21 +Button B: X+29, Y+54 +Prize: X=15497, Y=4808 + +Button A: X+22, Y+59 +Button B: X+99, Y+23 +Prize: X=5665, Y=5250 + +Button A: X+83, Y+14 +Button B: X+30, Y+64 +Prize: X=8493, Y=4910 + +Button A: X+28, Y+75 +Button B: X+68, Y+20 +Prize: X=5088, Y=2585 + +Button A: X+14, Y+39 +Button B: X+35, Y+22 +Prize: X=11491, Y=11926 + +Button A: X+52, Y+56 +Button B: X+64, Y+18 +Prize: X=6580, Y=4540 + +Button A: X+98, Y+11 +Button B: X+57, Y+76 +Prize: X=6791, Y=5704 + +Button A: X+88, Y+45 +Button B: X+40, Y+75 +Prize: X=8928, Y=8220 + +Button A: X+13, Y+33 +Button B: X+75, Y+50 +Prize: X=9076, Y=3791 + +Button A: X+75, Y+11 +Button B: X+13, Y+37 +Prize: X=7105, Y=1393 + +Button A: X+63, Y+43 +Button B: X+12, Y+35 +Prize: X=16619, Y=2191 + +Button A: X+59, Y+82 +Button B: X+85, Y+37 +Prize: X=3968, Y=3811 + +Button A: X+36, Y+91 +Button B: X+88, Y+48 +Prize: X=5932, Y=6447 + +Button A: X+24, Y+96 +Button B: X+83, Y+11 +Prize: X=9770, Y=8906 + +Button A: X+40, Y+13 +Button B: X+18, Y+27 +Prize: X=4810, Y=19642 + +Button A: X+25, Y+29 +Button B: X+69, Y+21 +Prize: X=7111, Y=4175 + +Button A: X+32, Y+60 +Button B: X+21, Y+12 +Prize: X=6652, Y=18176 + +Button A: X+71, Y+34 +Button B: X+15, Y+47 +Prize: X=18074, Y=14851 + +Button A: X+24, Y+55 +Button B: X+23, Y+13 +Prize: X=946, Y=8379 + +Button A: X+61, Y+25 +Button B: X+17, Y+39 +Prize: X=10946, Y=8580 + +Button A: X+14, Y+34 +Button B: X+66, Y+50 +Prize: X=16302, Y=602 + +Button A: X+36, Y+80 +Button B: X+67, Y+45 +Prize: X=7425, Y=6215 + +Button A: X+55, Y+88 +Button B: X+97, Y+24 +Prize: X=4421, Y=3400 + +Button A: X+43, Y+13 +Button B: X+22, Y+72 +Prize: X=17442, Y=4012 + +Button A: X+26, Y+57 +Button B: X+87, Y+42 +Prize: X=8063, Y=4737 + +Button A: X+63, Y+23 +Button B: X+45, Y+86 +Prize: X=6489, Y=7726 + +Button A: X+67, Y+73 +Button B: X+17, Y+82 +Prize: X=3866, Y=7640 + +Button A: X+34, Y+15 +Button B: X+22, Y+49 +Prize: X=4358, Y=2069 + +Button A: X+37, Y+18 +Button B: X+44, Y+78 +Prize: X=3863, Y=2898 + +Button A: X+25, Y+60 +Button B: X+57, Y+23 +Prize: X=15259, Y=12516 + +Button A: X+11, Y+32 +Button B: X+74, Y+30 +Prize: X=467, Y=3686 + +Button A: X+25, Y+86 +Button B: X+67, Y+63 +Prize: X=6940, Y=7963 + +Button A: X+11, Y+80 +Button B: X+75, Y+73 +Prize: X=6885, Y=10859 + +Button A: X+31, Y+50 +Button B: X+96, Y+31 +Prize: X=573, Y=305 + +Button A: X+53, Y+16 +Button B: X+37, Y+77 +Prize: X=15101, Y=16829 + +Button A: X+18, Y+78 +Button B: X+61, Y+12 +Prize: X=9178, Y=7268 + +Button A: X+43, Y+41 +Button B: X+11, Y+53 +Prize: X=3777, Y=6067 + +Button A: X+85, Y+28 +Button B: X+13, Y+44 +Prize: X=1662, Y=3288 + +Button A: X+27, Y+82 +Button B: X+65, Y+12 +Prize: X=6448, Y=14048 + +Button A: X+14, Y+92 +Button B: X+75, Y+84 +Prize: X=2876, Y=5816 + +Button A: X+14, Y+27 +Button B: X+52, Y+20 +Prize: X=13444, Y=17042 + +Button A: X+84, Y+25 +Button B: X+11, Y+60 +Prize: X=11642, Y=4160 + +Button A: X+45, Y+25 +Button B: X+33, Y+59 +Prize: X=9683, Y=10449 + +Button A: X+16, Y+61 +Button B: X+83, Y+50 +Prize: X=2160, Y=3972 + +Button A: X+64, Y+25 +Button B: X+48, Y+61 +Prize: X=5808, Y=6198 + +Button A: X+51, Y+55 +Button B: X+64, Y+16 +Prize: X=8113, Y=5197 + +Button A: X+36, Y+14 +Button B: X+16, Y+25 +Prize: X=12716, Y=12076 + +Button A: X+71, Y+21 +Button B: X+13, Y+70 +Prize: X=1999, Y=389 + +Button A: X+75, Y+14 +Button B: X+15, Y+83 +Prize: X=6365, Y=12329 + +Button A: X+59, Y+13 +Button B: X+23, Y+62 +Prize: X=11799, Y=8700 + +Button A: X+63, Y+12 +Button B: X+28, Y+84 +Prize: X=3756, Y=18080 + +Button A: X+83, Y+97 +Button B: X+93, Y+14 +Prize: X=6937, Y=4509 + +Button A: X+91, Y+52 +Button B: X+23, Y+54 +Prize: X=2740, Y=3200 + +Button A: X+98, Y+24 +Button B: X+12, Y+50 +Prize: X=2410, Y=3508 + +Button A: X+12, Y+48 +Button B: X+71, Y+56 +Prize: X=7260, Y=7152 + +Button A: X+81, Y+61 +Button B: X+12, Y+63 +Prize: X=5145, Y=6249 + +Button A: X+16, Y+53 +Button B: X+96, Y+21 +Prize: X=8048, Y=6463 + +Button A: X+33, Y+14 +Button B: X+15, Y+52 +Prize: X=14369, Y=9140 + +Button A: X+19, Y+59 +Button B: X+30, Y+11 +Prize: X=13981, Y=18382 + +Button A: X+15, Y+41 +Button B: X+62, Y+26 +Prize: X=918, Y=12146 + +Button A: X+60, Y+16 +Button B: X+17, Y+77 +Prize: X=16721, Y=8161 + +Button A: X+65, Y+30 +Button B: X+24, Y+49 +Prize: X=18662, Y=13672 + +Button A: X+19, Y+72 +Button B: X+72, Y+14 +Prize: X=8892, Y=19434 + +Button A: X+53, Y+26 +Button B: X+22, Y+57 +Prize: X=14006, Y=9613 + +Button A: X+64, Y+14 +Button B: X+14, Y+69 +Prize: X=6870, Y=9595 + +Button A: X+33, Y+12 +Button B: X+22, Y+64 +Prize: X=4763, Y=6884 + +Button A: X+11, Y+34 +Button B: X+66, Y+45 +Prize: X=1376, Y=6380 + +Button A: X+11, Y+49 +Button B: X+80, Y+18 +Prize: X=17079, Y=1417 + +Button A: X+88, Y+36 +Button B: X+17, Y+58 +Prize: X=6940, Y=3860 + +Button A: X+56, Y+18 +Button B: X+16, Y+71 +Prize: X=2160, Y=3872 + +Button A: X+73, Y+13 +Button B: X+19, Y+74 +Prize: X=5721, Y=13001 + +Button A: X+26, Y+62 +Button B: X+59, Y+14 +Prize: X=13427, Y=19772 + +Button A: X+62, Y+11 +Button B: X+20, Y+78 +Prize: X=9330, Y=17897 + +Button A: X+84, Y+23 +Button B: X+14, Y+73 +Prize: X=5254, Y=16308 + +Button A: X+35, Y+12 +Button B: X+20, Y+30 +Prize: X=10910, Y=1196 + +Button A: X+56, Y+25 +Button B: X+36, Y+72 +Prize: X=6600, Y=7980 + +Button A: X+18, Y+53 +Button B: X+71, Y+24 +Prize: X=15881, Y=16234 + +Button A: X+24, Y+81 +Button B: X+32, Y+21 +Prize: X=1792, Y=1698 + +Button A: X+57, Y+29 +Button B: X+22, Y+57 +Prize: X=3599, Y=12132 + +Button A: X+45, Y+22 +Button B: X+15, Y+43 +Prize: X=7250, Y=16657 + +Button A: X+11, Y+32 +Button B: X+76, Y+55 +Prize: X=6277, Y=8566 + +Button A: X+11, Y+38 +Button B: X+31, Y+20 +Prize: X=8663, Y=5068 + +Button A: X+13, Y+44 +Button B: X+79, Y+35 +Prize: X=16161, Y=12028 + +Button A: X+14, Y+86 +Button B: X+30, Y+33 +Prize: X=608, Y=1163 + +Button A: X+27, Y+18 +Button B: X+39, Y+96 +Prize: X=4887, Y=9558 + +Button A: X+29, Y+92 +Button B: X+96, Y+19 +Prize: X=9073, Y=2227 + +Button A: X+26, Y+69 +Button B: X+65, Y+14 +Prize: X=15993, Y=6605 + +Button A: X+44, Y+11 +Button B: X+14, Y+42 +Prize: X=8850, Y=15218 + +Button A: X+29, Y+55 +Button B: X+70, Y+39 +Prize: X=6877, Y=3948 + +Button A: X+14, Y+44 +Button B: X+66, Y+24 +Prize: X=11860, Y=13528 + +Button A: X+40, Y+18 +Button B: X+44, Y+73 +Prize: X=18372, Y=11267 + +Button A: X+75, Y+79 +Button B: X+12, Y+73 +Prize: X=6678, Y=8181 + +Button A: X+60, Y+92 +Button B: X+76, Y+28 +Prize: X=8196, Y=6724 + +Button A: X+11, Y+52 +Button B: X+47, Y+16 +Prize: X=19098, Y=9736 + +Button A: X+67, Y+70 +Button B: X+18, Y+83 +Prize: X=6057, Y=8575 + +Button A: X+82, Y+26 +Button B: X+14, Y+61 +Prize: X=18224, Y=11876 + +Button A: X+19, Y+60 +Button B: X+75, Y+32 +Prize: X=18161, Y=5480 + +Button A: X+43, Y+69 +Button B: X+52, Y+25 +Prize: X=17476, Y=4106 + +Button A: X+27, Y+95 +Button B: X+34, Y+32 +Prize: X=2126, Y=2836 + +Button A: X+40, Y+39 +Button B: X+14, Y+96 +Prize: X=1892, Y=6621 + +Button A: X+20, Y+71 +Button B: X+80, Y+40 +Prize: X=8920, Y=10438 + +Button A: X+40, Y+57 +Button B: X+33, Y+11 +Prize: X=6314, Y=568 + +Button A: X+99, Y+91 +Button B: X+15, Y+91 +Prize: X=4014, Y=11102 + +Button A: X+16, Y+22 +Button B: X+27, Y+12 +Prize: X=6729, Y=918 + +Button A: X+11, Y+67 +Button B: X+65, Y+16 +Prize: X=5652, Y=11917 + +Button A: X+14, Y+49 +Button B: X+81, Y+42 +Prize: X=17396, Y=17189 + +Button A: X+12, Y+31 +Button B: X+75, Y+53 +Prize: X=887, Y=4840 + +Button A: X+25, Y+63 +Button B: X+62, Y+15 +Prize: X=8820, Y=18605 + +Button A: X+43, Y+12 +Button B: X+18, Y+55 +Prize: X=10077, Y=19114 + +Button A: X+16, Y+27 +Button B: X+38, Y+12 +Prize: X=14666, Y=6686 + +Button A: X+65, Y+12 +Button B: X+30, Y+81 +Prize: X=5825, Y=10691 + +Button A: X+23, Y+65 +Button B: X+46, Y+14 +Prize: X=19098, Y=1810 + +Button A: X+32, Y+61 +Button B: X+55, Y+18 +Prize: X=9869, Y=745 + +Button A: X+19, Y+42 +Button B: X+97, Y+19 +Prize: X=5478, Y=4097 + +Button A: X+79, Y+25 +Button B: X+12, Y+63 +Prize: X=4014, Y=8007 + +Button A: X+24, Y+55 +Button B: X+57, Y+39 +Prize: X=2778, Y=3251 + +Button A: X+60, Y+14 +Button B: X+29, Y+77 +Prize: X=4471, Y=18743 + +Button A: X+44, Y+71 +Button B: X+45, Y+23 +Prize: X=4764, Y=16962 + +Button A: X+69, Y+44 +Button B: X+14, Y+37 +Prize: X=18647, Y=8826 + +Button A: X+15, Y+70 +Button B: X+58, Y+17 +Prize: X=2737, Y=10708 + +Button A: X+25, Y+48 +Button B: X+42, Y+20 +Prize: X=3308, Y=4896 + +Button A: X+16, Y+43 +Button B: X+70, Y+28 +Prize: X=10848, Y=15996 + +Button A: X+68, Y+74 +Button B: X+12, Y+68 +Prize: X=2632, Y=3084 + +Button A: X+67, Y+87 +Button B: X+91, Y+26 +Prize: X=6156, Y=5966 + +Button A: X+43, Y+88 +Button B: X+99, Y+11 +Prize: X=6953, Y=6182 + +Button A: X+66, Y+21 +Button B: X+17, Y+66 +Prize: X=6466, Y=5814 + +Button A: X+52, Y+24 +Button B: X+21, Y+43 +Prize: X=8244, Y=16996 + +Button A: X+46, Y+82 +Button B: X+45, Y+13 +Prize: X=9831, Y=14647 + +Button A: X+17, Y+30 +Button B: X+49, Y+23 +Prize: X=3553, Y=1954 + +Button A: X+56, Y+23 +Button B: X+16, Y+21 +Prize: X=5072, Y=2819 + +Button A: X+22, Y+98 +Button B: X+70, Y+75 +Prize: X=6382, Y=8773 + +Button A: X+32, Y+93 +Button B: X+68, Y+43 +Prize: X=7404, Y=6210 + +Button A: X+29, Y+75 +Button B: X+94, Y+38 +Prize: X=4690, Y=5566 + +Button A: X+54, Y+20 +Button B: X+39, Y+73 +Prize: X=16733, Y=11735 + +Button A: X+30, Y+15 +Button B: X+22, Y+35 +Prize: X=2952, Y=1980 + +Button A: X+20, Y+78 +Button B: X+86, Y+43 +Prize: X=7874, Y=4685 + +Button A: X+95, Y+22 +Button B: X+77, Y+92 +Prize: X=10628, Y=7208 + +Button A: X+77, Y+13 +Button B: X+36, Y+69 +Prize: X=2662, Y=3218 + +Button A: X+18, Y+49 +Button B: X+38, Y+22 +Prize: X=2140, Y=10210 + +Button A: X+22, Y+64 +Button B: X+68, Y+24 +Prize: X=14384, Y=1912 + +Button A: X+12, Y+34 +Button B: X+72, Y+37 +Prize: X=8864, Y=18895 + +Button A: X+50, Y+69 +Button B: X+67, Y+12 +Prize: X=7166, Y=2004 + +Button A: X+47, Y+31 +Button B: X+13, Y+75 +Prize: X=2386, Y=2238 + +Button A: X+24, Y+67 +Button B: X+57, Y+18 +Prize: X=17177, Y=13222 + +Button A: X+50, Y+22 +Button B: X+21, Y+38 +Prize: X=11997, Y=16114 + +Button A: X+61, Y+25 +Button B: X+29, Y+65 +Prize: X=845, Y=665 \ No newline at end of file diff --git a/day_13/example_data.txt b/day_13/example_data.txt new file mode 100644 index 0000000..444a287 --- /dev/null +++ b/day_13/example_data.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 \ No newline at end of file diff --git a/day_13/solution.go b/day_13/solution.go new file mode 100644 index 0000000..b0d0e33 --- /dev/null +++ b/day_13/solution.go @@ -0,0 +1,80 @@ +package day_13 + +import ( + "fmt" + "strings" +) + +type Arcade struct { + AX, AY int + BX, BY int + PrizeX, PrizeY int +} + +// task:https://adventofcode.com/2024/day/13 +func SolveBasic(input string) int { + arcades := loadArcades(input) + + sum := 0 + for _, arcade := range arcades { + if price, solvable := solve(arcade); solvable { + sum += price + } + } + + return sum +} + +// task:https://adventofcode.com/2024/day/12#part2 +func SolveComplex(input string) int { + arcades := fixPrizes(loadArcades(input)) + + sum := 0 + for _, arcade := range arcades { + if price, solvable := solve(arcade); solvable { + sum += price + } + } + + return sum +} + +func fixPrizes(arcades []Arcade) []Arcade { + for i := range arcades { + arcades[i].PrizeX += 10000000000000 + arcades[i].PrizeY += 10000000000000 + } + return arcades +} + +func solve(arcade Arcade) (int, bool) { + a1 := arcade.AX + b1 := arcade.BX + a2 := arcade.AY + b2 := arcade.BY + c1 := arcade.PrizeX + c2 := arcade.PrizeY + + A := (c1*b2 - b1*c2) / (a1*b2 - b1*a2) + B := (c2 - a2*A) / b2 + + if A*arcade.AX+B*arcade.BX == arcade.PrizeX && + A*arcade.AY+B*arcade.BY == arcade.PrizeY { + return A*3 + B, true + } + return 0, false +} + +func loadArcades(input string) []Arcade { + var arcades []Arcade + + for _, arcadeLine := range strings.Split(input, "\n\n") { + lines := strings.Split(arcadeLine, "\n") + arcade := Arcade{} + fmt.Sscanf(lines[0], "Button A: X+%d, Y+%d", &arcade.AX, &arcade.AY) + fmt.Sscanf(lines[1], "Button B: X+%d, Y+%d", &arcade.BX, &arcade.BY) + fmt.Sscanf(lines[2], "Prize: X=%d, Y=%d", &arcade.PrizeX, &arcade.PrizeY) + arcades = append(arcades, arcade) + } + return arcades +} diff --git a/day_13/solution_test.go b/day_13/solution_test.go new file mode 100644 index 0000000..b6f5907 --- /dev/null +++ b/day_13/solution_test.go @@ -0,0 +1,15 @@ +package day_13_test + +import ( + "advent_of_code_2024/day_13" + "advent_of_code_2024/helpers" + _ "embed" + "testing" +) + +//go:embed example_data.txt +var ExampleData string + +func TestBasicSolutionExample(t *testing.T) { + helpers.Check(t, day_13.SolveBasic, helpers.Format(ExampleData), 480) +} diff --git a/solutions.go b/solutions.go index 2ec338c..6eab4f5 100644 --- a/solutions.go +++ b/solutions.go @@ -13,6 +13,7 @@ import ( "advent_of_code_2024/day_10" "advent_of_code_2024/day_11" "advent_of_code_2024/day_12" + "advent_of_code_2024/day_13" ) var solutions = map[string]Solution{ @@ -41,4 +42,6 @@ var solutions = map[string]Solution{ "12-basic": {day_12.SolveBasic, Day12Data}, "12-complex": {day_12.SolveComplex, Day12Data}, "12-complex-fast": {day_12.SolveComplexFast, Day12Data}, + "13-basic": {day_13.SolveBasic, Day13Data}, + "13-complex": {day_13.SolveComplex, Day13Data}, }