From 0a5c1f77d01fc0bd166494787f24562e2fd3a9e9 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Wed, 11 Dec 2024 10:18:23 +0100 Subject: renamed day folders to two digit format --- 2024/day07/input | 850 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2024/day07/input_test | 9 + 2024/day07/solve.py | 38 +++ 2024/day07/solve2.py | 44 +++ 4 files changed, 941 insertions(+) create mode 100644 2024/day07/input create mode 100644 2024/day07/input_test create mode 100644 2024/day07/solve.py create mode 100644 2024/day07/solve2.py (limited to '2024/day07') diff --git a/2024/day07/input b/2024/day07/input new file mode 100644 index 0000000..f617be2 --- /dev/null +++ b/2024/day07/input @@ -0,0 +1,850 @@ +9151: 132 1 8 714 972 5 21 1 +740: 136 4 40 1 85 71 +1959240: 61 84 4 6 563 +9619353: 62 7 1 9 92 19 44 17 3 4 +85383: 141 8 4 6 9 5 49 +468373294: 7 25 841 46 101 329 4 +634495747544: 83 6 5 5 5 8 95 8 3 7 542 +1473921: 18 1 54 270 8 1 +191617: 9 2 3 78 617 +105545: 1 49 5 1 209 +3074260824: 89 4 90 5 9 4 3 62 452 9 +7871304: 9 3 6 7 96 456 3 1 9 6 8 +113179142: 7 7 96 6 70 6 6 4 49 3 2 7 +65190: 79 7 3 7 246 +111675278: 3 856 13 5 11 9 1 69 7 1 +18232286011544: 911 6 143 5 4 11 544 +2525217842: 2 9 9 8 5 1 4 8 6 4 310 3 +2754: 4 5 8 51 7 4 6 +9742: 77 15 27 6 8 6 81 7 80 +996566149: 674 4 12 668 45 22 1 7 +161036550888: 71 12 27 7 8 550 880 7 +6631527185: 7 5 98 5 9 764 1 7 185 +626: 72 3 379 8 23 +339047997: 914 3 409 904 88 +91402: 115 786 951 60 1 +2463205322: 9 2 8 60 5 821 1 6 8 5 2 +11096244: 24 9 2 43 508 +2761679223799: 8 8 8 5 1 8 490 1 22 799 +9228832: 43 19 8 4 353 +27049036274445: 8 9 5 4 9 791 5 34 3 8 4 2 +1366911546: 793 7 22 123 91 +123461: 53 1 9 5 38 5 338 88 +3822: 63 7 6 +18091789: 1 697 8 7 951 83 785 4 +7714: 469 92 1 13 408 +30391973: 8 593 8 6 1 2 3 8 5 7 6 71 +353583: 6 41 6 29 7 83 +198733471: 66 244 3 595 876 +358201: 6 49 29 7 6 5 47 57 +986380800: 148 51 7 24 64 85 +101112: 931 72 22 29 37 724 +743680946: 7 9 7 5 38 34 23 9 3 49 7 +115585260: 6 6 92 6 5 25 894 +15917620: 1 4 414 140 272 180 +28029104911: 84 15 3 278 4 114 8 +1123377777: 2 50 299 7 5 176 4 4 4 +108274258: 39 209 8 80 65 4 527 2 +6517: 7 7 40 1 3 9 2 5 7 3 144 1 +34114050: 4 8 38 57 9 8 43 123 5 1 +116285217: 10 9 322 2 88 1 4 9 4 15 +57634: 1 496 99 1 6 15 4 4 4 4 2 +26014: 986 9 26 55 89 +9106125640: 956 3 6 1 8 496 522 5 8 +721: 6 60 361 +4047586935: 59 61 1 679 32 +44558521: 856 72 52 859 49 1 +560032830: 10 1 2 1 915 8 7 20 85 6 +1855165370808: 8 7 5 4 1 76 1 4 370 80 8 +1146142: 7 578 3 7 48 94 +329511: 469 7 2 10 11 +420024: 2 73 6 4 516 +126044109: 61 9 6 729 91 25 9 +48703404994: 408 9 3 8 54 6 397 79 4 +5979: 8 7 9 731 88 8 7 3 9 7 3 +10432490441: 939 853 2 4 5 3 37 41 +119418127: 2 64 3 3 1 1 7 5 60 1 2 7 +87128064: 4 39 44 4 8 696 +2130168: 1 5 8 6 9 757 8 7 329 1 9 +97426804: 75 36 97 372 4 +806038: 1 26 6 24 69 3 536 686 +1313845: 26 19 8 6 9 5 +22504: 7 9 6 962 940 400 +3587483330: 92 39 874 4 286 +874581: 8 7 458 3 +8216470392: 3 7 74 81 2 8 3 314 5 9 4 +139797569: 4 1 9 8 1 7 268 71 5 61 8 +50791720425: 7 4 25 2 1 48 76 80 8 4 9 +946998094001: 721 7 46 130 93 994 7 +173645680: 310 56 4 5 680 +34416111: 956 45 8 64 49 +3093564117903: 66 72 42 781 80 155 4 +60037497240: 670 4 1 8 5 9 5 63 30 7 4 +310072: 738 2 35 18 4 +47077801344: 9 966 18 476 632 +126008: 453 669 9 669 70 8 +264843: 20 1 3 6 1 4 51 4 45 +81426920: 9 9 426 1 9 20 +466206: 19 5 178 38 2 2 9 9 1 3 6 +752675046: 858 6 35 3 2 6 5 78 62 6 +4462816920: 59 823 27 746 978 +84744: 6 2 844 9 11 +11830537: 1 3 3 6 44 8 7 19 7 1 39 +63332543: 623 9 60 1 71 527 5 9 +194775: 7 330 4 19 1 12 1 6 5 15 +394568496: 494 85 42 651 976 +24439099581: 41 73 887 9 907 +174366325623: 6 900 722 95 35 624 +444: 66 7 41 1 80 247 +837: 67 1 3 330 69 367 +196056917: 88 2 8 1 147 7 9 2 908 8 +409060: 6 615 82 86 30 94 8 4 +47090: 9 164 1 3 2 33 4 7 2 80 4 +7175: 64 2 823 8 66 7 +20344478588: 3 405 972 2 53 513 2 +659821815620: 613 343 263 5 69 620 +802485555: 2 444 5 7 6 88 16 5 535 +102625677: 1 8 65 2 608 7 3 4 5 +51268162: 879 90 529 80 62 +1662663653: 40 9 6 653 6 6 9 4 46 1 5 +1749: 3 6 89 1 769 +2104465: 6 9 7 49 7 1 9 7 1 1 2 243 +39785040: 3 975 678 4 3 5 +325326: 463 7 9 49 64 3 +505443247: 3 6 3 4 31 2 3 9 322 2 8 1 +6685230840: 84 5 8 1 8 35 79 13 841 +555959866: 3 47 111 2 7 5 98 68 1 +1232050199: 943 6 6 4 7 864 6 1 2 20 +24433540629540: 82 5 83 718 629 541 1 +139844572: 834 9 31 601 286 +352024115: 81 457 8 1 6 294 7 95 +466754400: 72 51 3 9 224 63 +1956636464: 397 89 61 66 463 4 +179284672885: 40 8 82 86 796 56 8 85 +12195470: 7 7 3 710 95 1 38 4 3 +1450501930: 9 5 2 1 7 95 19 1 4 28 5 5 +214898: 8 406 2 96 9 4 4 7 16 2 +27864: 6 966 4 +34977: 4 7 6 6 30 +1128443492504: 8 37 9 749 46 25 2 2 +7965: 13 4 17 9 9 +7258: 1 8 50 7 7 5 8 +9527870: 3 451 8 118 7 46 +9428848: 7 543 125 5 91 +4401902: 5 5 3 1 53 4 3 5 9 2 146 2 +14286283265: 26 996 54 98 65 +2644109705: 279 32 16 2 413 808 +2068932: 61 7 5 969 7 92 9 7 2 +20472203604: 1 9 3 6 2 2 7 3 37 760 1 4 +58617495: 2 171 3 9 177 104 214 +398838423580: 301 18 8 8 92 235 80 +18786839: 26 8 7 1 7 64 919 9 +6278462: 3 956 655 389 1 +9088797: 36 17 3 5 1 5 99 3 +2974506427701: 493 1 2 8 8 737 754 1 +19231: 5 9 420 4 5 271 24 27 +2350420985703: 3 7 1 23 5 6 7 7 53 9 877 +2736: 334 1 8 63 1 +2231907992: 9 149 18 81 509 248 +1118593: 86 1 13 483 106 4 +420262: 68 123 545 571 6 +1386900: 2 67 5 21 516 1 2 2 1 5 5 +26430: 5 522 50 12 68 +1832437: 277 35 189 80 +27477720: 8 66 48 6 48 15 1 508 +789621523: 4 983 8 1 2 1 515 8 +49684854: 77 5 6 9 8 252 90 5 84 +2088517152: 4 3 90 63 7 2 876 53 +4067837: 763 8 42 567 5 +844082: 43 7 7 5 76 29 2 2 9 512 +54108: 67 9 8 56 1 81 +54075944: 870 92 47 4 299 +7776679: 89 5 7 48 71 66 7 1 8 +819893: 3 98 9 3 4 9 2 800 8 693 +1052: 5 1 7 25 +794511615: 18 49 79 9 613 +5775164984242: 765 937 754 42 4 2 +166105353: 2 8 1 1 557 8 994 +449204: 8 9 959 556 2 1 28 +1307419: 1 2 2 4 4 8 4 9 8 178 5 7 +136481: 1 2 21 2 780 3 5 5 7 6 89 +2845449257: 284 5 449 257 +147060: 4 3 2 9 190 +1154: 6 3 8 8 2 +8713340202: 2 3 8 1 567 66 49 749 2 +285498: 154 269 672 495 747 +93244906260: 257 48 31 5 59 60 33 +199254: 9 362 8 51 3 22 +52132: 5 6 8 3 9 6 3 85 990 5 7 +81110: 4 912 157 16 6 +217141: 75 4 7 71 41 +243480250794: 6 67 8 6 7 4 6 744 1 7 7 4 +1461781: 90 66 6 42 9 1 1 +17748024: 7 7 80 926 5 4 10 87 24 +3203786001678: 46 7 4 1 45 85 8 1 678 +202847059: 7 1 943 2 470 59 +19485111: 39 9 575 2 496 5 146 +112166340: 701 2 8 60 2 74 69 +2188134198: 51 3 7 4 1 341 1 6 82 +10944961: 9 5 7 161 89 9 10 6 3 3 6 +42331808802: 2 1 4 5 7 65 37 2 746 6 2 +5325792196: 8 9 374 2 40 1 2 7 2 7 9 +12021872: 51 614 23 393 1 1 2 +4767141: 611 17 2 39 15 +3718357725: 7 1 1 5 1 5 5 5 44 2 5 417 +7646335: 41 4 41 889 84 851 +40469: 8 5 1 3 67 +615330: 643 26 918 300 888 +50260150: 359 700 5 2 8 8 6 5 +125520: 5 5 963 73 120 +647346227: 6 437 8 76 87 295 34 +29711242851815: 70 474 259 897 47 4 1 +5548803: 5 2 32 7 66 332 87 +450: 19 3 23 5 9 +132343: 8 54 40 4 2 3 52 4 3 4 27 +1179858960: 6 70 333 5 7 74 18 +497886150: 199 444 805 7 4 86 +141950: 4 7 8 1 7 8 46 543 4 6 9 4 +149735820035: 153 5 752 975 35 +100199700585: 91 94 765 708 1 583 +1044062784: 2 3 1 755 4 8 661 4 1 16 +5204633552: 5 5 52 4 63 22 7 5 1 5 5 +3620: 1 4 28 6 94 3 45 +295284: 3 41 40 60 84 +48248907: 902 19 8 938 3 5 4 9 3 +615145: 2 1 209 29 84 +2709056: 443 8 5 6 56 +54847043762: 2 7 704 3 746 4 5 5 5 1 8 +1120898: 56 6 6 556 +106037568094: 89 6 770 442 40 36 9 4 +19146429617: 32 28 7 2 7 1 6 959 7 53 +15963224760: 2 248 993 7 4 5 6 212 +776736688: 211 9 63 5 31 87 688 +364586: 18 346 49 9 6 +14059350: 8 2 363 6 8 6 785 +8619: 4 2 619 +16720759: 636 291 710 9 4 9 6 +798569985: 637 928 823 5 51 +210270837: 964 1 7 862 3 541 3 7 2 +2778624710: 231 10 2 4 9 4 8 7 1 2 1 +2153: 387 13 26 1 3 5 +3148076678: 314 807 667 6 1 +16220433195: 9 9 6 3 45 275 1 899 46 +29050653: 7 7 4 29 9 64 7 3 3 +4504999: 8 9 3 9 7 91 2 2 6 8 501 7 +24476553: 2 610 799 84 7 25 553 +960837415277: 24 68 388 213 26 4 77 +362770: 58 781 28 8 5 15 142 +98892626: 120 44 67 9 626 +56: 2 1 53 +264046: 4 970 7 5 53 +362427305: 6 2 9 423 84 4 6 15 7 +319715433: 8 928 7 9 259 8 7 69 69 +227299: 415 3 3 7 1 2 1 6 9 3 4 80 +2284578: 8 660 4 242 784 2 +2808058480: 90 390 731 8 2 +516: 22 1 22 5 464 2 +992: 4 39 50 31 7 7 3 8 99 5 2 +289123: 141 2 17 694 8 3 +564264010: 9 159 96 17 44 14 +485047: 67 740 4 598 69 +3790642776: 984 6 2 21 207 642 +95881: 604 2 1 3 9 52 877 +593105029510: 920 969 644 993 511 +24022618098: 1 5 3 9 3 9 8 5 972 4 7 94 +58556544: 30 4 1 5 794 218 6 32 +253136185: 506 270 5 11 26 57 +5474366: 741 6 246 414 4 3 8 96 +16587427068: 729 79 72 304 767 4 3 +50874781: 6 96 883 139 7 9 +5895: 75 7 130 9 +242279046: 13 9 6 520 4 52 8 80 6 +2242: 4 559 8 +11592154: 1 89 1 268 1 1 664 490 +16020118: 6 709 400 62 1 56 646 +1299962: 20 47 80 98 27 7 16 4 +295680: 1 3 5 40 52 800 5 8 +10464417: 9 2 6 27 3 3 34 83 +34462664411: 78 5 3 1 5 666 4 38 3 2 +8555: 96 88 59 44 4 +1169280986289: 9 4 35 928 9 86 289 +276164011: 119 444 60 49 14 1 +318180816: 53 6 175 5 814 +2591: 2 5 75 2 58 8 3 +32533493: 6 6 5 7 3 55 9 30 53 3 23 +229398: 266 4 1 45 1 5 9 16 663 +1728893159421: 8 1 28 9 8 566 69 11 1 8 +76054443206: 7 7 1 3 54 28 4 7 8 6 58 7 +35589: 20 57 66 1 7 1 1 14 +1253928: 74 5 65 64 52 +13626929426: 2 90 700 2 147 26 +17809524054: 51 5 1 97 4 5 72 54 +224832107: 93 68 3 8 107 +71645285: 98 143 73 89 5 +1030424: 4 6 5 87 596 4 5 92 7 5 +14471016: 516 57 82 52 6 +172454: 4 9 9 2 266 78 8 +855653: 5 2 82 8 65 287 366 +1226600: 7 37 1 473 5 58 8 7 979 +447240: 3 64 833 8 323 426 +15238243461: 21 7 39 2 69 9 730 2 +1071922335: 7 7 4 3 2 96 116 5 2 5 +229848187: 3 241 942 149 38 +45344183: 3 3 77 42 308 3 651 81 +4901: 888 7 5 2 424 +46609776: 568 1 34 82 589 6 +47824041: 469 33 515 6 108 3 +4985084: 1 912 5 34 2 13 +93130324833: 4 3 8 9 2 71 28 9 2 4 67 3 +149374: 30 1 118 37 4 +1027499: 6 55 3 7 100 248 3 34 1 +1019443816: 5 5 94 393 92 7 892 +148406254: 4 2 397 86 89 +1046424933: 5 48 276 19 5 40 9 837 +789121218468: 394 17 64 3 12 184 68 +24606: 394 61 1 26 531 8 6 +32826875: 5 3 24 35 2 7 449 8 75 +78610925642: 4 61 99 8 7 14 9 256 40 +563129: 19 9 9 1 939 5 501 1 3 2 +1185206173: 469 9 41 824 5 3 2 5 4 9 +88615648: 9 7 3 2 94 806 3 6 9 7 21 +3541: 44 3 74 8 55 +104271660: 3 487 26 633 6 8 15 3 +20881: 32 651 3 2 44 +1876729: 4 168 9 780 748 +28509624384: 996 8 4 286 3 84 +1026553844795: 74 92 52 5 527 4 72 7 5 +29043744111: 6 437 2 2 6 47 8 5 2 9 1 +1722468804: 9 2 4 636 9 6 142 1 866 +270229300: 6 6 890 10 4 3 48 5 92 +3004099: 894 6 28 6 8 2 78 45 +3616992: 3 60 600 8 1 5 51 1 4 9 2 +214643388: 39 55 73 70 388 +914715656: 7 1 20 11 3 352 9 4 8 8 +21106475520: 119 1 213 6 1 130 2 32 +53262303: 68 2 8 5 780 5 +507716: 498 7 81 85 60 45 6 +19438755840: 4 3 6 9 96 28 16 5 558 +684865: 66 7 18 52 71 9 78 5 +50379008: 2 9 8 843 83 261 2 5 6 7 +1751841: 125 36 403 9 3 +411768738: 9 65 20 73 78 92 231 6 +25: 5 8 12 +69387321: 69 3 8 731 8 +74878624: 1 20 379 7 8 1 2 6 7 4 4 +17592: 8 9 5 8 9 +55543298: 7 822 1 9 710 +52244409: 884 985 6 4 5 +27014: 270 1 4 +290549879: 538 3 5 83 360 +57134: 9 693 9 1 79 965 +1602647: 6 9 68 23 7 +2542: 24 47 1 7 88 +1341748: 134 167 7 1 8 +49167143: 3 79 37 108 38 12 336 +1229666510: 17 376 391 45 3 1 4 2 4 +918: 9 1 7 54 +1066482049: 2 2 7 7 6 3 7 53 6 9 535 9 +401582160: 340 7 86 6 327 +11328164873: 3 77 9 1 54 5 7 9 34 2 4 1 +4608: 6 5 719 6 6 78 +523320: 27 6 9 81 602 534 +5810: 8 70 8 84 9 109 +678988872: 9 3 99 4 126 8 56 4 4 9 +3745560: 28 7 546 35 2 +10516660: 3 3 53 9 34 26 3 8 7 70 2 +255469822776: 7 87 7 3 48 79 95 4 3 9 8 +69634: 2 298 5 3 26 74 +16699318278: 9 277 3 99 30 1 6 5 6 5 4 +18603: 69 8 5 3 8 +67053055690: 1 2 515 434 4 1 569 3 +141888: 733 6 1 3 64 +873288345622: 15 161 19 6 6 96 6 2 3 +112480808: 8 15 6 61 8 64 628 1 4 4 +8506730: 69 70 93 658 766 +10772735: 8 3 624 8 26 +29935635: 36 8 22 85 1 5 811 +870: 46 85 22 1 715 +96866: 8 1 260 7 5 2 5 2 1 9 8 7 +21406467537232: 37 24 2 35 5 8 376 482 +24602893: 72 8 2 2 8 8 2 96 3 873 7 +140909724814: 297 27 7 9 158 5 1 1 3 4 +3454011: 575 49 2 3 354 3 +286400393: 706 86 89 57 53 +18063592456: 9 808 6 56 511 767 +27428489: 421 83 2 544 9 +1796674401: 9 11 4 7 6 72 2 326 5 4 9 +337021994: 6 311 29 9 692 2 +7026159: 78 8 53 8 59 6 159 +443282: 382 16 45 1 68 34 7 73 +1046899268800: 466 6 9 779 4 1 7 880 4 +3651: 346 8 7 30 74 +572386770216: 6 8 69 7 7 50 55 6 486 +21346403103: 981 207 3 40 876 57 6 +2463381202: 7 4 6 3 3 8 52 77 55 3 94 +30407481: 9 5 621 318 4 +13515323217: 681 1 592 6 49 33 +1087609539: 332 9 2 90 431 416 +410953440: 9 91 93 5 987 955 485 +171585054: 124 6 72 1 256 174 9 +28973728: 25 3 1 96 5 1 8 6 83 4 7 8 +345430: 60 2 55 269 778 +2723562: 7 1 7 9 5 5 5 2 37 5 8 2 +24545063129: 6 6 3 3 4 2 9 43 20 1 930 +189356832874: 4 836 2 2 3 6 2 786 874 +1664708: 3 1 79 2 2 523 +3234: 566 1 4 9 66 8 879 6 +51568806: 978 8 44 9 4 97 91 8 2 +21978100: 17 65 67 525 4 +516143: 6 309 278 731 +1604981961: 862 1 4 8 5 7 7 6 69 8 4 9 +230: 9 21 2 7 1 31 +29711: 3 981 22 6 55 +7387441984: 52 2 76 2 557 839 +2497700061: 2 7 26 37 81 29 9 +283450487882: 9 446 7 3 5 8 4 9 596 5 6 +4611600047: 823 5 160 35 47 +18762785: 3 101 90 688 60 965 +6039720: 6 4 9 699 1 2 7 1 5 5 25 4 +18778179043: 7 9 81 3 6 8 7 528 3 1 13 +107610050: 8 50 7 4 952 8 13 6 7 3 2 +322506: 930 55 36 95 270 9 9 +112567: 1 3 874 8 8 72 1 2 12 27 +2187945065478: 6 853 342 5 2 6 5 9 6 5 +378542670168571: 94 635 6 67 542 4 571 +95370: 36 20 2 5 66 +60925172439: 572 3 202 5 2 710 19 +1864083431: 11 65 2 8 83 429 +130006538: 3 49 5 50 6 4 1 1 93 45 +45205660: 3 44 5 7 2 98 20 9 6 1 4 +4473939: 5 8 902 6 79 885 9 +9229836: 3 4 6 5 5 811 9 194 80 6 +126846796: 4 1 4 3 783 79 6 +354965538790: 3 48 6 965 5 3 878 1 2 +1523: 8 561 881 2 71 +2911951343: 41 157 34 5 9 1 343 +3411360640: 3 5 1 885 2 103 6 3 641 +8384: 90 5 11 3 8 +58070691758: 9 796 988 626 6 +4606: 38 79 56 669 2 +1855761377: 1 2 4 177 57 6 12 95 82 +8785483574: 6 27 5 2 1 5 53 8 2 82 1 7 +12108: 70 32 969 889 58 6 +14567: 1 6 12 78 7 4 480 237 +150941: 5 7 5 90 941 +786264: 6 788 1 989 396 602 +51732: 39 781 63 2 70 +4021802: 7 718 7 8 6 436 +307443454: 482 30 405 76 6 +6876720: 68 767 1 6 1 +3775473626: 94 38 684 4 26 +477729: 96 211 222 93 7 +186422884169: 1 2 86 92 6 2 8 6 4 16 9 +10320797: 130 8 4 992 29 +5947214674: 5 94 72 146 74 +75017587536: 75 10 1 758 753 6 +87977: 28 7 80 579 93 +595019375: 3 2 736 1 199 7 976 63 +5401506: 68 355 82 223 +423147: 6 7 23 6 2 38 9 +37519365: 9 8 92 5 360 98 5 8 5 +153574577: 86 21 7 172 8 829 670 +749: 292 79 378 +1322409: 397 871 46 8 409 +1616671693: 9 6 3 4 4 43 2 6 9 9 2 469 +8395504261: 2 4 39 542 3 5 4 2 63 +1485870: 6 2 9 8 9 7 35 847 4 722 +1438: 4 13 880 463 3 40 +272444064: 7 3 3 5 33 7 7 2 6 1 944 6 +463128200: 92 625 6 40 5 +17757: 5 62 57 81 7 +223440: 6 94 9 264 3 9 95 2 +17536: 183 3 337 22 8 +159298: 73 85 491 802 5 +7217725681: 3 1 88 3 3 2 94 7 7 40 46 +9102004482: 8 6 20 37 4 99 8 1 143 2 +73: 6 8 11 9 5 +522: 73 14 6 +2317: 3 88 75 6 654 +45537732: 7 1 1 58 95 2 1 5 9 5 2 6 +292143828: 683 6 801 6 89 972 +26166150: 82 7 25 7 6 2 95 8 6 3 75 +524161499002: 73 825 563 24 71 +535311: 89 675 7 90 65 356 +912: 4 6 866 +26016: 796 8 89 47 4 +1953265: 8 8 8 3 5 8 5 64 3 9 7 370 +184602403: 18 10 3 32 62 40 403 +16262943763: 146 8 88 2 90 6 8 29 6 2 +102402849: 328 214 8 39 81 +28237920: 1 5 575 902 14 2 4 267 +823891: 85 2 736 8 94 +146882851: 706 25 9 885 94 919 +5015: 9 1 3 412 71 1 +39960936: 2 5 365 2 85 6 92 184 +149149800: 79 4 7 41 47 860 +245273298: 272 525 6 1 7 7 5 9 +36014801803: 3 5 1 9 2 296 5 180 2 +9268771223: 122 92 8 754 23 +3879: 1 7 5 97 +6366882079: 5 280 25 1 73 5 4 3 2 5 9 +22651880: 4 566 2 2 376 5 +416: 397 2 17 +7522024: 666 3 8 7 7 644 36 76 +12054942: 1 16 48 872 6 125 13 3 +1804617: 8 77 14 505 4 2 16 +4979592: 1 684 479 62 69 +13230: 7 7 5 6 9 +188694006: 260 7 955 1 68 74 +664824301: 76 399 783 4 7 925 +99691298: 7 72 2 989 98 +2957: 40 58 8 516 52 61 +20566962720: 48 3 2 704 221 2 4 6 54 +768427128109: 8 50 10 3 904 810 7 +6527661: 8 36 61 9 1 993 2 9 2 4 +28558016: 237 908 7 738 4 3 17 4 +5416190: 6 9 136 814 7 3 611 4 5 +3058632: 384 4 2 895 7 59 92 +13389382: 8 7 1 2 759 7 295 1 7 2 +162903312071: 6 520 30 6 586 9 55 68 +1105: 4 2 86 1 184 +156: 83 34 5 2 32 +75682: 2 97 759 5 79 +738707: 7 4 7 9 54 916 7 +181872944: 2 6 48 511 3 339 93 9 5 +6916941511: 3 688 6 9 3 83 1 8 24 11 +215342: 3 3 7 2 534 69 1 67 540 +399338: 7 114 8 7 956 +2973648: 9 333 992 84 7 533 +3201299426: 1 2 3 5 1 8 43 2 57 2 3 23 +522701569: 5 22 58 3 9 15 5 2 1 6 8 2 +303731392: 5 1 9 9 930 84 35 63 6 8 +34897940825: 610 13 46 89 44 8 25 +29346: 8 3 49 67 6 +60466566943: 4 6 3 3 3 29 91 68 438 9 +3078173: 276 237 6 164 9 +1526065: 61 5 316 3 2 44 73 +1346: 382 814 9 45 96 +9683184: 9 2 5 537 16 7 7 +47632853: 79 363 25 6 54 +18427387459263: 2 9 42 7 385 2 4 592 62 +72445: 1 1 76 9 93 +354603: 9 3 8 2 29 4 893 975 +30207570456: 21 449 202 83 84 +1601402382: 623 34 56 7 6 47 18 +805: 51 5 618 89 42 +453218: 453 156 52 2 8 +2454691634: 3 7 52 4 58 67 7 16 34 +4249375: 376 8 3 2 5 4 44 8 7 18 4 +11202362: 466 76 1 5 24 +13890175488: 495 575 352 9 778 36 +77784300: 82 512 5 97 15 6 3 +3417: 17 5 91 3 3 2 46 16 2 3 3 +158868604400: 295 538 158 604 400 +14794788: 7 3 3 10 469 72 734 6 +496329: 55 9 51 2 1 90 726 +49702: 5 967 66 69 2 +5820848128: 65 789 227 5 1 8 611 +9911: 900 9 905 +2116507855: 939 7 7 46 926 920 9 +678377763: 7 35 8 866 57 3 8 1 9 6 1 +15252661: 8 7 25 265 8 +432963: 6 1 16 8 1 9 4 395 8 1 4 7 +462883134: 2 314 4 1 5 5 4 9 5 5 989 +20394944733: 2 40 259 72 280 1 93 +25449007500: 56 3 875 82 630 +673: 4 6 6 9 98 35 +433234809674: 481 369 3 45 2 962 5 4 +2231307: 932 1 1 5 239 +5496: 421 29 8 1 1 12 +361056486: 95 38 527 33 4 86 +14832: 2 119 7 +55377: 355 66 256 9 58 2 9 +3672207430366: 64 290 1 229 9 7 33 96 +924506: 8 1 8 7 7 307 4 825 72 7 +585727992: 406 75 29 24 2 5 72 +4464: 4 3 50 9 8 +969362: 2 30 8 420 +91356570230: 3 6 6 34 2 9 92 9 3 6 2 28 +21019: 41 38 543 7 +24076855887: 481 53 2 3 2 1 17 7 5 2 +5655436: 4 1 5 666 6 62 8 5 22 3 3 +2196815: 6 1 6 6 742 76 +197984593: 394 39 502 4 806 +225: 7 3 3 1 9 +54870: 914 4 1 6 +966: 25 9 641 93 7 +37809635: 53 269 851 87 321 2 3 +3735230: 18 717 5 43 1 36 995 +514763246: 3 8 21 10 76 3 23 1 7 1 9 +203727: 7 6 82 79 720 9 +17269915: 8 7 15 4 4 2 95 6 69 2 65 +10989115532: 7 8 1 650 6 4 6 2 3 11 3 5 +42746579602: 70 422 7 607 2 86 414 +128541973: 67 37 954 2 1 4 +2255236: 5 80 424 931 61 5 +335089472: 6 10 5 904 5 6 68 478 +342735588: 17 14 40 433 36 +9159: 9 21 35 27 5 384 +955712: 6 199 64 8 +429600: 1 96 52 29 4 100 +16629466: 870 9 41 38 70 4 46 7 1 +428326080: 2 8 6 715 4 6 2 6 4 65 6 +11696320: 36 547 4 40 8 +3480960: 60 14 8 74 7 +9707101: 995 6 975 +1408: 2 510 386 +82190387178: 821 871 32 8 7 1 81 +3057975750: 765 3 47 3 7 9 8 8 4 5 5 6 +1089290533: 3 4 3 5 1 603 7 69 533 +4645808: 451 2 133 771 37 +1875141773: 24 353 997 74 34 6 3 5 +1485138665414: 3 99 28 74 6 95 47 414 +37584: 87 9 6 8 +54241847: 3 530 6 7 341 +831532886240: 7 3 8 3 525 1 827 140 8 +2269440: 34 64 2 97 15 768 +3335: 5 3 8 6 92 24 3 640 +1607: 9 5 1 35 +926184: 88 19 82 7 7 84 +211117960879: 9 5 8 20 866 7 67 691 7 +9035504: 8 36 1 7 193 2 8 +1081599840165: 4 7 30 8 782 9 34 33 5 +1193940730: 958 47 18 66 7 30 +655320: 6 551 71 9 28 94 17 +2132901: 8 6 2 3 9 6 9 3 7 10 277 7 +6688892: 1 667 88 83 3 6 +5173437: 14 87 8 35 64 +29980: 23 13 54 26 +78634578: 65 55 8 3 34 6 803 +51202768: 420 4 2 878 2 359 409 +329599694594: 533 1 258 84 32 23 +419178834: 4 41 5 2 9 2 8 1 2 5 9 246 +203412475243: 4 168 6 5 2 6 47 4 5 7 4 1 +27075: 7 2 1 3 62 852 +416831779: 8 533 5 399 91 7 7 +3976787: 52 2 9 7 865 9 +240484: 70 1 885 5 48 8 2 1 236 +1959168: 573 4 2 4 223 9 3 8 4 8 3 +13400405953: 7 403 5 392 181 +54686971: 6 6 3 12 1 9 479 3 559 1 +15780086: 8 2 4 24 4 8 9 2 94 8 80 4 +5328139588: 877 15 9 50 9 7 1 9 6 13 +103650: 7 9 9 6 3 4 14 2 51 984 6 +1132504: 3 47 906 5 5 4 +1325436: 64 445 1 4 651 +522368033: 985 59 53 53 36 +17934048: 5 4 6 748 74 +32923: 8 80 5 92 3 +1684403: 68 375 9 66 64 2 734 9 +111745: 89 91 7 88 411 2 452 +13263230: 163 3 131 62 4 +3868986962: 6 42 362 167 98 72 8 5 +11345670: 3 43 145 63 27 +319239004896: 50 6 72 85 768 16 8 63 +3034544540: 3 5 867 4 33 12 4 3 +40627: 4 51 4 9 +47169937111206: 47 1 69 937 111 208 +112164822847: 5 804 2 7 7 66 3 84 5 2 1 +5803503559: 7 7 904 7 6 868 88 2 6 +11634120945: 947 6 29 4 306 943 +34851742: 913 7 9 3 63 55 98 +6297303600: 8 72 2 2 653 5 4 6 5 490 +9669310775124: 869 94 1 629 308 611 +4741903666: 6 1 9 6 182 6 77 1 6 4 2 6 +1410872158446: 7 5 271 80 3 958 7 4 98 +343116238185: 10 359 7 898 36 92 9 +400086541453: 837 478 54 1 453 +6515098: 63 25 7 270 254 +348: 30 4 6 +239609608: 1 1 6 19 5 33 607 28 53 +7414288540: 49 42 859 3 5 4 10 +96771: 6 200 1 8 43 1 37 56 3 +1894118717: 281 674 2 176 68 3 7 +6310857469: 80 8 6 160 6 3 5 11 7 6 9 +6182479: 6 72 92 77 2 +1032: 925 2 57 48 1 +1091687: 8 8 2 736 2 6 915 2 999 +543443: 92 1 59 3 49 +165718061: 2 7 6 22 24 445 5 6 5 +610745: 754 9 9 1 5 +5361319385: 8 8 2 3 777 193 76 9 +6159: 191 1 4 907 61 5 339 +493628437516: 7 421 75 9 5 9 3 7 1 886 +15757062: 104 293 147 2 9 9 3 51 +11216: 79 480 142 2 8 +6822: 23 13 3 7 543 +3388859842: 5 8 555 43 87 25 170 +8334: 25 77 9 75 9 +2250866676: 8 7 29 9 3 9 42 5 7 86 7 4 +89826408460: 4 411 863 36 6 457 +153485: 23 922 642 7 437 112 +36262905: 3 4 4 61 2 571 1 5 13 5 5 +22502497: 970 280 2 9 2 498 +2331369: 84 70 3 5 900 5 734 27 +22804091: 54 711 60 593 869 +24912366556: 76 4 88 3 700 607 7 44 +781102: 324 8 7 20 39 24 +341021: 41 9 881 3 51 46 118 1 +125012160: 48 14 56 952 36 45 2 +8601135: 928 45 3 6 9 20 971 17 +580850: 29 5 40 96 712 44 +26137464000: 61 1 95 10 860 4 129 +86455555: 868 9 199 1 5 +353502837: 5 11 261 66 969 86 9 +1766966: 243 665 65 2 908 +40398720: 8 59 727 795 64 +15777929: 1 36 6 6 886 8 6 35 +26640: 12 14 9 26 7 52 2 7 7 1 9 +6825793: 8 245 8 578 6 2 4 759 4 +7785132: 64 310 18 2 7 7 8 9 3 +5165452178: 239 350 658 34 633 +41027: 607 6 4 50 406 7 +109810788: 3 1 6 860 2 4 9 95 7 1 1 3 +3302: 87 63 8 60 27 226 7 5 +9182593: 1 5 274 62 98 2 9 2 5 73 +111608008784: 5 9 702 6 213 8 6 3 688 +82474315: 4 407 77 8 591 20 51 7 +3266534: 4 211 645 9 27 6 6 2 +235297: 806 22 7 5 5 8 7 26 71 +2902992: 12 32 5 8 67 1 36 38 8 +757673: 39 75 7 37 98 +5392: 852 6 13 26 241 +30316819: 606 5 1 15 799 21 +84160936096: 8 9 153 530 4 944 +18573: 2 2 9 7 72 29 397 3 +3400587: 339 9 6 9 88 +59117080933: 6 58 4 707 23 7 3 8 5 8 1 +709244949: 7 164 99 8 7 6 8 5 5 8 +256666: 631 3 4 3 380 5 30 278 +149736926: 594 4 77 5 3 21 6 96 2 +51400927: 8 69 782 45 853 +24013402569: 7 9 3 614 54 584 98 9 +41468325: 2 74 88 3 8 15 382 769 +80871091: 36 3 720 1 18 25 1 2 8 3 +437200704: 4 10 7 860 4 131 5 49 +52531364: 52 53 136 5 2 1 +1159045536329: 60 1 95 2 276 79 2 5 29 +30401139: 3 36 415 44 92 1 5 654 +855593039661: 7 8 4 7 1 3 6 328 2 6 2 66 +19362670: 1 314 442 87 98 3 124 +9366020992: 124 88 15 31 5 8 541 2 +79281216: 411 66 28 742 8 +2185054238: 79 63 8 343 2 61 7 40 +53587566: 6 918 47 69 78 3 +356106996: 4 5 8 7 96 92 9 175 7 7 4 +5372: 71 8 68 +42886097: 561 8 78 6 67 140 737 +2103466457: 4 72 14 60 9 73 +724634064: 8 2 2 599 2 8 6 4 26 2 72 +8940017483: 73 575 5 39 9 135 98 +734376: 2 4 62 455 888 +54967: 24 21 7 8 214 86 787 +25455: 2 3 8 467 8 925 3 3 3 2 3 +1706: 792 13 901 +16791586: 6 3 582 4 4 27 26 9 75 +1710311: 85 9 85 4 13 92 8 98 2 +178: 90 81 7 +2750345348: 5 7 298 853 8 4 4 3 2 3 2 +14913758: 9 271 33 16 264 9 58 1 +26509773: 4 6 104 10 192 13 771 +317152: 4 8 13 8 748 +54215093: 541 1 150 92 1 +14652360: 24 4 2 6 1 297 61 2 +147456741: 46 37 318 72 68 +135995340: 755 18 9 530 2 38 +5483610: 41 568 288 2 9 +265251335: 7 7 9 9 7 3 34 64 2 4 3 5 +444155: 38 74 566 78 75 +126994861: 23 4 157 3 17 4 861 +5528579: 6 5 3 8 8 1 3 7 7 7 34 624 +2198016422: 646 2 1 8 424 424 +16522: 5 7 9 9 51 +159183412: 320 141 392 9 52 +650538326: 6 46 7 1 26 8 4 3 824 8 6 +77169: 237 65 8 7 5 69 +49257063: 584 1 842 56 7 +51989200: 553 94 6 9 56 4 10 4 56 +636276292: 357 69 1 7 9 9 41 +5011587678720: 51 320 643 32 7 678 +62832226: 9 87 2 6 35 364 3 226 +324973544: 1 4 6 9 54 9 735 44 +43107424: 6 62 423 63 93 4 +1329: 3 7 11 1 921 +8127180: 4 5 2 35 1 5 9 43 55 5 3 +1646401: 6 276 1 7 2 1 7 6 8 800 1 +15569384: 37 40 4 763 1 597 787 +553222: 2 78 2 5 349 57 +667200: 91 610 24 66 12 +516301112: 573 630 6 365 9 1 721 +1375256534: 764 9 28 267 2 +24960320: 229 2 5 23 494 14 40 4 +54337879040: 7 2 37 3 3 37 878 98 5 7 +194164: 57 85 4 6 30 4 +214404579: 127 55 5 7 877 4 +91527: 3 6 73 5 2 7 +2551884: 287 616 314 9 6 +48941720325: 6 7 9 74 6 40 4 6 2 9 2 9 +9203: 16 575 5 +14256435294: 348 5 681 409 4 +3318458: 83 563 71 697 2 +36500: 52 7 32 6 62 +16233851004: 143 9 4 6 4 18 157 2 7 +130073: 73 9 22 8 9 +41452: 7 1 7 7 893 8 8 4 4 6 54 +29730573: 81 4 8 6 6 5 82 6 509 73 +451552: 27 147 928 2 2 292 8 +3607962: 5 67 97 3 6 37 1 784 8 3 +26553: 9 4 8 5 5 3 4 653 4 6 33 +99871: 3 26 67 3 871 +7974822: 79 7 431 6 506 +1065219: 42 1 44 12 48 771 +5804229: 602 964 37 58 1 +583501: 1 53 20 3 8 19 8 +8588035: 8 1 556 80 38 1 6 5 +2580648233: 9 7 2 8 1 6 727 8 6 9 9 69 +4013: 8 7 47 541 177 657 3 +4153099: 3 4 4 2 3 1 15 3 6 3 615 4 +232804: 539 972 51 533 5 3 7 +2309375607: 68 6 3 1 5 74 7 195 1 8 +769560: 3 90 7 40 458 8 1 6 2 8 4 +1016784: 78 7 6 6 307 +1178617147: 864 3 489 278 3 5 +38149143: 6 69 282 57 69 +665229: 98 7 5 67 9 580 +4130590464: 406 987 78 33 192 6 +447: 4 86 357 +3914899837: 4 2 156 4 4 66 3 1 1 3 1 6 +56259883189: 3 48 8 2 6 92 2 2 7 28 6 9 +2622: 12 7 4 2 74 +194536: 97 268 2 +31098614: 921 6 97 72 8 78 3 58 +948415: 4 4 8 8 96 8 527 67 2 4 5 +2672: 752 90 680 554 596 +476795: 45 8 6 6 9 6 4 6 5 9 4 412 +20759512: 2 6 8 8 4 938 8 869 840 +88817568: 97 6 7 6 2 668 9 6 1 8 12 +670085900344: 351 76 350 7 8 1 4 49 4 +755086: 4 3 7 840 59 730 9 2 4 +432946594: 432 946 1 49 396 46 +620888945040: 79 8 6 3 49 7 510 4 91 6 +9711: 856 9 839 168 135 +194558935285: 2 2 772 237 63 4 285 +758: 7 750 2 +6280922826: 4 32 9 3 3 7 6 5 7 81 9 +138895: 8 322 4 68 95 +1025917474: 6 30 395 917 47 4 +164811353: 4 3 67 35 66 1 356 +75636042382: 9 950 7 38 88 42 379 6 +3167998: 619 12 29 960 5 +1481204467: 5 2 5 8 4 175 2 4 38 8 8 1 +9923388: 2 515 47 23 8 51 12 +541863871: 541 86 38 7 2 +56829631: 3 5 7 676 9 144 632 1 1 +3465276611: 5 5 2 9 21 11 25 1 613 +10455518: 2 9 163 4 221 8 +45296160: 99 681 3 3 7 85 6 7 16 +142800: 8 6 7 34 2 971 1 8 5 50 +91872: 30 3 30 498 24 +55018317: 16 95 832 472 39 546 +4901324998: 919 5 77 83 53 8 \ No newline at end of file diff --git a/2024/day07/input_test b/2024/day07/input_test new file mode 100644 index 0000000..87b8b25 --- /dev/null +++ b/2024/day07/input_test @@ -0,0 +1,9 @@ +190: 10 19 +3267: 81 40 27 +83: 17 5 +156: 15 6 +7290: 6 8 6 15 +161011: 16 10 13 +192: 17 8 14 +21037: 9 7 18 13 +292: 11 6 16 20 \ No newline at end of file diff --git a/2024/day07/solve.py b/2024/day07/solve.py new file mode 100644 index 0000000..4737c9c --- /dev/null +++ b/2024/day07/solve.py @@ -0,0 +1,38 @@ +def is_valid_entry(ent: tuple[int, list[int]], current_result: int = 0, current_index: int = 0) -> bool: + if current_index == 0: + current_result += ent[1][current_index] + return is_valid_entry(ent, current_result, current_index + 1) + + if current_index >= len(ent[1]): + if current_result == ent[0]: + return True + return False + + new_result = current_result + ent[1][current_index] + + if new_result <= ent[0]: + if is_valid_entry(ent, new_result, current_index + 1): + return True + + new_result = current_result * ent[1][current_index] + + if new_result <= ent[0]: + if is_valid_entry(ent, new_result, current_index + 1): + return True + + return False + +entries = [] + +with open("input") as f: + for line in f: + line = line.strip() + split = line.split(": ") + entries.append((int(split[0]), [int(elem) for elem in split[1].split(" ")])) + +result = 0 +for entry in entries: + if is_valid_entry(entry): + result += entry[0] + +print(result) \ No newline at end of file diff --git a/2024/day07/solve2.py b/2024/day07/solve2.py new file mode 100644 index 0000000..f508ad9 --- /dev/null +++ b/2024/day07/solve2.py @@ -0,0 +1,44 @@ +def is_valid_entry(ent: tuple[int, list[int]], current_result: int = 0, current_index: int = 0) -> bool: + if current_index == 0: + current_result += ent[1][current_index] + return is_valid_entry(ent, current_result, current_index + 1) + + if current_index >= len(ent[1]): + if current_result == ent[0]: + return True + return False + + new_result = current_result + ent[1][current_index] + + if new_result <= ent[0]: + if is_valid_entry(ent, new_result, current_index + 1): + return True + + new_result = current_result * ent[1][current_index] + + if new_result <= ent[0]: + if is_valid_entry(ent, new_result, current_index + 1): + return True + + new_result = int(f"{current_result}{ent[1][current_index]}") + + if new_result <= ent[0]: + if is_valid_entry(ent, new_result, current_index + 1): + return True + + return False + +entries = [] + +with open("input") as f: + for line in f: + line = line.strip() + split = line.split(": ") + entries.append((int(split[0]), [int(elem) for elem in split[1].split(" ")])) + +result = 0 +for entry in entries: + if is_valid_entry(entry): + result += entry[0] + +print(result) \ No newline at end of file -- cgit v1.2.3-70-g09d2