This commit is contained in:
Gabe Venberg 2023-12-10 09:40:10 -06:00
parent 5b3a1c737f
commit 0a43e8a355
7 changed files with 324 additions and 0 deletions

7
Cargo.lock generated
View file

@ -81,6 +81,13 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "day09"
version = "0.1.0"
dependencies = [
"aoc_libs",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.9.0" version = "1.9.0"

9
days/day09/Cargo.toml Normal file
View file

@ -0,0 +1,9 @@
[package]
name = "day09"
authors.workspace = true
description.workspace = true
version.workspace = true
edition.workspace = true
[dependencies]
aoc_libs.workspace = true

200
days/day09/src/input.txt Normal file
View file

@ -0,0 +1,200 @@
13 14 13 10 5 -2 -11 -22 -35 -50 -67 -86 -107 -130 -155 -182 -211 -242 -275 -310 -347
9 19 37 66 111 177 266 388 625 1318 3490 9701 25720 63813 149272 333318 718069 1503353 3071375 6134368 11983281
17 46 98 176 281 429 679 1172 2193 4286 8484 16784 33150 65659 131075 264391 538087 1099560 2241224 4527470 9018149
7 8 7 15 65 227 628 1477 3095 5950 10697 18223 29697 46625 70910 104917 151543 214292 297355 405695 545137
16 20 32 75 200 503 1144 2368 4528 8110 13760 22313 34824 52601 77240 110662 155152 213400 288544 384215 504584
12 19 22 16 -5 -46 -106 -162 -130 213 1366 4324 10909 24244 49406 94298 170784 296135 494838 800824 1260175
2 6 26 72 158 308 570 1038 1882 3389 6024 10529 18090 30617 51200 84825 139458 227632 368702 591966 940886
22 46 83 136 215 355 655 1362 3045 6934 15547 33816 71102 144866 287545 559746 1075870 2053792 3909961 7437838 14134735
11 28 56 110 211 392 719 1340 2589 5207 10809 22836 48395 101619 209484 421412 824479 1566646 2891150 5186042 9053851
18 41 80 155 308 608 1164 2162 3949 7210 13337 25194 48675 95789 190569 380005 753596 1477199 2849870 5396645 10016062
27 45 78 149 302 624 1293 2676 5512 11226 22431 43686 82589 151295 268560 462423 773649 1260067 2001948 3108579 4726200
-4 -8 -13 0 71 277 765 1806 3871 7731 14593 26319 45879 78460 134275 235391 431268 831772 1672945 3440668 7091533
3 16 32 55 106 241 575 1307 2748 5384 10073 18593 34941 68045 136906 279649 568545 1133784 2199646 4137747 7543244
12 37 77 132 202 287 387 502 632 777 937 1112 1302 1507 1727 1962 2212 2477 2757 3052 3362
21 25 24 23 40 123 392 1125 2909 6873 15012 30615 58861 107802 190292 328053 560129 959637 1665192 2936927 5251986
-3 4 31 85 169 285 443 684 1131 2086 4193 8687 17747 34967 65953 119046 206161 343720 553643 864345 1311669
12 39 94 190 340 557 854 1244 1740 2355 3102 3994 5044 6265 7670 9272 11084 13119 15390 17910 20692
8 3 6 32 108 279 614 1212 2208 3779 6150 9600 14468 21159 30150 41996 57336 76899 101510 132096 169692
19 34 45 58 97 211 481 1027 2015 3664 6253 10128 15709 23497 34081 48145 66475 89966 119629 156598 202137
19 32 43 45 36 32 85 301 856 2020 4216 8156 15115 27474 49920 92445 178177 363369 786019 1778286 4114938
21 23 28 49 115 297 747 1743 3732 7381 13707 24503 43577 79880 154567 315616 666091 1415815 2971538 6088153 12113739
12 25 38 55 85 142 245 418 690 1095 1672 2465 3523 4900 6655 8852 11560 14853 18810 23515 29057
2 1 -3 -10 -20 -33 -49 -68 -90 -115 -143 -174 -208 -245 -285 -328 -374 -423 -475 -530 -588
15 31 53 83 130 228 479 1144 2816 6725 15248 32734 66829 130665 246726 454311 825117 1497239 2749951 5165469 9968628
13 22 41 94 227 530 1182 2527 5189 10234 19387 35312 61963 105014 172376 274809 426637 646574 958669 1393378 1988771
10 27 61 128 265 541 1078 2086 3929 7275 13453 25271 48812 97287 199231 415823 876990 1854968 3909809 8167901 16837713
20 41 69 115 210 426 919 2014 4376 9357 19685 40775 83102 166290 325847 623822 1165084 2121433 3766357 6523955 11036362
20 41 79 145 260 469 859 1576 2833 4898 8048 12472 18103 24356 29746 31357 24130 -65 -53611 -154621 -328754
12 15 14 14 20 31 44 93 361 1429 4792 13917 36403 88335 202900 447124 953909 1982790 4034693 8068571 15910501
7 1 -10 -26 -47 -73 -104 -140 -181 -227 -278 -334 -395 -461 -532 -608 -689 -775 -866 -962 -1063
8 17 28 41 56 73 92 113 136 161 188 217 248 281 316 353 392 433 476 521 568
-7 -7 -3 20 91 253 563 1092 1925 3161 4913 7308 10487 14605 19831 26348 34353 44057 55685 69476 85683
19 41 75 131 239 467 955 1978 4070 8281 16709 33558 67130 133373 261887 505645 956125 1766081 3182815 5595557 9601425
19 38 76 145 252 412 679 1198 2286 4562 9162 18098 34869 65554 120910 220664 402655 742670 1397682 2699767 5358228
-8 -12 -16 -20 -24 -28 -32 -36 -40 -44 -48 -52 -56 -60 -64 -68 -72 -76 -80 -84 -88
14 19 25 47 123 330 805 1770 3568 6733 12138 21281 36762 62959 106853 179040 295716 485185 810417 1439321 2840823
-5 -10 -5 27 113 307 712 1508 3008 5813 11227 22245 45678 96398 205401 434621 903560 1836489 3645526 7077172 13474410
6 12 37 100 225 454 877 1695 3352 6804 14053 29199 60520 124585 254292 514213 1028998 2034192 3964089 7598714 14302319
9 -1 -3 16 71 191 448 1014 2276 5083 11286 24888 54380 117243 248195 513614 1035739 2031815 3875387 7189552 12985245
13 9 3 11 67 227 573 1217 2305 4021 6591 10287 15431 22399 31625 43605 58901 78145 102043 131379 167019
3 13 41 93 185 367 766 1656 3563 7413 14731 27899 50481 87623 146536 237070 372387 569741 851373 1245529 1787609
26 35 37 26 -2 -45 -94 -139 -186 -289 -601 -1448 -3430 -7553 -15396 -29317 -52702 -90261 -148375 -235498 -362618
24 35 46 57 68 79 90 101 112 123 134 145 156 167 178 189 200 211 222 233 244
-1 -3 7 45 137 336 752 1595 3231 6251 11553 20437 34713 56822 89970 138275 206927 302361 432443 606669 836377
5 14 43 100 196 351 596 980 1613 2813 5492 12035 28135 66420 153386 342383 737601 1537808 3114941 6152870 11887554
-4 6 31 79 177 390 850 1806 3720 7456 14647 28396 54601 104440 198986 377657 713404 1339426 2495079 4602917 8394985
8 14 26 47 83 143 236 375 620 1224 2998 8105 21675 54992 131693 299673 653536 1375886 2810998 5591955 10852643
-6 -6 -6 -13 -32 -48 15 366 1463 4197 10185 22236 45083 86509 159036 282393 487032 819020 1346700 2169585 3430026
16 35 67 113 174 251 345 457 588 739 911 1105 1322 1563 1829 2121 2440 2787 3163 3569 4006
18 25 35 61 126 269 567 1182 2449 5043 10322 21086 43303 89970 189428 402531 856796 1812337 3786333 7783995 15721100
1 0 -3 -8 -15 -24 -35 -48 -63 -80 -99 -120 -143 -168 -195 -224 -255 -288 -323 -360 -399
22 29 36 43 50 57 64 71 78 85 92 99 106 113 120 127 134 141 148 155 162
12 25 47 93 190 380 730 1359 2492 4551 8293 15005 26766 46786 79832 132751 215100 339893 524475 791533 1170254
3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63
8 22 44 75 116 168 232 309 400 506 628 767 924 1100 1296 1513 1752 2014 2300 2611 2948
7 18 45 93 171 292 473 735 1103 1606 2277 3153 4275 5688 7441 9587 12183 15290 18973 23301 28347
16 25 41 71 122 201 315 471 676 937 1261 1655 2126 2681 3327 4071 4920 5881 6961 8167 9506
11 8 7 14 34 73 153 358 946 2603 6990 17860 43245 99637 219904 468209 967955 1953669 3866490 7528970 14465012
5 7 7 9 24 70 172 362 679 1169 1885 2887 4242 6024 8314 11200 14777 19147 24419 30709 38140
20 41 88 184 360 655 1116 1798 2764 4085 5840 8116 11008 14619 19060 24450 30916 38593 47624 58160 70360
5 1 -3 -7 -11 -15 -19 -23 -27 -31 -35 -39 -43 -47 -51 -55 -59 -63 -67 -71 -75
14 28 49 84 144 244 403 644 994 1484 2149 3028 4164 5604 7399 9604 12278 15484 19289 23764 28984
22 39 76 159 327 632 1139 1926 3084 4717 6942 9889 13701 18534 24557 31952 40914 51651 64384 79347 96787
-2 2 14 48 128 302 671 1448 3080 6489 13516 27685 55442 108067 204505 375415 668794 1157596 1949834 3201726 5134524
8 26 74 174 355 653 1111 1779 2714 3980 5648 7796 10509 13879 18005 22993 28956 36014 44294 53930 65063
23 33 50 91 180 356 702 1409 2889 5944 11981 23232 42888 74981 123741 192008 278083 370147 437052 413881 180172
3 21 50 101 197 368 646 1058 1610 2250 2793 2786 1286 -3481 -14617 -37247 -79459 -153541 -277572 -477429 -789277
11 24 52 113 232 438 776 1348 2397 4448 8520 16423 31154 57406 102204 175682 292015 470520 736940 1124925 1677724
-10 -6 14 71 204 480 1012 2001 3833 7274 13814 26222 49416 91898 168406 305363 552580 1008090 1868702 3527701 6753848
20 34 64 128 254 493 939 1767 3313 6233 11791 22339 42065 78098 142072 252264 436434 735508 1208258 1937146 3035512
2 10 22 45 90 169 301 550 1131 2634 6438 15432 35251 76403 157947 313829 603648 1130570 2070406 3717599 6556112
3 14 47 113 223 383 590 829 1076 1332 1752 2991 6966 18339 47197 113725 256297 545618 1109757 2178733 4163617
9 24 49 94 186 381 792 1643 3363 6738 13143 24880 45652 81207 140190 235245 384413 612876 955101 1457442 2181262
14 23 35 58 105 197 366 658 1136 1883 3005 4634 6931 10089 14336 19938 27202 36479 48167 62714 80621
27 44 59 64 57 56 117 356 975 2292 4775 9080 16093 26976 43217 66684 99683 145020 206067 286832 392033
17 25 33 41 49 57 65 73 81 89 97 105 113 121 129 137 145 153 161 169 177
17 32 70 139 249 433 788 1552 3245 6924 14644 30289 61045 119922 229851 429893 783891 1391526 2401936 4033413 6616003
16 27 55 113 230 463 916 1774 3367 6293 11651 21464 39397 71870 129603 229529 397057 669452 1104102 1803952 2993211
11 34 80 162 301 533 917 1545 2563 4231 7097 12477 23695 49066 108610 248366 569762 1288551 2852013 6171819 13087348
19 26 30 31 29 24 16 5 -9 -26 -46 -69 -95 -124 -156 -191 -229 -270 -314 -361 -411
1 20 64 146 293 561 1063 2033 3966 7896 15901 31956 63292 122461 230354 420471 744799 1281716 2146406 3504342 5588471
-4 0 10 41 129 333 731 1413 2475 4021 6200 9375 14701 25775 52754 121612 293282 700634 1615986 3568633 7541309
14 29 57 101 164 254 391 628 1118 2290 5238 12478 29293 65976 141417 288696 563690 1058247 1920315 3384655 5819558
12 22 42 72 112 162 222 292 372 462 562 672 792 922 1062 1212 1372 1542 1722 1912 2112
18 38 82 159 280 460 722 1114 1749 2874 4983 9051 17156 34208 72464 162434 377514 886708 2062686 4695469 10402310
3 5 19 57 145 338 735 1494 2847 5115 8723 14215 22269 33712 49535 70908 99195 135969 183027 242405 316393
20 29 38 60 132 334 816 1836 3813 7404 13640 24238 42403 74835 136386 260038 516810 1053119 2157346 4373288 8686278
16 42 90 173 313 554 995 1863 3648 7320 14640 28559 53665 96580 166117 272869 427704 638366 903014 1199049 1464961
15 24 33 42 51 60 69 78 87 96 105 114 123 132 141 150 159 168 177 186 195
8 31 73 153 298 550 988 1770 3200 5825 10567 18895 33042 56272 93202 150184 235752 361139 540869 793429 1142026
9 30 70 140 259 471 876 1691 3385 6979 14670 31027 65128 134201 269698 527469 1005174 1872859 3427543 6190589 11077866
-6 0 11 33 89 233 568 1274 2661 5271 10062 18716 34122 61094 107393 185131 312644 516930 836757 1326555 2061215
6 22 41 56 57 40 22 53 226 709 1860 4547 10912 26080 61944 145656 338842 780748 1782863 4029602 8988143
-9 -10 -4 15 67 204 545 1347 3146 7020 15048 31086 62104 120613 229283 429883 800389 1486794 2760144 5114905 9431989
7 26 59 115 203 330 507 765 1178 1885 3098 5078 8056 12071 16692 20586 20889 12332 -13931 -71851 -182431
25 50 84 133 218 381 694 1277 2328 4164 7285 12537 21617 38505 73019 148687 318659 695614 1504754 3173253 6475212
4 0 -13 -29 -17 103 501 1516 3817 8718 18751 38637 76837 147924 276125 500603 883477 1522303 2569754 4264250 6975394
27 47 81 153 311 639 1273 2437 4536 8382 15705 30247 60020 121869 250601 517175 1064855 2180784 4436721 8962954 17974199
14 13 9 18 75 240 621 1432 3106 6494 13211 26249 51075 97579 183443 339777 620222 1115163 1973237 3432972 5868163
23 50 93 161 277 492 914 1774 3579 7453 15857 34031 72745 153319 316418 636898 1248031 2379836 4418061 7992677 14107645
11 10 21 56 127 246 425 676 1011 1442 1981 2640 3431 4366 5457 6716 8155 9786 11621 13672 15951
26 45 69 98 132 171 215 264 318 377 441 510 584 663 747 836 930 1029 1133 1242 1356
15 41 78 131 225 419 830 1676 3361 6664 13177 26300 53407 110349 230417 481486 997646 2035714 4073411 7975968 15273628
-8 -8 -6 -4 2 30 119 334 774 1597 3082 5745 10513 18946 33506 57948 98120 163906 273862 465454 815928
8 17 26 35 44 53 62 71 80 89 98 107 116 125 134 143 152 161 170 179 188
-1 5 16 35 77 177 397 823 1538 2555 3704 4510 4223 2477 1816 15090 84677 329015 1049600 2966735 7719325
4 15 32 59 108 199 360 627 1044 1663 2544 3755 5372 7479 10168 13539 17700 22767 28864 36123 44684
-5 0 16 60 178 464 1087 2343 4767 9362 18027 34292 64492 119530 217386 386519 670275 1132348 1863234 2987460 4671150
8 13 29 70 160 330 615 1051 1672 2507 3577 4892 6448 8224 10179 12249 14344 16345 18101 19426 20096
2 7 12 14 26 92 302 807 1834 3701 6832 11772 19202 29954 45026 65597 93042 128947 175124 233626 306762
13 22 55 135 310 683 1460 3025 6057 11710 21883 39613 69630 119119 198740 323963 516781 807870 1239271 1867675 2768398
-9 -4 16 59 142 297 585 1133 2218 4431 8962 18062 35782 69203 130622 241651 441077 799858 1449144 2631225 4789554
17 30 53 86 129 182 245 318 401 494 597 710 833 966 1109 1262 1425 1598 1781 1974 2177
16 31 57 92 134 181 231 282 332 379 421 456 482 497 499 486 456 407 337 244 126
15 23 45 95 192 361 640 1097 1863 3193 5577 9934 17943 32647 59747 110768 211035 418963 869777 1868209 4073414
15 41 89 166 277 425 611 834 1091 1377 1685 2006 2329 2641 2927 3170 3351 3449 3441 3302 3005
13 21 40 89 207 459 933 1736 3024 5143 9015 16975 34352 72189 151614 310506 613247 1164513 2128234 3753045 6405757
16 23 38 68 130 264 551 1136 2256 4273 7712 13304 22034 35194 54441 81860 120032 172107 241882 333884 453458
12 18 24 22 14 35 199 777 2326 5912 13508 28700 57900 112345 211255 386631 690296 1203918 2052904 3425218 5596354
-8 -13 -18 -23 -28 -33 -38 -43 -48 -53 -58 -63 -68 -73 -78 -83 -88 -93 -98 -103 -108
5 2 -3 -1 29 127 377 956 2206 4728 9528 18351 34588 65629 128400 261301 548362 1166341 2475406 5194738 10747314
-9 -17 -13 18 105 315 784 1765 3731 7612 15304 30678 61474 122778 243443 478215 931187 1801827 3475476 6699809 12924125
16 30 44 58 72 86 100 114 128 142 156 170 184 198 212 226 240 254 268 282 296
-4 8 33 73 136 237 395 634 1019 1796 3769 9158 23371 58431 139277 314867 677022 1391344 2746409 5229879 9643306
11 19 22 16 -7 -59 -159 -336 -612 -921 -880 748 7202 26037 73573 183088 419305 903051 1851778 3644040 6919135
3 7 23 51 87 122 139 108 -21 -327 -929 -1999 -3777 -6588 -10861 -17150 -26157 -38757 -56025 -79265 -110041
26 47 76 110 141 168 237 537 1594 4619 12080 28582 62153 126048 241197 439437 767682 1293199 2110172 3347750 5179789
1 -3 5 43 135 311 607 1065 1733 2665 3921 5567 7675 10323 13595 17581 22377 28085 34813 42675 51791
26 36 51 78 121 181 256 341 428 506 561 576 531 403 166 -209 -754 -1504 -2497 -3774 -5379
24 49 83 120 161 228 376 695 1305 2378 4283 8064 16660 37614 88602 208180 476214 1052579 2250883 4679724 9513235
6 11 34 83 159 267 436 749 1395 2780 5782 12315 26488 56816 120170 248451 499348 973001 1836946 3362379 5975549
7 1 0 21 91 242 504 899 1439 2131 2992 4077 5523 7612 10856 16107 24695 38597 60640 94741 146187
15 28 45 60 63 40 -27 -160 -385 -732 -1235 -1932 -2865 -4080 -5627 -7560 -9937 -12820 -16275 -20372 -25185
12 19 30 45 64 87 114 145 180 219 262 309 360 415 474 537 604 675 750 829 912
13 37 73 123 189 273 377 503 653 829 1033 1267 1533 1833 2169 2543 2957 3413 3913 4459 5053
8 24 59 123 226 378 589 869 1228 1676 2223 2879 3654 4558 5601 6793 8144 9664 11363 13251 15338
6 0 1 22 90 259 623 1329 2590 4698 8037 13096 20482 30933 45331 64715 90294 123460 165801 219114 285418
1 0 4 15 33 59 104 204 441 970 2052 4093 7689 13677 23192 37730 59217 90084 133348 192699 272593
18 22 33 57 109 231 522 1202 2761 6298 14256 31955 70704 153980 329421 691523 1423433 2871746 5676622 10992031 20849292
21 23 32 62 131 275 575 1194 2432 4832 9409 18127 34816 66802 127618 241273 448679 816973 1452622 2519364 4262217
3 10 22 41 68 108 186 383 907 2220 5248 11707 24584 48818 92232 166773 290123 487750 795474 1262629 1955908
17 29 59 129 284 597 1180 2217 4044 7313 13292 24371 44865 82229 148827 264427 459627 780453 1294409 2098301 3328202
-4 -7 -4 11 44 101 188 311 476 689 956 1283 1676 2141 2684 3311 4028 4841 5756 6779 7916
13 31 65 132 273 571 1184 2408 4801 9423 18284 35154 66995 126451 236111 435682 793821 1427231 2530787 4423992 7621045
-2 -5 -7 -5 16 92 291 737 1664 3518 7130 14019 27008 51653 99674 196927 400914 837061 1769967 3736899 7787848
-7 -8 9 65 194 460 988 2015 3970 7595 14122 25524 44861 76745 127951 208204 331175 515722 787415 1180387 1739556
21 44 94 181 311 498 791 1326 2429 4835 10159 21876 47279 101271 213575 442351 900001 1802661 3566842 7001844 13698911
9 17 23 27 29 29 27 23 17 9 -1 -13 -27 -43 -61 -81 -103 -127 -153 -181 -211
9 15 15 4 -11 3 122 493 1382 3245 6810 13147 23740 40756 68207 115815 209575 416951 901321 2031090 4585703
15 26 51 114 247 502 981 1886 3601 6851 13046 25016 48484 94825 185957 362689 698703 1323992 2464873 4514282 8158873
28 48 72 93 98 67 -31 -251 -694 -1518 -2883 -4725 -6176 -4292 8596 50348 160256 421832 1007774 2265645 4875030
10 31 77 158 281 450 664 923 1271 1929 3607 8160 19938 48615 115226 265034 594392 1305015 2809553 5929150 12249559
11 31 66 133 257 470 820 1399 2399 4205 7534 13629 24517 43340 74768 125503 204883 325595 504506 763621 1131177
14 19 31 62 120 212 356 616 1182 2519 5613 12362 26228 53462 105720 206075 402990 801955 1634195 3399266 7148256
5 -3 -6 14 89 276 686 1539 3264 6689 13407 26460 51554 99104 187509 348173 632919 1124589 1951784 3308874 5482599
-4 3 34 112 283 625 1266 2420 4446 7930 13784 23349 38481 61590 95592 143723 209152 294317 399894 523294 656567
-4 5 33 88 192 399 815 1624 3145 5985 11417 22210 44287 89811 182627 367450 724810 1394557 2611681 4759268 8444498
15 30 58 110 197 330 520 778 1115 1542 2070 2710 3473 4370 5412 6610 7975 9518 11250 13182 15325
14 11 2 -2 32 169 513 1214 2486 4655 8264 14270 24376 41549 70783 120174 202382 336563 550862 885566 1397024
18 43 79 125 182 263 410 716 1359 2669 5267 10352 20327 40295 81829 172433 378440 857986 1978345 4565832 10419624
4 10 17 26 42 88 231 636 1675 4136 9608 21163 44514 89909 175172 330649 607626 1093546 1940883 3423120 6042846
3 22 53 98 162 263 459 900 1927 4263 9384 20245 42704 88286 179422 359061 707675 1372260 2614095 4884884 8944614
4 15 38 73 120 179 250 333 428 535 654 785 928 1083 1250 1429 1620 1823 2038 2265 2504
23 42 81 152 262 406 554 631 489 -130 -1641 -4674 -10144 -19334 -33992 -56443 -89717 -137694 -205267 -298524 -424950
12 19 49 116 230 404 678 1165 2136 4196 8684 18602 40728 90256 200608 443427 967876 2075253 4356031 8933736 17886258
-2 -8 -16 -16 7 73 207 438 805 1393 2443 4607 9452 20356 43984 92583 187392 363526 676762 1212730 2099093
15 20 22 21 17 10 0 -13 -29 -48 -70 -95 -123 -154 -188 -225 -265 -308 -354 -403 -455
2 5 14 30 53 82 115 149 180 203 212 200 159 80 -47 -233 -490 -831 -1270 -1822 -2503
8 15 38 93 209 435 852 1596 2894 5121 8921 15540 27768 52407 106190 228941 511121 1148880 2550469 5537596 11722540
-7 4 30 71 127 198 284 385 501 632 778 939 1115 1306 1512 1733 1969 2220 2486 2767 3063
4 21 54 101 157 212 245 214 42 -401 -1320 -3021 -5941 -10682 -18049 -29092 -45152 -67911 -99446 -142287 -199479
24 44 72 121 229 467 952 1889 3693 7283 14711 30431 63812 134129 280578 582555 1200874 2461318 5022490 10208249 20654203
16 44 87 158 277 466 759 1245 2165 4087 8186 16659 33308 64327 119332 212676 365094 605726 974569 1525412 2329311
23 51 104 192 325 513 766 1094 1507 2015 2628 3356 4209 5197 6330 7618 9071 10699 12512 14520 16733
10 25 51 92 164 314 665 1513 3530 8178 18521 40743 86848 179241 358175 693406 1301834 2373431 4208375 7269030 12251244
12 27 60 111 175 257 398 722 1523 3415 7570 16073 32432 62295 114440 202106 344702 569835 915392 1431035 2177845
26 49 81 132 228 419 803 1580 3151 6278 12322 23577 43719 78390 135938 228335 372296 590623 913799 1381858 2046558
13 13 25 74 204 497 1103 2287 4510 8579 15939 29260 53625 98891 184223 346449 654819 1236049 2315277 4280846 7783762
10 31 75 145 249 406 653 1054 1721 2875 4998 9151 17554 34538 67982 131336 246300 446175 779821 1316045 2148095
13 15 17 16 19 55 189 554 1427 3390 7660 16783 36127 77064 163516 344803 719657 1479081 2979707 5864762 11257059
9 21 37 66 129 268 555 1100 2060 3670 6359 11077 20036 38154 75584 151800 301771 584784 1096751 1988587 3500239
9 23 37 51 65 79 93 107 121 135 149 163 177 191 205 219 233 247 261 275 289
3 6 27 74 157 302 581 1180 2541 5628 12381 26436 54203 106408 200219 362090 631471 1065546 1745175 2782230 4328529
3 21 49 96 195 422 916 1896 3668 6604 11047 17037 23644 27511 19924 -18697 -128591 -387257 -936475 -2024770 -4072135
2 19 49 85 125 186 324 662 1428 3005 5995 11299 20215 34556 56790 90204 139094 208983 306869 441505 623713
3 -2 -12 -31 -56 -63 9 271 889 2076 4066 7065 11174 16279 21903 27015 29791 27322 15264 -12575 -64716
-7 -12 -9 28 138 383 875 1840 3763 7691 15813 32487 65944 130968 252929 473633 859549 1513078 2587643 4307502 6993318
2 1 -3 -13 -27 -17 104 527 1604 3917 8359 16227 29327 50091 81706 128255 194870 287897 415073 585715 810921
-3 -1 2 6 11 17 24 32 41 51 62 74 87 101 116 132 149 167 186 206 227
13 26 44 64 92 165 385 976 2383 5443 11681 23833 46794 89362 167440 309821 568385 1035568 1873426 3360638 5966520
14 43 88 154 261 457 833 1552 2918 5524 10539 20244 39039 75362 145344 279640 535806 1019929 1923066 3580526 6565265
9 6 5 6 9 14 21 30 41 54 69 86 105 126 149 174 201 230 261 294 329
-3 12 39 84 173 364 759 1516 2861 5100 8631 13956 21693 32588 47527 67548 93853 127820 171015 225204 292365
12 20 52 124 251 454 780 1348 2447 4728 9552 19581 39730 78636 150846 279981 503198 877348 1487316 2457130 3964541
10 4 -3 -11 -20 -30 -41 -53 -66 -80 -95 -111 -128 -146 -165 -185 -206 -228 -251 -275 -300
23 45 69 102 160 276 530 1122 2528 5807 13164 28920 61095 123874 241299 452612 819765 1437713 2448215 4057986 6562170
22 47 91 160 273 481 903 1800 3731 7881 16734 35407 74202 153333 311438 620531 1211684 2318227 4346981 7993474 14424847
3 18 59 136 255 417 617 843 1075 1284 1431 1466 1327 939 213 -955 -2685 -5114 -8397 -12708 -18241
23 49 87 137 199 273 359 457 567 689 823 969 1127 1297 1479 1673 1879 2097 2327 2569 2823
24 35 47 71 128 250 480 878 1551 2737 4986 9495 18669 36996 72341 137782 254130 453295 782681 1310815 2134438

14
days/day09/src/main.rs Normal file
View file

@ -0,0 +1,14 @@
mod part1;
mod part2;
mod parse;
fn main() {
let input = include_str!("./input.txt");
let mut structured_input = parse::parse(input);
println!("Part One");
println!("Result: {}", part1::part1(&structured_input));
println!("Part Two");
println!("Result: {}", part2::part2(&mut structured_input));
}

48
days/day09/src/parse.rs Normal file
View file

@ -0,0 +1,48 @@
pub fn parse(input: &str) -> Vec<Vec<i32>> {
input
.lines()
.map(|l| l.split(' ').map(|n| n.parse().unwrap()).collect())
.collect()
}
pub fn get_differences(input: &[i32]) -> Vec<i32> {
input.windows(2).map(|p| p[1] - p[0]).collect()
}
pub fn extrapolate_sequence(input: &[i32]) -> i32 {
if input.iter().all(|i| *i == 0) {
return 0;
};
let diffs = get_differences(input);
input.last().unwrap() + extrapolate_sequence(&diffs)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_differences() {
assert_eq!(get_differences(&[0, 3, 6, 9, 12, 15]), vec![3, 3, 3, 3, 3]);
assert_eq!(get_differences(&[1, 3, 6, 10, 15, 21]), vec![2, 3, 4, 5, 6]);
}
#[test]
fn test_extrapolate_sequence() {
assert_eq!(extrapolate_sequence(&[0, 3, 6, 9, 12, 15]), 18);
assert_eq!(extrapolate_sequence(&[1, 3, 6, 10, 15, 21]), 28);
}
#[test]
fn test_parse() {
let input = concat!("0 3 6 9 12 15\n", "1 3 6 10 15 21\n", "10 13 16 21 30 45\n",);
assert_eq!(
parse(input),
vec![
vec![0, 3, 6, 9, 12, 15],
vec![1, 3, 6, 10, 15, 21],
vec![10, 13, 16, 21, 30, 45],
]
);
}
}

20
days/day09/src/part1.rs Normal file
View file

@ -0,0 +1,20 @@
use crate::parse::*;
pub fn part1(input: &[Vec<i32>]) -> i32 {
input.iter().map(|l| extrapolate_sequence(l)).sum()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_part1() {
let input = vec![
vec![0, 3, 6, 9, 12, 15],
vec![1, 3, 6, 10, 15, 21],
vec![10, 13, 16, 21, 30, 45],
];
assert_eq!(part1(&input), 114);
}
}

26
days/day09/src/part2.rs Normal file
View file

@ -0,0 +1,26 @@
use crate::parse::*;
pub fn part2(input: &mut [Vec<i32>]) -> i32 {
input
.iter_mut()
.map(|l| {
l.reverse();
extrapolate_sequence(l)
})
.sum()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_part2() {
let mut input = vec![
vec![0, 3, 6, 9, 12, 15],
vec![1, 3, 6, 10, 15, 21],
vec![10, 13, 16, 21, 30, 45],
];
assert_eq!(part2(&mut input), 2);
}
}