diff --git a/.github/badges/typescript/2023.json b/.github/badges/typescript/2023.json index 60974030c..60b983ecd 100644 --- a/.github/badges/typescript/2023.json +++ b/.github/badges/typescript/2023.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "label": "Advent of TypeScript 2023", - "message": "7/25", + "message": "8/25", "color": "orange" } diff --git a/resources/2023/09/example.1.txt b/resources/2023/09/example.1.txt index e69de29bb..539a763f9 100644 --- a/resources/2023/09/example.1.txt +++ b/resources/2023/09/example.1.txt @@ -0,0 +1,3 @@ +0 3 6 9 12 15 +1 3 6 10 15 21 +10 13 16 21 30 45 diff --git a/resources/2023/09/input.txt b/resources/2023/09/input.txt index e69de29bb..e27a50ab9 100644 --- a/resources/2023/09/input.txt +++ b/resources/2023/09/input.txt @@ -0,0 +1,200 @@ +-7 -12 -15 -4 52 210 556 1204 2291 3968 6387 9684 13958 19246 25494 32524 39997 47372 53861 58380 59496 +26 33 38 39 24 -37 -200 -556 -1249 -2520 -4807 -8956 -16641 -31137 -58573 -109554 -200280 -350497 -572000 -834815 -986998 +10 8 -4 -34 -93 -195 -357 -599 -944 -1418 -2050 -2872 -3919 -5229 -6843 -8805 -11162 -13964 -17264 -21118 -25585 +21 39 67 108 165 241 339 462 613 795 1011 1264 1557 1893 2275 2706 3189 3727 4323 4980 5701 +3 1 1 3 7 13 21 31 43 57 73 91 111 133 157 183 211 241 273 307 343 +18 31 60 117 214 379 701 1432 3189 7329 16639 36626 77951 160976 324057 638253 1232796 2338487 4361058 8005003 14482876 +15 31 52 76 95 91 35 -105 -328 -491 -43 2534 10778 32073 80618 182013 380053 746451 1394354 2496672 4310409 +5 18 50 114 230 437 813 1520 2903 5696 11440 23315 47743 97340 196095 388084 751768 1423532 2638127 4803908 8656019 +10 26 46 69 94 120 146 171 194 214 230 241 246 244 234 215 186 146 94 29 -50 +8 33 84 174 316 523 808 1184 1664 2261 2988 3858 4884 6079 7456 9028 10808 12809 15044 17526 20268 +10 16 22 28 34 40 46 52 58 64 70 76 82 88 94 100 106 112 118 124 130 +15 37 76 141 244 400 627 946 1381 1959 2710 3667 4866 6346 8149 10320 12907 15961 19536 23689 28480 +6 19 49 111 219 384 612 900 1230 1576 1990 2964 6551 19286 58956 169005 447286 1100773 2546075 5589445 11743235 +16 20 28 58 140 332 759 1694 3717 8010 16870 34558 68697 132699 250360 465212 860174 1598764 3009836 5757282 11170690 +15 29 66 150 332 703 1410 2687 4920 8772 15401 26811 46383 79640 135307 226734 373757 605079 961260 1498412 2292702 +28 54 93 142 195 243 274 273 222 100 -117 -456 -947 -1623 -2520 -3677 -5136 -6942 -9143 -11790 -14937 +9 9 19 59 173 455 1091 2422 5039 9929 18701 33933 59695 102319 171505 281872 455085 722713 1129999 1740751 2643593 +2 -5 -17 -34 -56 -83 -115 -152 -194 -241 -293 -350 -412 -479 -551 -628 -710 -797 -889 -986 -1088 +27 44 70 109 177 327 693 1563 3505 7600 15895 32302 64374 126734 247466 479526 920171 1742408 3243236 5913435 10531915 +7 14 34 92 234 540 1148 2304 4471 8563 16424 31756 61844 120716 235022 455395 879407 1699618 3305944 6503840 12973594 +4 2 -9 -34 -84 -174 -299 -365 -34 1594 6601 19408 48842 111674 238435 482629 934848 1743762 3146515 5511714 9398960 +2 7 15 29 62 158 433 1144 2800 6344 13465 27151 52680 99392 183848 335480 606798 1092065 1961807 3526801 6356210 +18 41 88 188 380 723 1322 2366 4172 7226 12216 20084 32223 51179 82712 141071 261346 526763 1126648 2475832 5454162 +24 30 31 30 43 112 332 897 2167 4760 9679 18492 33608 58801 100511 171511 301116 561862 1134657 2458966 5563819 +17 18 13 1 -15 -17 45 276 873 2209 5060 11203 24861 55914 126575 284603 628537 1354628 2842299 5806873 11567617 +24 51 95 156 237 355 565 1016 2073 4575 10375 23458 52230 114175 245324 519544 1087839 2258100 4655484 9540665 19430952 +19 39 80 161 316 603 1127 2099 3960 7615 14875 29338 58211 116057 232232 464960 926697 1827791 3548602 6754367 12572358 +21 26 27 30 57 159 434 1062 2395 5188 11140 24047 52075 111985 236673 488289 980745 1918046 3659225 6827652 12493381 +11 14 30 66 139 286 586 1213 2554 5455 11707 24959 52352 107313 214137 415224 782133 1431972 2551068 4428360 7501537 +14 19 29 44 64 89 119 154 194 239 289 344 404 469 539 614 694 779 869 964 1064 +1 2 2 1 -1 -4 -8 -13 -19 -26 -34 -43 -53 -64 -76 -89 -103 -118 -134 -151 -169 +-2 11 36 86 195 429 896 1749 3183 5447 8933 14479 24150 42963 82327 166410 343260 703339 1409226 2741660 5168885 +10 20 35 58 96 162 280 513 1056 2481 6312 16277 40885 98516 227218 503362 1077221 2241409 4563704 9145831 18125849 +22 49 89 142 208 287 379 484 602 733 877 1034 1204 1387 1583 1792 2014 2249 2497 2758 3032 +15 21 35 61 101 153 209 253 259 189 -9 -403 -1079 -2143 -3723 -5971 -9065 -13211 -18645 -25635 -34483 +-2 14 39 66 96 148 269 556 1215 2710 6111 13847 31221 69262 149787 313937 635948 1244534 2355007 4316152 7676926 +9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 +15 11 8 12 30 70 141 253 417 645 950 1346 1848 2472 3235 4155 5251 6543 8052 9800 11810 +16 35 81 180 380 760 1452 2698 4979 9276 17566 33740 65285 126337 243135 463544 873234 1622377 2968439 5342892 9452554 +11 30 58 108 203 372 644 1035 1520 1978 2093 1188 -2038 -9908 -26347 -57701 -113863 -209786 -367476 -618572 -1007635 +15 14 15 40 126 325 704 1345 2345 3816 5885 8694 12400 17175 23206 30695 39859 50930 64155 79796 98130 +8 1 1 16 56 151 390 996 2461 5774 12784 26749 53131 100706 183067 320607 543078 892831 1428851 2231710 3409570 +-4 -6 0 22 61 103 109 1 -358 -1176 -2678 -4838 -6583 -3865 14489 75023 235088 610398 1422316 3076286 6288101 +-4 2 29 89 206 426 827 1529 2704 4586 7481 11777 17954 26594 38391 54161 74852 101554 135509 178121 230966 +11 7 10 24 57 137 352 941 2487 6301 15140 34474 74609 154087 304922 580395 1066323 1896939 3276774 5510220 9040777 +0 9 36 91 201 421 841 1598 2927 5335 10074 20259 43292 95823 213469 469154 1006538 2098973 4250264 8361843 16002531 +3 2 -4 -5 24 136 449 1227 3033 6990 15194 31331 61558 115716 208951 363827 613023 1002714 1596744 2481707 3773060 +23 41 70 117 189 293 436 625 867 1169 1538 1981 2505 3117 3824 4633 5551 6585 7742 9029 10453 +11 34 79 164 323 618 1163 2185 4162 8093 15970 31537 61436 116855 215808 386192 669781 1127332 1844993 2942218 4581409 +2 -1 -8 -11 7 81 295 857 2261 5616 13273 29939 64515 132896 261853 493753 891056 1537941 2533594 3966993 5855571 +9 24 44 83 171 359 729 1418 2674 4991 9430 18330 36745 75109 153879 311458 618211 1203433 2312086 4430714 8569879 +21 28 35 42 49 56 63 70 77 84 91 98 105 112 119 126 133 140 147 154 161 +15 30 51 76 94 92 89 220 916 3259 9641 24957 58787 129492 272039 552912 1097949 2142712 4120439 7810174 14577780 +25 34 38 41 57 127 363 1042 2780 6824 15511 32958 66068 125969 230056 404897 690419 1146046 1859868 2962543 4648555 +13 20 25 23 19 44 179 592 1609 3877 8756 19244 42075 92261 202456 441349 948165 1994674 4092379 8171381 15869523 +17 41 84 162 315 632 1293 2644 5329 10505 20162 37565 67844 118813 202255 336247 549717 891429 1447064 2370020 3933877 +-4 -4 -6 -3 32 168 559 1520 3661 8129 17052 34356 67260 128982 243564 454318 838302 1530574 2763890 4932187 8689836 +21 36 58 88 129 204 398 935 2302 5443 12081 25300 50644 98181 186290 348545 646521 1194900 2213606 4140102 7873009 +6 15 37 95 226 485 949 1721 2934 4755 7389 11083 16130 22873 31709 43093 57542 75639 98037 125463 158722 +26 33 38 53 100 211 428 803 1398 2285 3546 5273 7568 10543 14320 19031 24818 31833 40238 50205 61916 +13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 +-1 -5 -7 7 58 169 355 603 846 953 777 316 42 1444 7831 25471 65179 144329 288383 528047 880284 +16 37 84 183 375 715 1263 2064 3114 4309 5374 5769 4569 315 -9167 -26982 -57420 -106251 -181064 -291653 -450453 +-9 -16 -15 8 78 249 646 1541 3480 7490 15408 30396 57782 106632 193238 349694 645265 1237744 2490535 5225428 11241258 +6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 +9 24 45 80 159 362 868 2031 4490 9327 18302 34215 61460 106826 180579 297996 482421 774183 1259055 2153089 4032831 +25 38 66 137 288 567 1056 1943 3691 7390 15456 32991 70382 148147 305694 616617 1214493 2334958 4382230 8031325 14381100 +7 15 19 30 69 166 369 783 1675 3704 8376 18904 41804 89824 187241 379242 748115 1440417 2711277 4994670 9012019 +10 19 36 71 137 252 457 864 1765 3864 8736 19666 43078 90843 183903 358000 673213 1231362 2211150 3944505 7087722 +1 0 9 37 92 183 336 630 1257 2608 5385 10737 20416 36947 63804 105582 168153 258792 386257 560805 794124 +7 23 64 146 292 538 942 1592 2615 4204 6710 10898 18538 33580 64249 126623 251174 496993 988119 2012050 4282547 +15 20 20 16 26 108 392 1121 2701 5760 11216 20354 34912 57176 90084 137339 203531 294268 416316 577748 788102 +9 25 44 75 141 284 570 1094 1985 3411 5584 8765 13269 19470 27806 38784 52985 71069 93780 121951 156509 +12 24 50 107 230 493 1033 2074 3944 7074 11976 19245 29766 45595 72484 125747 241996 499812 1051746 2166411 4269742 +4 5 11 30 72 162 365 833 1889 4167 8833 17925 34877 65342 118513 209272 361690 614673 1030919 1710840 2813734 +13 26 55 117 259 577 1247 2591 5220 10320 20188 39202 75539 144153 271842 505889 929479 1691809 3073055 5633760 10563703 +2 -2 -6 -10 -14 -18 -22 -26 -30 -34 -38 -42 -46 -50 -54 -58 -62 -66 -70 -74 -78 +-3 2 13 41 118 306 700 1434 2707 4852 8478 14727 25710 45224 79913 141128 247873 431406 742307 1261141 2114246 +5 17 39 90 210 467 976 1958 3876 7688 15260 30002 57853 108882 200052 360256 639926 1130114 2001512 3585305 6540007 +15 13 11 11 28 105 342 960 2443 5837 13345 29472 63220 132374 272077 552245 1112903 2234801 4477099 8938033 17733340 +13 29 64 142 301 593 1084 1854 2997 4621 6848 9814 13669 18577 24716 32278 41469 52509 65632 81086 99133 +7 6 3 6 42 170 503 1251 2807 5923 12077 24229 48318 96077 190053 372128 717359 1355604 2504191 4515832 7947098 +22 45 80 139 257 502 990 1915 3621 6768 12684 24063 46277 89719 173760 333018 626564 1150191 2050568 3537423 5885029 +19 39 62 91 136 222 401 774 1542 3123 6407 13303 27917 59080 125658 267324 565574 1183315 2437609 4932039 9799403 +13 39 82 158 305 605 1224 2477 4937 9647 18591 35790 69821 139424 285570 596660 1259756 2662305 5589969 11604510 23754656 +20 37 67 119 222 433 841 1574 2823 4910 8452 14716 26327 48588 91804 175177 333062 624651 1148489 2063629 3619708 +10 28 66 136 250 420 658 976 1386 1900 2530 3288 4186 5236 6450 7840 9418 11196 13186 15400 17850 +-2 2 12 28 50 78 112 152 198 250 308 372 442 518 600 688 782 882 988 1100 1218 +17 36 66 114 193 339 641 1284 2616 5270 10398 20110 38288 72157 135556 256184 491973 967546 1952936 4027884 8414357 +28 46 66 82 79 25 -141 -516 -1204 -2175 -2846 -1040 9359 43356 134829 356082 855556 1930208 4164434 8696518 17726951 +18 34 56 90 149 262 490 951 1856 3558 6616 11876 20571 34442 55882 88105 135342 203066 298248 429646 608129 +1 14 52 135 299 606 1152 2064 3474 5472 8091 11490 16706 27678 55745 128531 306103 708578 1561022 3263593 6497501 +26 35 54 101 210 459 1021 2247 4786 9746 18908 35032 62362 107599 181987 305990 519769 906021 1637793 3074055 5941677 +2 0 9 37 96 210 424 813 1505 2765 5243 10589 22844 51480 118013 270396 614080 1377682 3047777 6636265 14192164 +16 25 30 33 50 117 297 694 1483 2968 5683 10554 19143 33998 59136 100689 167746 273427 436228 681679 1044360 +5 20 47 90 153 240 355 502 685 908 1175 1490 1857 2280 2763 3310 3925 4612 5375 6218 7145 +13 34 63 97 141 229 474 1171 2992 7343 17022 37471 79240 162916 328921 656537 1299655 2551560 4958169 9509285 17951519 +3 14 42 95 197 413 895 1952 4153 8494 16718 32015 60634 115570 224723 448242 914020 1888110 3911402 8061836 16456294 +23 48 90 155 263 467 876 1683 3205 5951 10746 18954 32861 56300 95624 161160 269307 445474 728090 1173957 1865259 +-1 -2 -1 5 36 141 404 940 1877 3320 5293 7655 9986 11439 10554 5030 -8549 -35038 -81109 -155687 -270448 +11 25 44 68 100 159 303 676 1613 3863 9033 20440 44731 94996 196874 400767 806522 1613201 3218219 6411314 12746745 +-3 7 29 71 152 309 621 1260 2571 5170 10040 18618 32939 56116 93940 159434 284165 543545 1109122 2350886 5031720 +8 25 53 91 148 259 522 1172 2706 6083 13057 26780 52976 102302 195076 370513 704232 1340654 2552368 4849815 9188938 +11 10 19 52 123 246 435 704 1067 1538 2131 2860 3739 4782 6003 7416 9035 10874 12947 15268 17851 +21 45 80 126 183 251 330 420 521 633 756 890 1035 1191 1358 1536 1725 1925 2136 2358 2591 +12 38 90 180 320 522 798 1160 1620 2190 2882 3708 4680 5810 7110 8592 10268 12150 14250 16580 19152 +15 17 12 9 28 100 267 582 1109 1923 3110 4767 7002 9934 13693 18420 24267 31397 39984 50213 62280 +-2 -5 1 32 110 261 516 919 1563 2707 5074 10492 23117 51569 112419 235587 472348 906795 1671775 2970496 5105200 +22 34 46 58 70 82 94 106 118 130 142 154 166 178 190 202 214 226 238 250 262 +0 14 47 100 167 233 272 245 98 -240 -859 -1870 -3407 -5629 -8722 -12901 -18412 -25534 -34581 -45904 -59893 +22 29 41 65 113 217 457 1019 2323 5302 11977 26556 57373 120063 242471 472089 887804 1620547 2894245 5113131 9050185 +-4 -12 -20 -18 9 77 204 436 932 2157 5249 12662 29301 64695 137563 285857 588692 1212470 2503306 5163322 10571721 +11 10 16 54 170 448 1045 2252 4589 8942 16750 30250 52788 89204 146299 233392 362975 551474 820124 1195966 1712974 +19 27 37 58 115 269 654 1544 3470 7425 15241 30322 59107 113964 218739 418975 799961 1517371 2847425 5266382 9572911 +18 30 48 81 138 228 360 543 786 1098 1488 1965 2538 3216 4008 4923 5970 7158 8496 9993 11658 +23 38 60 103 202 425 898 1853 3709 7196 13532 24663 43576 74695 124370 201469 318083 490354 739436 1092599 1584486 +10 30 57 90 134 201 301 414 436 100 -1113 -4038 -9804 -19633 -34329 -53282 -72762 -83222 -65267 16122 219594 +18 37 59 77 89 119 257 737 2091 5458 13218 30313 67006 144605 307223 645703 1345819 2784351 5718225 11651616 23537332 +13 29 57 110 210 394 726 1333 2498 4871 9916 20832 44446 95147 203176 432257 917156 1943272 4113576 8694033 18317055 +20 34 47 53 45 19 -22 -64 -78 -16 193 647 1475 2841 4948 8042 12416 18414 26435 36937 50441 +29 43 60 81 119 220 502 1220 2862 6278 12841 24636 44670 77093 127417 202717 311795 465285 675674 957211 1325673 +4 14 32 58 103 203 455 1103 2730 6650 15651 35334 76444 158813 317842 614848 1153116 2102190 3733962 6475774 10988569 +-6 3 18 46 111 256 536 997 1636 2337 2778 2304 -239 -6714 -19952 -44065 -84818 -150065 -250254 -399006 -613773 +3 0 -5 2 49 178 445 920 1687 2844 4503 6790 9845 13822 18889 25228 33035 42520 53907 67434 83353 +9 30 65 118 198 331 582 1087 2091 3984 7323 12824 21304 33549 50080 70785 94381 117666 134517 134586 101642 +-5 2 17 37 63 99 156 281 647 1767 4943 13148 32695 76318 168742 356542 725203 1427944 2733245 5101343 9304511 +12 18 38 78 145 247 393 593 858 1200 1632 2168 2823 3613 4555 5667 6968 8478 10218 12210 14477 +4 14 35 76 144 239 343 400 297 -102 -732 -637 3658 21424 73609 202479 486349 1061162 2152334 4125664 7580615 +-4 0 22 68 143 257 438 756 1368 2613 5238 10954 23751 52802 118430 263584 574668 1217502 2496790 4950864 9497815 +22 25 28 36 64 148 365 870 1970 4280 9050 18840 38925 80299 166247 346793 730052 1548654 3296591 7003574 14772202 +5 20 42 61 66 53 42 103 392 1216 3194 7673 17703 40066 89052 192788 402783 806672 1542498 2809649 4865920 +17 28 34 29 2 -63 -187 -396 -721 -1198 -1868 -2777 -3976 -5521 -7473 -9898 -12867 -16456 -20746 -25823 -31778 +1 11 40 93 176 304 516 905 1677 3270 6610 13677 28725 60787 128585 269839 558589 1137165 2274968 4476021 8673986 +0 9 23 52 134 365 941 2212 4756 9504 18009 33091 60358 111566 211519 411317 812344 1607571 3149667 6059214 11391174 +-1 2 21 62 129 227 362 530 679 617 -166 -2775 -9229 -22608 -46525 -82945 -126649 -153596 -98989 181088 973125 +1 6 11 17 28 50 90 155 251 382 549 749 974 1210 1436 1623 1733 1718 1519 1065 272 +3 16 55 142 320 662 1273 2280 3815 6018 9129 13826 22150 39720 80624 177668 403234 911346 2022969 4400897 9411153 +21 27 29 31 41 82 216 580 1426 3144 6240 11276 18927 30688 51546 97360 212087 503765 1213827 2842497 6364457 +13 29 60 125 257 504 931 1634 2790 4777 8412 15398 29192 56784 112427 225337 454995 920189 1851652 3683467 7205779 +21 32 42 51 59 66 72 77 81 84 86 87 87 86 84 81 77 72 66 59 51 +2 8 32 89 194 362 608 947 1394 1964 2672 3533 4562 5774 7184 8807 10658 12752 15104 17729 20642 +10 25 54 105 201 393 787 1597 3235 6448 12511 23484 42540 74370 125670 205714 327016 506083 764260 1128667 1633227 +22 28 33 44 77 167 384 855 1792 3526 6547 11550 19487 31625 49610 75537 112026 162304 230293 320704 439137 +-3 -1 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 +7 15 32 58 93 137 190 252 323 403 492 590 697 813 938 1072 1215 1367 1528 1698 1877 +17 21 21 12 -11 -53 -119 -214 -343 -511 -723 -984 -1299 -1673 -2111 -2618 -3199 -3859 -4603 -5436 -6363 +12 15 14 18 53 162 402 834 1507 2452 3727 5589 8914 16041 32281 68407 144526 295829 580820 1092740 1975027 +19 30 55 112 217 385 641 1044 1739 3077 5881 11987 25253 53306 110387 221757 430243 805632 1457763 2554322 4344513 +0 8 31 87 201 419 837 1645 3186 6030 11063 19591 33459 55185 88109 136557 206020 303348 436959 617063 855901 +8 8 23 72 173 351 669 1299 2661 5678 12230 25954 53659 107856 211323 405350 764498 1422568 2617277 4765208 8584341 +10 21 56 138 298 583 1085 2016 3879 7817 16252 33936 69503 137518 260882 473380 822467 1373787 2222838 3528329 5601145 +9 24 57 137 306 616 1121 1864 2872 4203 6157 9902 19024 42956 104001 251014 585373 1310025 2823055 5899338 12049064 +12 18 35 81 190 419 858 1643 2972 5124 8481 13553 21006 31693 46688 67323 95228 132374 181119 244257 325070 +-1 9 27 53 87 129 179 237 303 377 459 549 647 753 867 989 1119 1257 1403 1557 1719 +10 26 40 58 97 189 387 773 1468 2644 4538 7468 11851 18223 27261 39807 56894 79774 109948 149198 199621 +12 27 59 122 230 397 637 964 1392 1935 2607 3422 4394 5537 6865 8392 10132 12099 14307 16770 19502 +17 34 58 90 133 194 294 500 1019 2439 6275 16094 39675 92955 207041 440650 902763 1795846 3502510 6765480 13066239 +6 13 27 48 76 111 153 202 258 321 391 468 552 643 741 846 958 1077 1203 1336 1476 +3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 98 103 +22 30 38 46 54 62 70 78 86 94 102 110 118 126 134 142 150 158 166 174 182 +13 31 51 67 70 50 -2 -92 -221 -383 -563 -735 -860 -884 -736 -326 457 1747 3703 6511 10386 +11 29 49 80 144 281 556 1068 1961 3437 5771 9328 14582 22137 32750 47356 67095 93341 127733 172208 229036 +4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 84 89 94 99 104 +9 17 30 46 67 98 149 249 487 1107 2720 6796 16830 41035 98230 229920 523593 1155193 2462790 5068886 10075793 +3 14 34 71 147 303 596 1086 1827 2907 4636 8083 16364 37469 90117 215327 498335 1108488 2369202 4876467 9693301 +10 22 47 112 266 587 1189 2229 3914 6508 10339 15806 23386 33641 47225 64891 87498 116018 151543 195292 248618 +3 10 27 68 169 402 899 1895 3816 7471 14456 27943 54110 104575 200340 377950 698857 1263392 2231345 3852006 6507719 +-3 8 42 120 268 512 880 1436 2386 4311 8597 18147 38475 79297 156749 296377 537059 936034 1575228 2569082 4074102 +11 33 67 115 185 308 565 1124 2287 4547 8655 15697 27181 45134 72209 111802 168179 246613 353531 496671 685249 +15 36 76 146 269 492 916 1761 3499 7129 14758 30837 64762 136225 285924 596426 1231879 2512340 5051614 10012540 19582519 +12 35 65 96 134 223 483 1172 2795 6294 13364 26951 51999 96524 173104 300885 508214 836021 1342083 2106314 3237236 +19 31 63 144 313 618 1134 2021 3659 6921 13679 27696 56171 112438 220799 425430 807170 1515600 2830766 5282589 9883584 +17 27 54 121 258 503 915 1607 2805 4941 8809 15880 29026 54195 104053 205275 411997 828992 1650047 3222417 6164976 +-2 3 16 53 155 401 928 1963 3872 7231 12924 22273 37205 60461 95852 148567 225538 335867 491320 706893 1001455 +29 40 45 42 27 -7 -67 -151 -224 -160 380 2182 6914 17942 41896 91756 193152 397830 813746 1674138 3496382 +12 33 66 118 206 357 608 1006 1608 2481 3702 5358 7546 10373 13956 18422 23908 30561 38538 48006 59142 +16 15 13 8 -7 -45 -127 -285 -566 -1037 -1791 -2954 -4693 -7225 -10827 -15847 -22716 -31961 -44219 -60252 -80963 +-4 -13 -14 14 95 258 559 1135 2298 4670 9350 18091 33449 58847 98475 156922 238408 345453 476786 624260 768499 +6 15 36 66 111 206 448 1059 2520 5862 13288 29478 64280 138143 292787 611477 1256190 2533329 5005920 9678986 18296673 +8 22 41 66 101 158 262 456 806 1406 2383 3902 6171 9446 14036 20308 28692 39686 53861 71866 94433 +-6 2 23 69 171 404 934 2110 4640 9908 20519 41219 80447 152956 284221 517809 927702 1639134 2864587 4967525 8577419 +19 21 26 51 139 376 905 1941 3800 6964 12213 20864 35166 58909 98314 163280 269073 438551 705028 1115889 1737077 +-8 -14 -13 15 110 339 808 1686 3259 6058 11153 20794 39749 78015 156223 316369 643186 1306846 2647988 5344768 10733542 +23 41 71 117 186 302 546 1130 2508 5520 11553 22694 41876 73163 122785 202782 342178 617688 1231576 2697244 6259895 +0 -3 0 14 46 120 303 742 1712 3675 7350 13794 24494 41470 67389 105690 160720 237881 343788 486438 675390 +16 21 36 77 164 322 591 1058 1925 3633 7084 14067 28150 56628 114724 234236 480269 981541 1981877 3923003 7572927 +14 42 86 157 283 515 946 1762 3353 6534 12977 26073 52715 107095 218858 450380 932348 1934410 4000108 8194885 16545679 +8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 +25 49 91 152 228 310 384 431 427 343 145 -206 -754 -1548 -2642 -4095 -5971 -8339 -11273 -14852 -19160 +13 26 39 52 65 78 91 104 117 130 143 156 169 182 195 208 221 234 247 260 273 +-2 -4 -7 -12 -18 -16 11 72 129 48 -388 -1203 -1248 4341 29829 110604 326340 846101 2016617 4537901 9819082 +21 43 77 134 232 396 658 1057 1639 2457 3571 5048 6962 9394 12432 16171 20713 26167 32649 40282 49196 +9 17 30 48 71 99 132 170 213 261 314 372 435 503 576 654 737 825 918 1016 1119 +11 26 68 152 295 516 836 1278 1867 2630 3596 4796 6263 8032 10140 12626 15531 18898 22772 27200 32231 +21 28 45 87 182 385 806 1673 3460 7117 14444 28654 55171 102708 184667 320898 539847 881114 1398431 2163057 3267572 +21 41 71 111 174 307 623 1358 2982 6407 13344 26874 52349 98899 182210 330037 593379 1068709 1940557 3559633 6580216 +10 32 62 97 140 223 448 1055 2546 5937 13294 28869 61457 129185 269104 556250 1141342 2324930 4701926 9439533 18802318 +8 11 9 13 60 236 704 1739 3779 7505 13962 24740 42303 70832 118781 206492 387275 801621 1808345 4286788 10307017 +-4 4 30 81 178 381 834 1842 4011 8515 17615 35679 71196 140721 276443 540304 1049619 2022584 3858311 7278269 13581299 +14 31 61 128 269 534 986 1701 2768 4289 6379 9166 12791 17408 23184 30299 38946 49331 61673 76204 93169 diff --git a/solutions/typescript/2023/08/package.json b/solutions/typescript/2023/08/package.json index 984acf577..0a0bff184 100644 --- a/solutions/typescript/2023/08/package.json +++ b/solutions/typescript/2023/08/package.json @@ -61,6 +61,11 @@ "import": "./dist/p2.js", "default": "./dist/p2.js" }, + "./parse": { + "types": "./src/parse.ts", + "import": "./dist/parse.js", + "default": "./dist/parse.js" + }, "./readme": "./readme.md" }, "dependencies": { diff --git a/solutions/typescript/2023/09/src/p1.spec.ts b/solutions/typescript/2023/09/src/p1.spec.ts index 28d01a292..40702d850 100644 --- a/solutions/typescript/2023/09/src/p1.spec.ts +++ b/solutions/typescript/2023/09/src/p1.spec.ts @@ -7,14 +7,14 @@ describe('2023 09 p1', () => { describe('the input', () => { it('should solve the input', async () => { const resources = await loadTaskResources(packageJson.aoc); - expect(p1(resources.input)).toEqual(0); + expect(p1(resources.input)).toEqual(1_938_731_307); }); }); describe('example 1', () => { it('should be solved', async () => { const resources = await loadTaskResources(packageJson.aoc, 'example.1.txt'); - expect(p1(resources.input)).toEqual(0); + expect(p1(resources.input)).toEqual(114); }); }); }); diff --git a/solutions/typescript/2023/09/src/p1.ts b/solutions/typescript/2023/09/src/p1.ts index d508a960e..f1ee21373 100644 --- a/solutions/typescript/2023/09/src/p1.ts +++ b/solutions/typescript/2023/09/src/p1.ts @@ -1,8 +1,21 @@ import { task } from '@alexaegis/advent-of-code-lib'; import packageJson from '../package.json'; +import { extrapolateSequence, parse } from './parse.js'; -export const p1 = (_input: string): number => { - return 0; +const extrapolateNextInStack = (sequenceStack: number[][]): number[][] => { + let carry = sequenceStack.last().last(); + for (let i = sequenceStack.length - 1; i >= 0; i--) { + carry = (sequenceStack[i]?.last() ?? 0) + carry; + sequenceStack[i]?.push(carry); + } + return sequenceStack; }; -await task(p1, packageJson.aoc); // 0 ~0ms +export const p1 = (input: string): number => + parse(input) + .map(extrapolateSequence) + .map(extrapolateNextInStack) + .map((extrapolatedStack) => extrapolatedStack.first().last()) + .sum(); + +await task(p1, packageJson.aoc); // 1938731307 ~1.57ms diff --git a/solutions/typescript/2023/09/src/p2.spec.ts b/solutions/typescript/2023/09/src/p2.spec.ts index 574032a00..55272fb69 100644 --- a/solutions/typescript/2023/09/src/p2.spec.ts +++ b/solutions/typescript/2023/09/src/p2.spec.ts @@ -7,14 +7,14 @@ describe('2023 09 p2', () => { describe('the input', () => { it('should solve the input', async () => { const { input } = await loadTaskResources(packageJson.aoc); - expect(p2(input)).toEqual(0); + expect(p2(input)).toEqual(948); }); }); describe('example 1', () => { it('should be solved', async () => { const { input } = await loadTaskResources(packageJson.aoc, 'example.1.txt'); - expect(p2(input)).toEqual(0); + expect(p2(input)).toEqual(2); }); }); }); diff --git a/solutions/typescript/2023/09/src/p2.ts b/solutions/typescript/2023/09/src/p2.ts index 68c39bd1c..fd76e562e 100644 --- a/solutions/typescript/2023/09/src/p2.ts +++ b/solutions/typescript/2023/09/src/p2.ts @@ -1,8 +1,21 @@ import { task } from '@alexaegis/advent-of-code-lib'; import packageJson from '../package.json'; +import { extrapolateSequence, parse } from './parse.js'; -export const p2 = (_input: string): number => { - return 0; +const extrapolatePreviousInStack = (sequenceStack: number[][]): number[][] => { + let carry = sequenceStack.last().first(); + for (let i = sequenceStack.length - 1; i >= 0; i--) { + carry = (sequenceStack[i]?.first() ?? 0) - carry; + sequenceStack[i]?.unshift(carry); + } + return sequenceStack; }; -await task(p2, packageJson.aoc); // 0 ~0ms +export const p2 = (input: string): number => + parse(input) + .map(extrapolateSequence) + .map(extrapolatePreviousInStack) + .map((extrapolatedStack) => extrapolatedStack.first().first()) + .sum(); + +await task(p2, packageJson.aoc); // 948 ~1.62ms diff --git a/solutions/typescript/2023/09/src/parse.ts b/solutions/typescript/2023/09/src/parse.ts new file mode 100644 index 000000000..ef3a39c79 --- /dev/null +++ b/solutions/typescript/2023/09/src/parse.ts @@ -0,0 +1,15 @@ +export const parse = (input: string): number[][] => + input.lines(false).map((line) => line.splitToInt()); + +export const extrapolateSequence = (sequence: number[]): number[][] => { + const sequenceStack: number[][] = [sequence]; + while (sequenceStack.last().some((i) => i !== 0)) { + sequenceStack.push( + sequenceStack + .last() + .slideWindow(2, 1) + .map(([left, right]) => right - left), + ); + } + return sequenceStack; +}; diff --git a/solutions/typescript/readme.md b/solutions/typescript/readme.md index 27dd98f74..d209ed737 100644 --- a/solutions/typescript/readme.md +++ b/solutions/typescript/readme.md @@ -16,7 +16,7 @@ | [Day 6](/solutions/typescript/2023/06/) | [40μs](/solutions/typescript/2023/06/src/p1.ts) | [7μs](/solutions/typescript/2023/06/src/p2.ts) | | [Day 7](/solutions/typescript/2023/07/) | [8.70ms](/solutions/typescript/2023/07/src/p1.ts) | [20.46ms](/solutions/typescript/2023/07/src/p2.ts) | | [Day 8](/solutions/typescript/2023/08/) | [10.25ms](/solutions/typescript/2023/08/src/p1.ts) | [11.44ms](/solutions/typescript/2023/08/src/p2.ts) | -| Day 9 | - | - | +| [Day 9](/solutions/typescript/2023/09/) | [1.57ms](/solutions/typescript/2023/09/src/p1.ts) | [1.62ms](/solutions/typescript/2023/09/src/p2.ts) | | Day 10 | - | - | | Day 11 | - | - | | Day 12 | - | - |