main
Brett 2024-12-07 17:31:41 -05:00
parent 1d116e7c15
commit 0b080eacb4
8 changed files with 1098 additions and 1 deletions

View File

@ -3,5 +3,6 @@
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/lib/blt" vcs="Git" />
<mapping directory="$PROJECT_DIR$/lib/blt/libraries/parallel-hashmap" vcs="Git" />
</component>
</project>

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(Advent-Of-Code-2024 VERSION 0.0.5)
project(Advent-Of-Code-2024 VERSION 0.0.6)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

24
include/day8.h Normal file
View File

@ -0,0 +1,24 @@
#pragma once
/*
* Copyright (C) 2024 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DAY8_H
#define DAY8_H
void run_day8();
#endif //DAY8_H

9
problems/day7/example Normal file
View File

@ -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

850
problems/day7/input Normal file
View File

@ -0,0 +1,850 @@
37603097701038: 475 8 68 9 9 5 878 38 3
740556: 418 9 4 4 3 1 9 7 5 12 9
41216: 2 8 8 46 7
30984320: 1 928 416 840 80
31422162: 619 401 2 70 44
6593961: 94 19 9 4 7
243973: 7 230 6 97 3
553110: 5 6 1 49 7 1 13
569: 567 1 2
26339: 928 66 19 26
126563: 12 2 9 56 4
909583: 92 5 38 59 89 5
1870: 1 477 993 98 302
716: 5 72 58 382 1 17 181
59398283: 75 1 877 79
8974471341: 9 860 8 3 99 8 552 9 61
1547232: 83 266 70 950 822
38491788: 4 3 18 4 81 4 5 2 2 23 89
1802: 5 30 71 17
21013: 42 236 2 8 8 337 836
66233: 3 7 22 8 3 67 9 9 2 947
127085000539: 488 6 31 7 7 80 2 5 6 5 9
251952544: 223 407 347 8 8
2276: 6 6 48 6 542
20875394922: 6 7 379 9 49 9 52 7 4 1 4
465821964765: 83 413 37 153 365
75412: 19 49 81
94979304: 7 6 19 424 4 72 7
8497104: 13 9 8 77 627
24090419534: 66 730 839 5 36
3476088918: 693 19 66 4 918
1726268485: 42 10 85 8 603 1 87
2129276: 95 70 2 40 79 8 4
26374687: 17 9 37 468 9
3488425625: 45 66 764 655 44 926
558272: 68 1 755 29 8
2141581321406: 7 3 49 65 73 383 82
539432: 2 9 8 9 45 5 3 4 8 7 5 8
1143072190: 37 5 21 54 24 190
5907370: 1 71 16 19 166 3 936 3
983687: 538 676 4 81 23
87247: 80 4 7 6 5 5 6 3 4 12 868
275131752: 9 6 2 5 2 5 9 5 773 97 2 9
55114: 104 21 437 445 44
195608254: 313 977 623 579 4
35682: 3 551 8 3 88
18577: 1 81 8 3 393
847228: 5 43 8 16 7 8 7 1 9 8 4
2004290: 84 71 336 7 379
104188904: 1 888 74 4 4 6 3 749 4 2
2545518: 9 63 4 743 6
27748: 76 201 35 2 9
118738267: 92 117 568 3 23 267 1
53889338763: 893 679 8 21 603
617456785968: 892 57 59 7 2 8 1 759
83155248103: 41 91 8 76 22 9 103
63221: 8 79 2 1 1
10592961: 6 25 3 6 2 8 8 7 7 6 7 638
714288: 9 63 7 8 9 5 5 6 9 5 6 48
4938839: 63 8 422 883 6
189: 9 2 6
36109644495: 8 9 54 6 6 39 1 9 7 7 1 15
258032985: 314 30 824 8 985
242881: 2 7 42 879 57 6 23 8
3193460: 6 76 7 1 458
5881: 4 9 39 945
102489030: 633 45 7 1 514
3157446: 203 717 2 343 832 2 3
399084: 24 80 1 38 83
1995: 8 990 77 900 20
118513013: 592 5 1 65 2 10
63992498039: 1 1 97 507 710 324
181580636835: 158 4 7 81 6 898 2 8 3 3
78363207: 17 5 9 8 7 29 8 695 20 7
1999465200: 31 7 38 8 6 796 883 5 9
928316: 5 491 1 2 169
33984349: 3 177 64 347
154485816: 935 2 557 296 752
563402503: 5 203 413 7 23 6 32 5 2
2059683822300: 8 27 99 56 4 57 85 5 71
849046464: 2 494 14 931 2 8 76 14
8565: 33 81 6 6 233 9 9 177
104340802: 7 162 13 7 2 4 46 7 2 4 3
186: 2 83 40 61 1
12429168: 8 6 8 1 9 87 7 6 484 2 8 3
6087: 2 3 70 80 7
38059: 7 3 22 65 9 71
251: 7 14 55 4 171
210495791: 22 3 61 6 82 989 799 3
26632279216: 6 260 2 3 7 2 2 7 92 16
2460016: 788 15 7 26 8
2868334: 842 5 2 605 316 2
769280: 89 17 3 877 7 640
1139092122: 825 428 8 138 379
1401727: 2 7 72 721 100
455284: 35 9 287 228 579 4 83
47583019515: 661 214 580 39 4 719
34664783: 1 7 46 62 269 79 69 83
89259783411: 7 973 286 9 656 213 9
2885334: 7 2 2 852 8 5 5
3135979: 3 2 329 97 66
13967912759692: 2 28 5 7 7 873 59 684 8
4872: 2 9 5 397 1
658438564: 5 331 2 442 9 6
3967765560000: 2 2 72 5 825 978 683 5
136674769: 615 751 747 64 5
4708288121: 6 28 7 682 39 268 64 4
50061: 42 65 467 92
18311082920: 85 3 9 963 3 797 365 8
98238: 3 80 5 7 57 263 4 970
1258: 84 527 1 8 609 28
13675051737: 2 6 1 767 883 5 6 7 7 20
1756359: 862 26 38 9 5 506 339
2978631: 6 496 2 5 33 98
596544400: 932 1 64 400
14367: 14 532 26 170 1
311784916: 7 9 1 953 9 3 6 752 8 38
29928: 6 7 179 3 1 727 684 8
259603: 64 1 9 3 15
10808: 607 594 9
85669: 85 595 74 1
216444: 47 7 48 7 2 9 557 9 7 68
547308919: 9 89 7 7 61 79
1213981: 8 671 14 5 33
981706: 6 5 948 3 639 67
208398892192: 645 457 101 5 313 7
1617480: 7 4 91 4 4 979 3 2 85 9 8
631844: 6 222 1 96 44
506927: 3 21 6 3 759 609 851
22395638525919: 87 41 4 670 28 7 6 3 61
273672: 4 6 40 3 1 4 14 2 7 2 3 3
1029600: 427 54 2 27 657 22
139971080613: 6 614 31 6 7 3 78 29 9 2
66750: 205 2 2 4 6 529 34 1 5 6
450445574: 80 65 9 6 49 866 6
654192369: 23 8 8 354 369
17406970833: 2 967 9 970 830
46004805786: 3 71 255 847 786
124437: 1 16 8 392 42
770782189: 185 66 97 59 40 7 9
507937531: 108 771 610 1 273 1
1244437447: 976 7 715 227 177 4
251993780: 640 5 6 5 78 22 7 5 1 5 5
740: 7 7 7 586 70
142560703: 6 7 673 140 6 27 703 3
89571802: 19 90 627 8 9 347 98
60779110: 5 45 755 1 805 2
54569648: 517 81 35 912 89 39
2516469736: 83 585 297 3 97 39
6206: 72 81 34 106 234
1278426433: 9 3 93 2 1 20 6 8 95 2 6 4
5617427760: 219 9 46 7 2 413 9 3 8 3
97483: 9 5 5 6 422
1049473: 68 9 19 896 3 18 5 5
2947566: 8 245 653 94 3 4 93 9
47057186926: 89 1 576 56 737 1 525
34105869: 6 8 718 3 1 67 7
47313281: 751 63 2 80
11539723: 1 5 6 6 7 7 2 3 44 9 271 6
81484356: 19 967 887 5 59 42
487: 3 1 86
163215: 6 6 23 9 65 3
2336694416127: 33 33 5 1 34 8 801 8 7
422604: 8 13 6 36 86
2977: 513 682 2 2 585
20180160050: 3 887 8 20 5 65 792 50
1713136422449: 5 9 284 24 7 6 71 3 1 5 1
287779207: 2 6 6 5 5 1 27 4 887 4 9 2
273295994: 2 3 7 6 6 8 4 39 89 1 9 4
3771666: 30 290 3 392 9 4 833 6
9701916: 936 446 7 2 25 91 6
48057093: 6 6 5 7 9 8 901 1 2 1 3 27
54526042364: 871 626 14 423 64
22942522: 120 1 3 89 189
735564172: 74 497 4 711 5 51 566
477307200: 4 358 1 823 405 82 38
763004189: 876 871 8 177 7 5
287175471: 66 87 1 8 6 5 5 469
1203504640: 4 5 13 4 6 2 8 754 4 580
17175078: 575 4 8 42 29 5 84 6 3
21417984334: 2 880 704 83 36 16 8 2
3648203204979: 7 40 986 640 99 6 5
3406125185: 3 5 666 225 5 177 5
26123: 31 841 52
129910763: 8 9 7 7 27 8 2 386 147
9414082548: 816 170 8 3 290 6 78
10673869261: 1 8 55 9 67 5 84 94 2 58
12815684528: 9 432 3 4 941 57 38 8
4326214: 109 6 9 735 4
15353686864: 65 60 830 5 4 41 3 38 8
4348775: 1 6 9 171 973 726 7 5
1678996509: 1 9 10 98 1 7 3 8 8 7 2 8
45121182448: 3 9 8 47 11 81 72 2 726
6243842: 5 84 7 41 94 1 5 9 16 4 1
85614: 9 271 4 76 494
1099842: 1 225 6 4 72 8 8 5 2 6 2 4
10402268: 9 24 7 4 35 1 6 8 1 2 6 67
1205494673459: 287 7 6 946 7 28 6 57 2
20555736: 205 5 551 4 214 8
7792509: 8 13 427 83 287 153 3
8654: 2 6 77 776 6
9673586: 7 4 7 106 507 2 4
688051: 6 1 10 5 40 21 91
1740: 7 1 1 6 7 293 19 6 7 5 7 8
21242520: 4 74 85 36 89
219447: 298 4 7 196 95
2961: 9 8 12 3 367 2
4927: 2 2 3 6 30
24224396146: 8 7 3 6 1 2 814 1 8 19 4
8362755197: 46 787 4 231 7 97
37314475: 8 939 9 3 417 26 38
391982515: 621 1 5 90 625 7 18
89882: 7 1 110 3 8 88 90 7 7 12
312984957: 64 4 6 81 957
138666177: 430 5 7 9 3 8 7 5 4 27 6 9
14273765439120: 26 93 16 3 2 904 530
896184254: 234 3 3 24 1 9 6 59 2 7 2
24882719: 9 4 7 678 2 9 5 4
54833: 6 56 1 1 4 295 1 2 9 5 1
2430: 73 2 5 1 29 9 4 5 9 46 3 5
20943029: 812 798 1 130 29
274065120: 7 452 5 9 2 4 9 19 7 6 3
121510368003: 950 2 1 8 333 724 75 7
9212: 1 16 24 53 98
9280: 394 908 7 4 7 89
2934360: 529 89 5 4 5 936
37786777: 9 996 5 378 7
3831853409: 53 2 602 231 501
1408419: 66 475 867 3 55 66
9067258: 13 69 8 672 56
62112: 877 364 5 6 4
8366650: 81 4 6 93 18 706 42 25
213922985: 1 213 8 8 2 33 7 908 78
32924: 7 7 3 4 6 6 8 6 9 26 3 63
5431235659165: 9 126 9 4 551 3 9 7 1 6 7
5848713: 8 9 243 8 9 4 963 39 1
1050230513: 58 4 9 7 8 7 5 97 6 5 510
2329854: 7 1 76 618 3
5457846: 58 941 46
10169595: 8 9 63 90 93 5 9
7421390633: 7 8 4 3 2 5 58 163 6 3 6
1301820: 7 50 61 526 729 4 51 6
4847040: 3 1 46 3 861 4 73 45 99
371: 35 2 4
1430550: 5 632 19 75 6
52933: 31 849 2 58 237
15162724: 5 30 42 120 724
144936079: 554 358 3 9 2 66 4 7 6 6
648438787: 9 132 3 74 64 5 7 89
9864016101: 56 244 8 411 1 610 4
676: 28 252 384 3 9
1583868: 769 9 3 26 78
11740100: 8 92 15 84 190 74
473103946: 9 4 3 6 2 4 8 7 19 7 2 6
9475255: 80 7 3 23 931 9 698 2
505930647771: 506 43 37 3 78 641 9 9
52650: 8 2 8 398 47
58731726417993: 774 39 9 482 256 1 76
1663101: 664 55 57 25 303
6854898026: 9 4 265 2 35 7 1 88 5 8 2
153166816600: 661 2 80 4 114 3 254
10598822214: 123 241 86 96 21 4
112042247: 9 53 2 59 5 822 182 5 2
1243387: 24 7 96 8 400 5 69 4 2
124759377: 43 509 6 1 57
38893544531: 1 403 46 964 531
14511588: 87 7 220 4 688 97 7
480984: 26 5 66 9 56
3781: 373 1 7 40 2
23158570: 21 86 2 4 2 4 6 9 9 5 3 42
81019026: 8 1 64 21 7 98 4 9 4 8 4
525347: 83 298 575 18 8 49 67
42549020330: 8 61 5 773 9 94 88 58
3462694879: 66 32 9 25 9 35 4 879
26562: 9 968 59 83 3
53984698740: 642 666 8 985 84
98180544: 8 2 57 99 8 7 704 1 3
19918182142: 12 5 84 3 2 654 38 8 7
57543: 7 4 345 5 6 9 1 5 4 91 6 3
1345805820: 248 525 692 6 3 540
10814889802: 453 7 2 8 4 47 52 506 1
560553237303: 9 7 8 2 34 9 514 5 3 9 3 6
4437504: 87 340 85 9 963
4927446: 47 2 2 31 43 4 9
659489040: 929 1 8 90 21 6 62
3008413: 4 746 6 18 413
1124820843: 182 309 3 20 843
4075: 838 103 4 14 300
684608048: 68 407 52 89 1 913 8
880277366978: 4 6 372 48 49 577 744
28111: 863 228 307 4 5 55 96
16971984: 4 969 5 52 13 9 479 68
6464949128: 1 62 78 4 9 7 912 97 1 8
1094383: 66 81 51 933 7 9 4
268414693: 7 480 9 78 46
64034145: 600 40 29 5 142
89859376: 375 9 52 75 45
1046447: 5 7 2 83 225 51 4 443
64317982651: 568 75 1 7 98 2 6 38 13
2354004228: 37 664 625 42 26
15413: 10 6 51 7 3 5 63
36924578416: 7 4 575 63 958 32 38
465142300: 6 7 62 18 2 90 1 9 343 1
18637559: 8 525 874 96 9 4
264492561: 9 1 8 59 81 880 62 9 5
1258416719: 277 649 81 7 7
151604409383: 846 64 43 4 769 7
128748146: 12 7 615 362 771 146
2408916193: 209 4 90 89 2 106 8 59
3356801: 5 92 3 7 27 9 9 9 2 54
44008246: 79 8 9 89 3 5 5 8 172 71
1492088700814: 3 70 7 4 8 2 54 1 7 8 72
300857: 6 50 846 9 1
8208920665: 817 7 31 920 667
141351643884: 9 312 38 321 361 86
1788474226065: 9 1 2 4 858 4 6 5 7 4 7 67
12673536: 7 87 1 14 2 10 464 74
21467: 7 3 4 58 9
47473193045: 99 7 4 248 7 3 2 9 3 8 1 2
5203644: 8 4 1 43 645
1792: 957 407 431
80997710: 4 1 804 972 5 12
150420428: 2 6 9 7 310 6 4 4 5 42 4 1
71077: 57 6 9 6 4 9 2 8 2 6 3 151
16445351847828: 3 945 405 491 58 28
36680: 4 93 4 7 6 7 7 8
368128: 35 8 7 916 128
101: 3 24 73 1
215118528: 2 37 51 57 525
64879: 72 9 76 1 2
229680: 2 4 9 7 2 1 3 542 9 9 4 6
10111024: 1 298 7 141 318 566 7
3018508441: 766 394 46 8 437 4
2076138: 11 8 93 83 13 8
324945234: 3 112 971 485 6 1 5 78
81794142: 67 5 730 15 94 140
49254556: 50 794 21 1 4 310 516
406347900: 7 573 49 70 70
66243: 7 629 1 1 83 21 159 1 3
40008300: 473 74 33 60 5 38 6
72557: 42 343 88 1 4 9 3 5
236186: 2 68 3 6 747 7 4 6 3 1 96
151514: 3 9 7 2 8 823 9 4 1 34 5 7
82128: 31 214 91 9 3 2 118
1765: 710 4 63 44 944
21945072619: 8 6 171 45 5 2 726 1 6
4593: 60 2 64 333 4
3162994299: 6 5 17 34 33 133 757 1
335361557: 4 693 7 86 855 8 79
60319234: 87 4 6 759 5 4 67 9 629
79048669: 9 65 539 472 149
154860670: 82 9 911 89 670
1388465631: 9 8 541 6 8 99 5 3 837 3
26640: 8 90 37
48719682: 7 69 4 19 608 75
5987936160: 5 903 742 791 2 6 80 3
11084975: 283 69 518 7 79 90
4182077: 91 4 846 6 64 9 317
21220: 21 15 4 66
25149: 6 419 9
11268670235: 5 509 291 34 85 179
27315960: 39 521 90 29 3 1 86 42
141950: 4 727 6 28 5
13721861: 48 62 7 46 60
64328731: 4 60 6 9 14 7 37 190 3 1
1256: 2 4 9 6 7 2 1 9 2 4 906 1
5571225774: 4 6 8 5 1 4 6 2 7 99 771
46797: 6 461 12 84 2
25749: 1 2 3 9 476 2 1 8 2 16 9 7
1389333440: 29 14 137 8 88 335
20385: 8 57 66 376 4 993 728
97308: 6 2 6 89 1 7 4 36 35 7 9 2
621911: 8 183 76
136033580: 7 9 8 9 98 1 5 7 88 7 90 2
28209153538: 559 9 5 3 623 6 3 3 8 19
1526266: 3 7 381 4 8 2 8 3 8 9 8 69
885432740: 8 768 3 859 1 270 3 37
13637160: 9 9 5 5 4 1 1 6 1 7 9 915
1335398477: 38 915 856 14 72 5
237006: 23 64 34 1 32 55 189 6
1510: 6 2 66 8 919
3766: 20 1 20 51 8
2123684: 9 820 7 8 7 29 9 6 86
11448746: 4 4 81 882 890 9 2 20 6
242182: 34 8 697 99 289
14229563: 9 8 728 80 7 43 86 2 3
1045642353: 4 660 503 8 396
22243681: 5 4 322 9 3 1 7 63 5 2 9 1
185742: 652 46 871 94 6
493: 27 2 17
1661724: 1 6 6 1 71 9 7
570389: 949 77 79 9 6
438506889: 4 259 521 943 811
1345877956: 553 1 5 8 9 82 39 9 8 3 6
2258628: 774 6 4 4 52 850 9 1 3 6
9900: 5 99 20
1639: 18 9 51 86 83 93
45459039: 7 19 903 63 84 8 8 378
14804410320: 647 454 3 8 70 9
245797934: 34 378 17 955 2 12 2 6
202655002734: 71 94 313 25 26 9
753018480284: 8 868 8 2 48 4 2 8 353
55427: 78 475 3 9 7
2857680701: 844 4 6 5 419 8 1 5 557
931456: 4 6 3 1 8 204 9 54 4 8 38
84004: 4 7 4 8 3 64 9 7 9 7 7 753
203988: 338 7 8 120 6
1242186: 4 73 950 182 4
2956426: 733 448 8 73 9 241
496: 48 1 9 4 60
1411905084: 3 8 521 2 2 4 2 645 84
469154: 1 305 66 268 23
1609: 81 8 2 6 953
2423194366519: 242 319 436 651 9
294367700: 416 19 16 50 107 122
258744: 6 410 92 35 16 29
10820: 4 7 383 1 96
4102518660376: 59 51 58 371 660 376
81938326: 81 19 74 8 328
10410341: 44 17 2 37 3 17
4169992704931: 416 9 1 992 70 49 26 6
29734: 55 8 769 22 540
2785658: 84 186 13 589 254 58
9808872679: 49 5 4 8 8 72 67 9
1538: 486 18 9 3 1
29695647956: 7 464 8 4 13 6 6 2 914 5
89549706: 44 12 2 130 9 706
15952: 2 28 9 51 5 8
230927360: 592 5 92 848
218010: 745 49 6 2 70 5 7 8 129
85747671776: 134 1 6 9 7 816 2 974 8
313731792: 4 62 9 746 708
672020778: 3 8 442 3 4 105 63 778
313295328: 3 884 53 7 3 837 92 6 4
75523: 7 63 6 97 930
337101953: 831 44 91 45 90 203
3280416: 34 5 77 5 65 508 5 2 48
6361: 69 26 7 4 92 8 1 210 62
1151055520: 47 404 5 7 68 70 3 6 9 6
952: 3 3 49
3312641047: 3 376 5 2 9 68 4 8 5 2 2 9
40848840: 3 8 275 6 41 8 8 27 545
92145: 92 14 3 5
8085171945: 660 7 5 4 85 6 35 2 1 7 5
42541685607: 5 558 8 5 9 3 509 4 5 1 3
768366963: 5 9 3 98 763 2 2 3 9 2 4 3
1433823: 99 2 557 7 13 2 12
17106391: 229 83 10 9 1
4234: 787 5 6 7 76 4 8 7 9 686
2382777: 579 693 7 207 9
99460323: 78 302 2 654 4 3
36216: 3 60 2 2 17 6
44579482780: 31 72 2 5 8 2 541 780
4725757: 325 73 18 16 710
16075344: 412 424 7 37 92
76280568533: 488 978 52 3 533
4899847680: 701 40 4 560 52 6
6619743: 805 4 94 43 87
3010779299: 43 875 9 741 8 1 2 14
107004040949: 370 6 482 40 947
55145323511: 536 8 6 6 8 532 35 1 1
337878256043: 972 436 145 586 797
142460645: 63 56 6 673 6
1280076: 43 7 5 50 9 17 2 669 1 2
326253: 9 3 8 77 7 4 1 6 7 5 329 4
139757: 639 8 108 2 2
91146240: 3 92 320 3 344
4487: 8 633 7
11318310: 74 9 624 381 8 66 40 2
304566: 95 44 357 614 22
81730534: 817 305 31
721: 6 6 44 9 1
12125052828: 866 175 5 1 3 77 6 8 30
1098: 9 237 7 833 4 7 1
1911: 2 60 9 759 75
151775549: 467 325 3 15 231
55176046: 94 96 294 228 5 43 3
18983481756: 41 463 481 753
715501: 75 5 2 199 63 707 3 6 8
6177608459: 1 2 5 1 4 55 8 8 456 1 5
2698949722878: 1 8 808 50 6 287 878
133: 7 6 12 5 8
37026: 366 8 99
136240016: 6 4 1 244 55 47 1 9 167
5369118: 9 64 71 179 7 118
176268044343: 4 8 642 9 7 8 5 739 6 6
78852: 675 942 754 33 609
479125212480: 939 461 2 51 479
15891202555: 948 7 9 8 7 87 4 4 55 6 5
4381286020: 1 812 92 784 5 247 4 5
18243607: 1 1 814 1 401 2 4 15 2 6
64943035538: 1 2 7 9 5 7 1 87 665 1 2 6
1834955: 5 4 9 2 6 321 6 1 18 9 6 3
5392524039: 281 8 2 953 6 26 2 932
1660082: 1 282 373 42 465 5 7
29899972: 278 92 962 2 84 7 837
580484834115: 857 4 36 978 677 1 6
7363035: 73 56 80 623 5
12617458: 3 7 6 2 9 223 69 5 5 4 4 2
137757: 73 96 3 9 57 734 5 3 47
168919: 209 7 8 116 2
5811278: 3 32 848 4 6 375
32581: 7 6 2 46 183 7
1814851: 3 864 7 3 90 61
76873499110656: 725 6 66 4 183 67 864
77468979555: 8 4 44 103 45 3 635 81
117157: 2 203 9 3 4 8 161 5 5 1 1
1212365896: 346 83 520 1 4 71 73 2
887247764: 7 3 433 5 7 2 239 94 1 4
4362519840: 4 9 3 5 9 158 4 7 6 415 4
116: 4 7 2 16 4
259255: 9 36 8 50 5
361753664: 90 438 39 2 6 4
8057: 67 738 7
15068: 7 78 1 5 1 2 1 7 23 3 92
650891342: 6 471 37 9 13 43
1041894889672: 2 65 9 4 2 27 28 1 376 7
2204983: 2 9 76 980 2
3169152: 1 44 375 6 96 2
1440198: 58 8 52 6 31
2951360509168: 765 195 88 133 29 8
1520477: 16 9 1 27 94 5 9 545 77
6448585068534: 946 464 4 83 59 1 78 3
132256560: 934 59 80 72 1 3 1
23126094506: 642 39 1 143 7 6 8 36
248: 8 6 5 64 7 2
25769625: 2 576 961 9 6
1350052: 6 5 25 4 3 5 1
710825806868: 6 8 2 5 82 1 4 80 6 86 9
94256767107: 7 3 54 9 8 629 4 636 4
236578283: 9 365 8 9 4 4 1 2 57 5 1 5
6091472: 25 6 1 96 5 4 5 3 435 7 2
195800: 6 181 7 95 4 844
6751740: 6 4 1 629 461 7 2 31 2
89416249145698: 576 879 31 829 5 698
79337108847: 670 1 3 269 9 1 10 44 9
582075235: 585 5 995 2 2 34
230: 7 55 85 6 77
12364053: 2 39 199 4 6 8 2 8 7 8 9 4
1315159874: 939 1 2 9 991 14
172852: 2 873 33 3 1
35: 3 1 4
148833: 987 61 71 7 2
2249277123: 6 348 23 36 9 5 764 8 3
4098601236: 99 50 6 92 8 5 4 8 3
397978707173: 29 547 628 8 7 383 6
647776: 88 92 1 8 90
300628727460: 413 51 954 3 727 6 8
5633862247: 5 8 9 2 63 1 9 1 4 3 3 809
16948: 6 58 93 2 2 932 2 6 987
3323: 77 7 2 5 618
762568: 95 99 60 3 568
1632594179370: 9 3 597 9 4 7 9 9 85 1 7 6
5190458: 56 8 3 20 8 91
24412160799: 54 558 14 633 81 99
5842625: 1 8 8 6 134 7 107 9 414
9505: 3 7 2 74 3 4
28360287: 9 6 60 7 13 4 9 2 1 23 9 3
19162: 871 106 19 8 591
1588039374: 4 4 5 560 1 99 4 2 9 246
529061305: 1 7 34 2 3 2 823 3 8 302
20470087211: 66 8 982 1 91 401 3 8
271835242245: 628 3 38 7 763 9 7 9
664206137805: 664 206 13 7 805
252498840: 916 55 5 88 591
3588031: 681 9 52 25 6 2
1669227009751: 8 298 609 9 6 5 3 8 7 9 1
8592: 9 3 8 9 6 321 69 1 8 424
4520811: 645 78 9 7 288
4588248: 4 2 8 2 31 7 58 5 2 2 434
7308889: 4 9 51 84 824 62
5650032516: 237 39 63 2 238 29 72
1500632: 551 194 294 2 7
290: 7 1 6 6
6940554612: 57 9 1 9 1 302 8 9 4 69
3053432256162: 9 7 367 1 8 40 98 6 9 9
715300: 878 8 652 7 92 92
472471839791: 66 964 158 336 47
41638291: 744 86 9 5 1 931 91
30729: 2 3 2 7 577 89 7 9 1 43
68858066: 57 325 1 56 4 8 6 2 290
11705: 15 28 5 40 45 147 75 5
172805096: 4 14 4 4 8 9 4 5 5 90 4 5
112486480056: 83 9 42 652 8 30 612
2255867489: 63 6 2 698 8 508 8 9
23553213402: 2 3 7 8 474 4 3 4 6 7 5 7
4351515: 9 434 195 31 220 355
55575: 39 52 4 3 195
31683616245: 62 70 24 361 624 5
49801178529: 56 2 916 9 983 9
406343010: 5 44 5 2 283 1 4 71 6 7 1
34560: 5 5 54 32 2
24864: 7 4 336
4879102: 85 287 2 97 5
1311973: 19 75 92 1 97 5
943673: 94 26 96 4 971 2
16530764188: 826 2 9 1 764 17 7 11
22116: 7 1 451 6 82 375 2 9
3485422: 927 9 70 7 81 41 6 3
259616: 3 146 63 77 40 90 76
585664165: 91 4 2 538 81 6 41 6 3
34707442220270: 96 7 624 8 492 3 4 129
182543640: 529 11 2 345 1
3536050: 149 1 95 66 247
1835: 94 817 883 41
1763497872: 6 5 8 785 7 3 5 3 63 432
143326336: 286 4 2 3 9 5 9 7 11 4 76
290569473: 628 873 53 15 3
2628325988520: 2 4 6 6 587 634 1 4 445
648000: 3 15 80 2 90
123016: 6 473 43 39 1 942
1135724897: 84 1 94 19 5 7 757 67
456092182907: 68 8 9 5 4 7 662 900 3 7
21430860636: 5 6 781 43 2 7 7 894 9 5
14017959691: 4 9 596 48 3 36 691
7770300: 7 9 40 7 8 1 9 4 747 7 3 2
6985: 5 2 4 85 8 887
80834112: 5 6 6 8 2 858 62 27 48
44460048659: 78 950 6 48 658
7045762059070: 945 7 398 73 7 745 5
673: 28 1 18 7 347 4
124573209: 6 2 8 3 9 6 904 31 9 7 5 8
18588: 53 867 4 5 4 2
4702617919: 36 1 20 2 110 7 848
5631803: 7 2 8 21 8 348 91 971 1
52: 14 26 3 5 4
295216: 2 946 6 13 3
46552414: 4 597 57 2 3 57 2 735 5
1029156840: 88 6 793 2 1 4 9 387 83
6564294: 894 200 20 9 5 4 3
280394247303: 1 50 7 49 28 8 730 4
2079328842: 753 3 8 276 44
16362993602: 5 703 86 71 7 7 5 64 1
302345215226: 232 130 74 521 52 26
275983140164: 8 82 15 2 47 1 8 7 298 4
4984851980: 8 989 4 45 7 3 34 3 2 9 7
8550490687: 5 64 41 5 2 23 724 9 7
2467: 97 136 5 87 45
9169757847: 819 3 94 97 578 49
2738: 913 1 8 917 899
71836380: 1 17 7 710 803
138108017589: 5 99 6 2 630 6 8 2 1 439
25623376: 117 219 378
297069679: 324 157 8 73 3 559
109913: 7 28 560 46 6 14 87
40829: 40 7 67 5 57
1667028: 348 1 343 73 1 33
3065830: 23 374 3 99 26 196
8471: 72 4 46 733 93
50578531: 43 31 53 806 26 16 3
419077: 8 58 5 9 9 5 9 8 1 73 7 2
8517255516: 5 358 79 1 6 27 9 9 33
88228: 38 4 3 7 30
10191450057: 486 5 4 50 5 1 6 37 699
860342: 83 97 3 9 716 2 7 7
1434303: 448 12 1 6 3 8 4
3924124810: 9 4 783 2 5 6 2 6 29 6 4 7
4731932: 966 5 8 2 609 2
1625738985: 796 1 92 6 43 493 45
2649: 1 7 58 2 68 4 19 8
139784755: 5 57 96 61 7 37 55
2371491360: 105 7 1 1 4 2 4 7 28 72
673267: 1 66 3 260 7
86530234: 1 8 359 5 73 48 471
3173494: 8 35 53 953 6
246481: 24 1 6 454 27
337699982: 21 268 333 6 4
3192168888: 3 79 9 927 6 5 1 6 2 8 9
400754759: 52 6 64 69 7 38 4 5
9874: 12 3 8 9 25
2296980: 79 2 71 698 2
15453444272: 10 6 77 741 28 74 61
9234: 8 1 33 374 739 8 1 1 1
7523285309497: 2 270 258 9 884 9 6 97
355863040: 5 274 9 3 3 43 8 9 5 7 20
6017896518: 6 6 3 84 989 1 5 9 1 520
21463219: 3 3 1 1 7 7 51 2 2 3 219 1
249972: 2 247 973
9483335933505: 13 547 6 22 762 15 7
14106336: 6 8 6 941 96
47760167652: 9 64 3 25 38 1 9 2 1 650
18510: 72 257 6
3538458: 4 108 4 1 3 5 621 483 6
422149: 6 78 902 6 7
705149: 7 4 7 2 6 9 1 2 930 2 207
1699: 856 75 57 704 7
151628377: 3 4 51 7 694 8 51 7 66
10663194: 28 21 4 316 57 85 5
346421: 7 19 665 5 9 6 22 5 74 5
39897: 1 14 350
386536: 2 5 2 8 872 7 8 1 6 7 3 8
2742606: 33 1 9 94 72 8 108 6 8
127867660: 87 6 95 660 9 7 765 9 1
1501660281: 8 278 2 7 99 8 9 421 9
686904710453: 9 4 53 4 265 9 56 9 46 7
204439326844: 8 6 8 2 3 177 98 9 3 2 3 1
24776250: 7 20 18 6 8 6 2 5 7 625 6
2679616647: 4 7 87 7 4 1 663 9 8
700877440: 3 36 8 9 8 78 50 80 8
326398: 43 6 2 640 1
1105723872: 8 8 75 4 8 9 9 9 341
18741772072: 7 284 575 8 4 2 5 7 8 73
379608: 8 9 494 26 25 661
377084225762: 873 85 899 1 97 7 6 8 1
6303485511: 960 9 767 65 11
1438340: 6 23 5 83 40
81: 5 10 18 6 4
2657422692: 459 7 213 9 6 57 3 39
6920: 7 126 37 3 40 1
53121623: 50 83 2 51 84 34 23
3485684191: 47 5 57 8 5 8 37 84 5 6 1
71324: 772 9 139 45 4
280728128745: 2 5 7 3 1 55 8 6 2 8 1 742
42670: 57 642 7 6 688
445: 55 8 5
3645021339: 138 3 79 1 779 1 1 3 33
98354767: 8 58 2 228 8 48 903 7 7
424631220019: 1 323 6 8 397 8 200 19
11097232472: 754 9 7 9 64 3 7 8 11 6 4
483210: 848 307 5 79 390
12350: 6 9 791 8 6 7 455 9
19649273: 529 54 9 53 7
8937985012: 96 253 4 92 9 46 66
520033939: 7 95 71 72 323 6
18230126: 4 2 9 1 3 70 8 707 664 6
87575079: 34 33 8 775 79
134945: 32 8 74 76 7 685
430796231254: 64 3 6 59 962 3 1 257
672749200: 2 847 87 944 609 50 8
287831: 8 798 51 7 89
34510203129: 36 1 9 2 33 91 129
363718885: 8 917 67 74 7
40504689602: 64 36 97 62 89 593 6
427764568: 8 6 60 961 88
146169: 852 772 9 2 7
3601167: 777 87 9 825 5 9 36
87040: 569 3 8 6 6 7 7 1 3 9 4 1
17405044: 229 38 5 2 44
39960000: 1 22 483 86 5 5 60 45
156876: 70 86 136 1 743
38442: 71 53 6 1 5 1 737
97301592: 355 331 9 92 9
55987728: 540 8 3 9 1 480 49
459742804: 7 28 91 80 4 9 4 7 1 1 3 1
1703750: 7 8 421 500 250
50094: 72 434 99
26: 5 8 4 9
357775357: 954 5 24 9 1 6 1 75 4
23116: 1 39 7 2 41 131 2 8 15
35248: 7 20 5 2 1 3 32 35 5 6 1 8
39806299201031: 3 9 4 9 8 300 95 3 9 6 6 7
298228891638: 6 656 730 8 7 9 28 5
338458480290: 674 7 9 458 99 90 119
17116: 1 148 5 417 9
4591429453: 20 316 226 13 453
2100824: 6 1 7 487 10 88 1
57720: 5 2 2 8 5 4 92 1 696 65
22637: 26 3 6 47 15 965 5
1684311: 23 732 4 66 9
305195: 606 503 3 9 362
34398776: 8 1 3 8 914 7 7 307 84 8
36383: 416 44 267 50 31
28584: 312 3 89 41 508
5958941381790: 72 6 700 16 8 5 1 82 5 3
232007102155: 8 8 3 8 7 467 260 431 5
6514959032: 892 46 73 566 463
207: 5 4 9 2 7
575418: 7 93 6 780 4 399 452 7
768460: 555 213 3 56 104
85723616832: 97 4 132 88 832
2474805658: 6 11 1 76 5 8 56 1 1 60
113698: 43 139 79 6 1 6 8 2 5 26
159333: 5 17 3 27 565
208467478761: 707 35 3 734 202 979
191917: 7 9 218 682 275
3076: 6 30 2 11 7 944 4 3 6 2
8763802073526: 7 744 6 6 6 733 8 943 2
87235: 6 56 6 3 9 179 7 9 58
338625046: 4 3 75 774 47
84974: 1 7 3 582 2
2526047: 4 1 74 44 4 46
17128812: 1 4 793 54 15
205561: 59 6 1 8 4 3 8 9 1 6 568 3
697394: 4 1 8 50 3 5 9 9 60 6 4 3
33080892: 797 1 3 415
938: 8 263 667
1564661697: 720 68 776 66 1 697
13768: 42 36 24 3 5 74 103 8
49978: 28 1 30 846 64
6601164080: 6 70 85 984 83
1080: 5 8 88 8 64 84 26 98
77002376: 2 629 167 2 61
3657653370: 3 76 1 2 802 53 3 3 70
1765971: 94 89 8 4 6 4 84 1 3 645
1015930728: 1 269 87 4 341 8
18207: 7 45 8 3 2 16 309
663234557: 2 1 2 43 4 6 7 2 5 1 4 512
14201135154: 761 6 2 814 311
115600: 813 1 5 452 7 13 30
1499214: 2 6 2 909 392 2 2 4 55 6
54283169: 82 9 33 4 47 3 70 59
1017935: 6 7 1 2 4 7 33 3 8 6 265 5
43008: 1 7 610 30 4 4
98971109: 3 6 8 2 4 14 1 6 37 6 1 83
340101: 1 1 8 5 6 5 6 38 479 4 1 9
213894723: 6 787 6 40 377 1 3
1197424642: 316 556 998 976 640
12147: 4 5 82 25 568 9 9 159
102569344: 7 5 7 2 2 5 999 3 4 92 16
1404: 19 48 84 5 9
31269612: 45 7 9 8 2 90 8 86 9 1 2
15043: 1 903 20 570 11 3
75316777: 195 599 29 77 5
4887133223: 888 5 443 547 6 5
78470767: 92 17 8 89 803
110668536002: 8 384 45 8 765 3 600 2
90722459520: 2 8 4 946 8 210 201
75961851: 7 6 2 5 4 9 883 875 93
82073162111: 889 2 923 2 109
91197457: 4 5 23 7 7 92 1 60 1 4
189076: 2 2 6 542 743 2 73 6
1123173960: 40 4 6 81 386 4 3 654 3
3562: 166 8 2 8 3
1725836521: 9 988 7 34 8 713 4 53
229045: 73 1 308 112 3
4389588: 3 9 4 6 38 8 994 7 6 42
1081: 56 8 937 17 63
582431925: 4 741 78 1 9 7 3 25
170884: 4 2 7 9 6 6 89 147 9 1 7
631904133: 65 992 98 71 62
12762253763: 9 773 85 4 3 86 40 4 1
341824972636: 4 5 6 2 4 6 5 6 5 525 15 9
8670693800: 236 3 39 136 22 9
12606163: 98 4 4 6 4 53 2 7 8 8 8 6
850686497: 850 58 8 98 488 6
1866247: 92 52 4 324 7
16800: 1 80 6 5 7
31933349: 94 1 249 38 50 1 49
10758448637: 671 2 8 96 4 5 4 8 6 3 5
7384: 11 5 4 45 1
743720: 835 86 8 69 20
25992842: 6 71 6 760 7 5 6 6 8 42
14248281685: 7 206 241 95 501 7 79
132997195: 6 319 409 72 195
98010: 7 9 5 922 99
17104242839121: 3 570 424 28 390 3 9 1
12612741120: 7 95 504 784 8 6
505239641290: 1 7 68 4 3 8 222 246 8 2
8377857: 6 8 563 310 417
1566246: 187 68 234 4 785 114

View File

@ -20,6 +20,7 @@
#include <vector>
#include <limits>
#include <algorithm>
#include <stack>
#include <blt/fs/loader.h>
#include <blt/iterator/enumerate.h>
#include <blt/iterator/iterator.h>
@ -28,6 +29,183 @@
#include <blt/math/vectors.h>
#include <blt/std/assert.h>
struct test_case_t
{
blt::i64 calibration;
std::vector<blt::i64> values;
};
enum class operator_t
{
PLUS, MULTIPLY, CONCAT
};
struct operation_t
{
const test_case_t* test_case;
std::vector<operator_t> operators;
explicit operation_t(const test_case_t* test_case): test_case(test_case)
{
for (blt::size_t i = 0; i < test_case->values.size() - 1; ++i)
operators.push_back(operator_t::PLUS);
}
[[nodiscard]] bool valid() const
{
std::stack<blt::i64> value_stack;
for (const auto v : blt::iterate(test_case->values).rev())
value_stack.push(v);
for (const auto op : operators)
{
const auto a = value_stack.top();
value_stack.pop();
const auto b = value_stack.top();
value_stack.pop();
switch (op)
{
case operator_t::PLUS:
value_stack.push(a + b);
break;
case operator_t::MULTIPLY:
value_stack.push(a * b);
break;
case operator_t::CONCAT:
value_stack.push(std::stoll(std::to_string(a) + std::to_string(b)));
break;
}
}
return test_case->calibration == value_stack.top();
}
bool next()
{
bool carry = false;
for (blt::size_t i = 0; i < operators.size(); i++)
{
if (carry && operators[i] == operator_t::MULTIPLY)
{
if (i == operators.size() - 1)
return false;
operators[i] = operator_t::PLUS;
}
else if (carry && operators[i] == operator_t::PLUS)
{
operators[i] = operator_t::MULTIPLY;
break;
}
else if (operators[i] == operator_t::PLUS)
{
operators[i] = operator_t::MULTIPLY;
break;
}
else if (operators[i] == operator_t::MULTIPLY)
{
if (i == operators.size() - 1)
return false;
carry = true;
operators[i] = operator_t::PLUS;
}
else
{
BLT_INFO("I don't think this state is possible");
}
}
return true;
}
bool next2()
{
bool carry = false;
for (blt::size_t i = 0; i < operators.size(); i++)
{
if (carry && operators[i] == operator_t::CONCAT)
{
if (i == operators.size() - 1)
return false;
operators[i] = operator_t::PLUS;
}
else if (operators[i] == operator_t::PLUS)
{
operators[i] = operator_t::MULTIPLY;
break;
}
else if (operators[i] == operator_t::MULTIPLY)
{
operators[i] = operator_t::CONCAT;
break;
}
else if (operators[i] == operator_t::CONCAT)
{
if (i == operators.size() - 1)
return false;
carry = true;
operators[i] = operator_t::PLUS;
}
else
{
BLT_INFO("I don't think this state is possible");
}
}
return true;
}
};
void run_day7()
{
const auto file = blt::fs::getLinesFromFile("../problems/day7/input");
std::vector<test_case_t> test_cases;
for (const auto& line : file)
{
test_case_t test;
auto data = blt::string::split(line, ":");
test.calibration = std::stoll(data[0]);
auto values = blt::string::split(data[1], ' ');
for (const auto& value : values)
test.values.push_back(std::stoll(value));
test_cases.emplace_back(std::move(test));
}
blt::i64 valid_test_case_sum = 0;
for (const auto& test : test_cases)
{
operation_t op{&test};
do
{
if (op.valid())
{
BLT_TRACE("Valid test case found! %ld", test.calibration);
valid_test_case_sum += test.calibration;
break;
}
}
while (op.next());
}
blt::i64 valid_test_cases_sum2 = 0;
for (const auto& test : test_cases)
{
operation_t op{&test};
do
{
if (op.valid())
{
BLT_TRACE("Valid test case found! %ld", test.calibration);
valid_test_cases_sum2 += test.calibration;
break;
}
}
while (op.next2());
}
BLT_INFO("test_case_sum %ld", valid_test_case_sum);
BLT_INFO("test_case_sum2 %ld", valid_test_cases_sum2);
}

33
src/day8.cpp Normal file
View File

@ -0,0 +1,33 @@
/*
* <Short Description>
* Copyright (C) 2024 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <day8.h>
#include <blt/math/log_util.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <blt/fs/loader.h>
#include <blt/iterator/enumerate.h>
#include <blt/iterator/iterator.h>
#include <blt/iterator/zip.h>
#include <blt/std/hashmap.h>
#include <blt/math/vectors.h>
#include <blt/std/assert.h>
void run_day8()
{
}

View File

@ -7,6 +7,7 @@
#include <day5.h>
#include <day6.h>
#include <day7.h>
#include <day8.h>
int main(const int argc, const char** argv)
{
@ -46,6 +47,7 @@ int main(const int argc, const char** argv)
run_day7();
break;
case 8:
run_day8();
break;
default:
BLT_INFO("%d is not a day", day);