2023 Day 9

main
Petra 2023-12-09 19:22:31 +13:00
parent 14ecdadb1c
commit d8478c465b
5 changed files with 293 additions and 2 deletions

View File

@ -2,7 +2,7 @@ FC:=gfortran
FFLAGS:=-Wall -Wno-maybe-uninitialized FFLAGS:=-Wall -Wno-maybe-uninitialized
BIN:=./bin BIN:=./bin
SRC:=./src SRC:=./src
BINS:=./bin/day01.bin ./bin/day01b.bin ./bin/day02.bin ./bin/day03.bin ./bin/day04.bin ./bin/day05.bin ./bin/day05b.bin ./bin/day06.bin ./bin/day07.bin ./bin/day07b.bin ./bin/day08.bin ./bin/day08b.bin BINS:=./bin/day01.bin ./bin/day01b.bin ./bin/day02.bin ./bin/day03.bin ./bin/day04.bin ./bin/day05.bin ./bin/day05b.bin ./bin/day06.bin ./bin/day07.bin ./bin/day07b.bin ./bin/day08.bin ./bin/day08b.bin ./bin/day09.bin
all: aoc19 all: aoc19

201
2023/data/day09.txt 100644
View File

@ -0,0 +1,201 @@
4 7 14 17 8 -3 40 284 1054 3047 7774 18514 42224 93097 198790 410780 820904 1587039 2972406 5405827 9575760
13 26 44 80 164 361 809 1779 3761 7595 14712 27667 51418 96397 185632 370526 764205 1608876 3406248 7160410 14814288
7 29 66 132 264 549 1164 2429 4873 9313 16946 29454 49122 78969 122892 185823 273899 394645 557170 772376 1053180
4 12 30 67 132 234 382 585 852 1192 1614 2127 2740 3462 4302 5269 6372 7620 9022 10587 12324
2 -7 -12 5 83 304 825 1930 4126 8339 16326 31524 60745 117473 228159 444058 863130 1669793 3205496 6091003 11433015
19 37 58 82 109 139 172 208 247 289 334 382 433 487 544 604 667 733 802 874 949
13 38 85 173 329 598 1062 1881 3394 6351 12388 24919 50736 102855 205682 404727 785534 1511550 2900900 5582289 10809214
22 36 50 64 78 92 106 120 134 148 162 176 190 204 218 232 246 260 274 288 302
12 19 44 94 170 273 428 741 1505 3379 7690 16965 35920 73403 146423 288884 571005 1142650 2328614 4832776 10161751
13 31 55 85 121 163 211 265 325 391 463 541 625 715 811 913 1021 1135 1255 1381 1513
-1 -6 -11 -16 -21 -26 -31 -36 -41 -46 -51 -56 -61 -66 -71 -76 -81 -86 -91 -96 -101
-7 -4 1 5 18 78 281 836 2166 5113 11395 24648 52730 112561 239752 506795 1055794 2154637 4288752 8302746 15603689
10 10 6 10 58 234 708 1799 4086 8613 17277 33560 63876 119961 222947 410039 745066 1334612 2351960 4071710 6918670
6 -1 -4 6 38 101 204 356 566 843 1196 1634 2166 2801 3548 4416 5414 6551 7836 9278 10886
18 33 58 89 113 102 19 -151 -332 -237 816 4165 12155 28592 59313 112885 201446 341701 556086 874113 1333909
9 36 76 129 195 274 366 471 589 720 864 1021 1191 1374 1570 1779 2001 2236 2484 2745 3019
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
12 14 14 25 84 272 747 1794 3893 7803 14657 26060 44179 71811 112412 170067 249378 355244 492504 665411 876902
5 13 24 55 145 366 834 1719 3252 5736 9593 15522 24904 40677 69058 122831 227727 435239 849010 1679301 3353475
10 22 53 118 232 410 667 1018 1478 2062 2785 3662 4708 5938 7367 9010 10882 12998 15373 18022 20960
14 29 48 76 124 218 413 811 1591 3074 5862 11106 20993 39660 75101 143587 280453 566488 1190981 2597257 5806239
15 33 77 165 319 573 988 1673 2824 4813 8382 15035 27824 53013 103809 208864 431181 908257 1932899 4107549 8624741
0 6 20 51 122 297 735 1784 4130 9028 18687 37000 71067 134442 253856 482482 924903 1782520 3435024 6588364 12553249
12 24 34 38 31 7 -41 -121 -242 -414 -648 -956 -1351 -1847 -2459 -3203 -4096 -5156 -6402 -7854 -9533
13 32 57 100 187 357 665 1191 2060 3502 6052 11145 22655 50458 118076 278353 644947 1455264 3196219 6854814 14412615
15 34 66 133 280 581 1139 2078 3525 5580 8272 11499 14950 18007 19625 18188 11339 -4218 -32946 -80735 -155196
0 19 52 99 160 235 324 427 544 675 820 979 1152 1339 1540 1755 1984 2227 2484 2755 3040
11 26 63 142 292 548 958 1619 2768 4961 9380 18315 35875 68989 128765 232282 404897 683156 1118405 1781204 2766654
-3 9 28 56 113 247 537 1093 2078 3815 7117 14120 30148 67548 153076 341406 738867 1543937 3114970 6082220 11532363
6 24 62 125 229 410 741 1367 2569 4881 9326 17946 35052 70144 144457 304889 652104 1394482 2947110 6106207 12345559
2 3 22 69 150 282 532 1089 2378 5225 11082 22321 42606 77352 134280 224077 361170 564623 859166 1276365 1855942
7 14 28 42 58 106 286 856 2410 6225 14921 33702 72677 151193 305960 606484 1184929 2294888 4428038 8545010 16526252
9 12 31 92 230 485 896 1493 2287 3258 4341 5410 6260 6587 5966 3827 -571 -8168 -20133 -37896 -63182
1 14 51 136 315 677 1382 2701 5086 9304 16688 29580 52066 91131 158393 272609 463183 774946 1274521 2058632 3264765
13 25 39 68 145 346 837 1954 4338 9181 18700 37050 72020 138034 261208 487500 895339 1614537 2853781 4939576 8370171
-7 -9 -13 -8 42 219 678 1686 3698 7521 14657 27996 53216 101691 196743 387406 778956 1600221 3349773 7107057 15179205
16 24 40 65 104 176 320 592 1048 1708 2496 3151 3104 1316 -3928 -15274 -36608 -73424 -133256 -226179 -365384
-1 13 48 119 245 449 767 1284 2219 4089 8014 16311 33700 69739 143527 292235 585572 1148764 2196908 4083479 7364698
7 13 38 90 172 282 413 553 685 787 832 788 618 280 -273 -1093 -2237 -3767 -5750 -8258 -11368
0 -1 7 35 92 188 342 595 1028 1785 3101 5335 9008 14846 23828 37239 56728 84371 122739 174971 244852
27 47 73 114 189 331 594 1067 1900 3344 5800 9861 16316 26066 39879 57884 78673 97845 105787 84444 2783
2 -3 5 37 110 259 567 1228 2666 5762 12302 25860 53476 108682 216668 422661 804906 1493979 2700515 4753783 8153866
2 7 34 93 193 357 646 1190 2236 4245 8109 15629 30517 60387 120517 240638 476686 930395 1780876 3333989 6097449
21 35 49 61 65 50 -1 -112 -315 -651 -1171 -1937 -3023 -4516 -6517 -9142 -12523 -16809 -22167 -28783 -36863
11 25 52 109 215 389 663 1131 2061 4105 8657 18436 38415 77283 149720 279890 506719 891729 1530450 2568735 4225663
7 12 21 34 51 72 97 126 159 196 237 282 331 384 441 502 567 636 709 786 867
-1 5 24 73 186 425 907 1857 3705 7258 14006 26685 50350 94441 176685 330182 615659 1141583 2095476 3790157 6728418
15 29 60 126 262 540 1099 2180 4173 7718 13983 25401 47434 92431 187518 390006 816655 1698669 3485638 7045690 14060466
21 44 79 133 219 349 521 709 881 1097 1789 4415 12831 35974 92880 221911 497941 1065530 2205607 4473153 8983035
22 47 88 152 257 437 752 1310 2301 4034 6973 11811 19729 33185 57884 107000 209244 422965 859074 1716102 3331013
19 38 61 94 159 317 705 1587 3419 6928 13205 23812 40903 67359 106937 164433 245859 358634 511789 716186 984751
15 39 75 123 183 255 339 435 543 663 795 939 1095 1263 1443 1635 1839 2055 2283 2523 2775
18 29 46 74 118 183 274 396 554 753 998 1294 1646 2059 2538 3088 3714 4421 5214 6098 7078
1 0 -2 -7 -18 -26 29 336 1343 3952 9792 21583 43604 82278 146887 250430 410637 651152 1002898 1505637 2209738
9 22 54 107 180 269 367 464 547 600 604 537 374 87 -355 -986 -1843 -2966 -4398 -6185 -8376
15 30 63 128 258 533 1138 2479 5409 11662 24677 51151 103958 207625 408542 793752 1524859 2897750 5445011 10106818 18508538
3 11 27 66 172 435 1017 2207 4546 9091 17922 35038 67837 129431 242110 442339 787749 1366667 2310821 3811954 6143186
26 52 104 199 370 676 1223 2215 4061 7571 14281 26954 50311 92053 164242 285116 481420 791342 1268150 1984633 3038456
10 20 58 146 322 647 1212 2158 3735 6437 11263 20184 36980 68838 129680 247589 481942 963055 1982435 4192778 9037066
-3 0 19 79 235 602 1400 3014 6069 11520 20757 35725 59059 94234 145730 219212 321725 461904 650199 899115 1223467
2 9 16 23 30 37 44 51 58 65 72 79 86 93 100 107 114 121 128 135 142
8 10 20 50 115 236 457 892 1832 3957 8722 19039 40491 83533 167515 327971 629536 1188172 2208208 4042144 7284363
5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65
8 26 65 146 316 663 1341 2624 5023 9514 17937 33635 62411 113908 203613 355960 609658 1027726 1717281 2868628 4830662
9 17 37 78 149 259 417 632 913 1269 1709 2242 2877 3623 4489 5484 6617 7897 9333 10934 12709
20 38 78 154 280 470 738 1098 1564 2150 2870 3738 4768 5974 7370 8970 10788 12838 15134 17690 20520
7 24 47 81 136 225 362 557 805 1066 1233 1085 222 -2021 -6684 -15319 -30157 -54308 -91997 -148839 -232156
0 1 -2 -3 9 62 236 730 1970 4767 10534 21571 41427 75348 130820 218216 351556 549389 835806 1241593 1805533
3 6 17 53 156 407 939 1945 3678 6448 10644 16862 26335 42111 71980 135406 279566 615947 1402676 3226260 7393115
10 14 24 34 47 98 296 908 2528 6411 15120 33747 72146 148909 298384 583295 1118426 2117292 3987296 7525720 14319117
6 9 14 40 129 360 864 1837 3555 6422 11141 19209 34150 64331 129087 271621 585396 1266455 2713600 5713306 11768647
20 46 99 205 403 741 1279 2113 3437 5662 9612 16817 29922 53229 93386 160233 267810 435526 689481 1063925 1602829
1 -3 -16 -37 -52 -24 125 554 1603 4032 9538 21770 48166 103065 212703 422887 810357 1499095 2683124 4657661 7860848
15 27 41 48 38 19 62 398 1607 4947 12880 29877 63658 127217 242445 447220 810212 1462984 2670744 4988351 9600271
30 55 99 181 341 651 1226 2235 3912 6567 10597 16497 24871 36443 52068 72743 99618 134007 177399 231469 298089
8 19 40 95 231 522 1073 2037 3667 6440 11313 20214 36973 69143 131709 254841 500234 995487 2006112 4085673 8387151
12 29 60 119 244 510 1052 2120 4203 8274 16223 31560 60485 113437 207249 368051 635078 1065555 1740846 2774069 4319394
21 35 62 112 205 390 770 1534 3007 5757 10855 20481 39217 76578 151615 300791 590793 1138511 2141100 3919854 6982573
-1 0 5 14 27 44 65 90 119 152 189 230 275 324 377 434 495 560 629 702 779
15 25 54 108 189 298 441 637 927 1383 2116 3282 5085 7776 11647 17019 24223 33573 45330 59656 76557
13 15 16 23 58 163 406 888 1751 3187 5448 8857 13820 20839 30526 43618 60993 83687 112912 150075 196798
8 21 34 47 60 73 86 99 112 125 138 151 164 177 190 203 216 229 242 255 268
0 9 40 105 216 385 624 945 1360 1881 2520 3289 4200 5265 6496 7905 9504 11305 13320 15561 18040
5 9 31 90 225 511 1093 2256 4558 9063 17712 33854 62927 113248 196881 330673 537887 851569 1322065 2033214 3135009
14 32 65 126 231 399 652 1015 1516 2186 3059 4172 5565 7281 9366 11869 14842 18340 22421 27146 32579
16 31 59 114 216 393 692 1217 2225 4328 8874 18619 38863 79316 157097 301464 561142 1015477 1791117 3086528 5207418
25 48 85 150 280 562 1170 2410 4780 9072 16583 29586 52395 93748 172014 326185 638123 1275552 2571281 5162458 10224290
25 46 83 141 230 371 602 984 1607 2596 4117 6383 9660 14273 20612 29138 40389 54986 73639 97153 126434
18 31 60 135 311 678 1382 2668 4956 8961 15868 27573 47001 78512 128406 205538 322054 494259 743628 1097971 1592763
21 48 96 181 334 609 1091 1904 3219 5262 8322 12759 19012 27607 39165 54410 74177 99420 131220 170793 219498
18 28 41 75 171 406 911 1901 3730 7004 12834 23400 43124 80886 153787 292822 550230 1006860 1775083 2987825 4756165
7 16 48 120 261 531 1049 2030 3831 7006 12370 21072 34677 55257 85491 128774 189335 272364 384148 532216 725493
8 11 29 87 229 520 1042 1880 3091 4646 6332 7598 7326 3505 -7217 -30131 -73246 -148283 -271921 -467335 -766069
7 13 24 59 160 415 991 2177 4437 8473 15298 26319 43430 69115 106561 159781 233747 334533 469468 647299 878364
18 32 60 116 213 363 585 940 1624 3168 6820 15212 33440 70732 143055 277580 521391 960022 1757523 3240240 6062704
-4 -7 -1 28 110 302 699 1445 2744 4871 8183 13130 20266 30260 43907 62139 86036 116837 155951 204968 265670
22 35 67 129 230 384 629 1065 1918 3637 7031 13453 25038 45002 78009 130613 211782 333511 511531 766121 1123030
15 33 77 173 374 787 1624 3286 6502 12571 23801 44317 81531 148727 269365 483718 858087 1495811 2547551 4216723 6757554
18 47 97 189 354 628 1047 1642 2434 3429 4613 5947 7362 8754 9979 10848 11122 10507 8649 5129 -542
14 25 46 95 214 486 1051 2114 3943 6866 11288 17755 27083 40535 59955 87640 125532 173023 222266 249351 199012
18 36 60 90 126 168 216 270 330 396 468 546 630 720 816 918 1026 1140 1260 1386 1518
14 32 64 129 250 457 795 1334 2178 3470 5390 8143 11934 16927 23185 30588 38726 46764 53276 56045 51826
24 48 80 114 151 204 309 562 1228 3014 7682 19333 46981 109581 245726 532281 1120276 2304490 4659592 9309226 18462519
9 28 63 134 279 559 1060 1903 3283 5568 9499 16542 29453 53127 95812 170779 298549 509788 848991 1379086 2187099
8 8 7 5 2 -2 -7 -13 -20 -28 -37 -47 -58 -70 -83 -97 -112 -128 -145 -163 -182
-1 2 18 60 141 274 472 748 1115 1586 2174 2892 3753 4770 5956 7324 8887 10658 12650 14876 17349
20 27 34 41 48 55 62 69 76 83 90 97 104 111 118 125 132 139 146 153 160
10 30 62 108 170 257 399 681 1326 2881 6603 15220 34388 75445 160625 333097 676895 1357967 2711435 5430457 10976083
23 27 33 52 106 235 504 1010 1889 3323 5547 8856 13612 20251 29290 41334 57083 77339 103013 135132 174846
4 11 21 34 50 69 91 116 144 175 209 246 286 329 375 424 476 531 589 650 714
-4 -1 2 10 34 98 272 758 2068 5345 12890 28970 60994 121156 228656 412622 715868 1199635 1949474 3082442 4755794
21 30 31 25 13 -9 -55 -154 -355 -732 -1389 -2465 -4139 -6635 -10227 -15244 -22075 -31174 -43065 -58347 -77699
4 12 30 76 187 427 907 1844 3713 7600 15961 34160 73458 156678 328807 676706 1365506 2705112 5269876 10109828 19115437
9 23 58 116 205 355 653 1320 2867 6390 14107 30327 63214 128026 253037 490173 933684 1752420 3245799 5943513 10791206
17 16 22 56 148 344 725 1445 2800 5360 10241 19669 38091 74208 144420 278248 526283 971040 1740680 3024798 5090230
13 16 25 41 65 98 141 195 261 340 433 541 665 806 965 1143 1341 1560 1801 2065 2353
21 40 64 103 184 349 650 1152 1962 3302 5631 9792 17133 29596 50051 83992 145651 275472 582970 1341041 3177182
3 6 24 80 206 440 830 1452 2457 4176 7328 13390 25196 47830 89862 164942 293711 505906 842424 1356964 2116682
12 21 34 62 123 239 446 841 1713 3847 9168 22032 51708 116973 254314 532059 1073914 2096945 3971102 7310034 13106297
17 19 17 20 47 136 362 858 1829 3555 6414 11046 18963 34255 67667 145431 327161 740367 1644463 3545588 7396567
11 33 61 102 174 306 538 921 1517 2399 3651 5368 7656 10632 14424 19171 25023 32141 40697 50874 62866
10 22 44 75 115 171 284 598 1506 3938 9915 23607 53356 115562 242174 495118 993898 1967721 3852127 7463913 14308751
9 12 19 51 139 320 640 1186 2180 4174 8380 17155 34671 67931 128748 238449 439487 822724 1587149 3161951 6441487
11 32 68 126 212 338 545 948 1813 3685 7610 15551 31215 61722 120906 235602 457115 881274 1682148 3166760 5861114
4 6 11 16 18 14 1 -24 -64 -122 -201 -304 -434 -594 -787 -1016 -1284 -1594 -1949 -2352 -2806
5 14 17 8 -10 0 154 721 2238 5692 12832 26749 53001 101813 192341 360811 675779 1266182 2371803 4432002 8238072
7 17 40 78 149 302 645 1396 2970 6128 12256 23945 46252 89397 174271 343099 679057 1340763 2620584 5039928 9500511
11 26 61 121 225 420 795 1495 2735 4814 8129 13189 20629 31224 45903 65763 92083 126338 170213 225617 294697
6 5 11 28 67 169 437 1072 2412 4986 9617 17649 31475 55807 100744 188965 371746 762575 1603683 3390746 7095403
11 14 26 58 124 244 467 942 2078 4844 11280 25359 54540 112843 227363 452379 899585 1801110 3636518 7379896 14964376
7 13 23 37 73 185 497 1265 2992 6660 14232 29750 61661 127515 263009 538679 1089674 2167524 4228610 8083880 15151202
12 34 65 112 187 307 494 775 1182 1752 2527 3554 4885 6577 8692 11297 14464 18270 22797 28132 34367
24 45 76 117 168 229 300 381 472 573 684 805 936 1077 1228 1389 1560 1741 1932 2133 2344
20 42 81 151 274 474 782 1271 2159 4052 8462 18855 42715 95570 208876 445649 931901 1920493 3921194 7964326 16129275
14 15 20 43 112 286 687 1547 3270 6509 12258 21959 37624 61972 98581 152055 228206 334251 479024 673203 929552
16 26 49 113 263 564 1104 1997 3386 5446 8387 12457 17945 25184 34554 46485 61460 80018 102757 130337 163483
13 21 44 91 174 319 600 1215 2635 5876 12970 27755 57206 113784 219872 416611 781841 1466127 2763048 5241467 9985262
10 18 39 92 210 445 881 1679 3202 6299 12868 26894 56330 116568 237008 473629 932842 1815712 3497445 6665552 12552178
23 44 67 91 132 234 485 1058 2316 5059 11078 24359 53620 117500 254920 545448 1149018 2383217 4873604 9845500 19687217
6 0 -11 -24 -30 -11 77 345 1046 2694 6237 13294 26466 49731 88933 152375 251526 401852 623781 943812 1395778
18 30 64 146 315 625 1163 2110 3899 7565 15437 32402 68116 140840 284229 559773 1080416 2056576 3886978 7338046 13894977
6 15 34 63 102 151 210 279 358 447 546 655 774 903 1042 1191 1350 1519 1698 1887 2086
4 14 24 34 50 101 285 867 2467 6406 15343 34475 73848 152844 308861 613987 1206919 2354222 4568737 8840286 17087455
-5 -9 -17 -29 -45 -65 -89 -117 -149 -185 -225 -269 -317 -369 -425 -485 -549 -617 -689 -765 -845
12 24 36 48 60 72 84 96 108 120 132 144 156 168 180 192 204 216 228 240 252
13 30 61 121 241 471 883 1574 2669 4324 6729 10111 14737 20917 29007 39412 52589 69050 89365 114165 144145
7 7 -2 -12 11 151 577 1589 3675 7579 14380 25582 43215 69947 109207 165319 243647 350751 494554 684520 931843
11 27 66 148 300 556 957 1551 2393 3545 5076 7062 9586 12738 16615 21321 26967 33671 41558 50760 61416
14 30 69 146 276 472 751 1158 1814 2986 5175 9257 16882 31826 64146 141378 335518 822406 2003157 4737816 10772536
10 15 24 43 93 234 605 1484 3378 7172 14414 27913 53008 100168 190085 363322 698366 1345713 2593620 4997599 9637955
1 -1 -5 -2 23 101 300 757 1721 3607 7061 13036 22879 38429 62126 97131 147457 218111 315247 446330 620311
-1 -2 13 54 133 274 525 984 1863 3623 7219 14497 28785 55717 104323 188409 328239 552516 900641 1425208 2194669
11 8 19 60 145 283 475 711 967 1202 1355 1342 1053 349 -941 -3023 -6141 -10580 -16669 -24784 -35351
-3 3 25 83 214 475 946 1733 2971 4827 7503 11239 16316 23059 31840 43081 57257 74899 96597 123003 154834
19 33 57 102 193 384 789 1647 3461 7290 15348 32218 67296 139654 287521 586270 1181494 2347838 4590050 8810205 16573334
16 32 67 130 228 380 644 1157 2188 4204 7949 14536 25552 43176 70310 110723 169208 251752 365719 520046 725452
-4 -7 -10 -13 -16 -19 -22 -25 -28 -31 -34 -37 -40 -43 -46 -49 -52 -55 -58 -61 -64
6 0 -1 13 58 174 463 1168 2842 6700 15319 33986 73261 153834 315684 635168 1256474 2448851 4710185 8954744 16855508
17 21 26 32 39 47 56 66 77 89 102 116 131 147 164 182 201 221 242 264 287
18 24 30 36 42 48 54 60 66 72 78 84 90 96 102 108 114 120 126 132 138
8 18 38 78 161 336 706 1485 3117 6535 13723 28886 60754 126884 261373 528410 1046221 2030675 3878211 7329809 13802378
1 17 57 142 316 673 1404 2874 5755 11276 21706 41270 77840 146004 272601 506680 937325 1725195 3157359 5740566 10356100
13 22 36 71 173 434 1019 2218 4544 8913 16968 31651 58210 106027 192137 348404 636607 1180136 2229164 4290479 8377331
20 33 62 124 239 433 751 1295 2308 4335 8522 17186 34930 70824 142590 284445 561536 1096265 2116210 4041472 7643885
12 19 31 71 180 417 862 1628 2883 4886 8068 13259 22292 39418 74260 147476 301083 617090 1252234 2506948 4971597
16 35 58 84 129 256 635 1653 4095 9414 20107 40227 76106 137465 239274 405034 672626 1104557 1805384 2950374 4831127
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
4 10 24 67 168 369 753 1517 3130 6644 14264 30331 62930 126403 245125 458989 831144 1458638 2486736 4127811 6685844
13 20 27 34 41 48 55 62 69 76 83 90 97 104 111 118 125 132 139 146 153
5 16 45 111 258 579 1257 2639 5370 10625 20488 38538 70713 126534 220782 375732 624059 1012542 1606703 2496529 3803436
-6 -11 -12 -1 30 89 184 323 514 765 1084 1479 1958 2529 3200 3979 4874 5893 7044 8335 9774
21 28 48 94 179 316 518 798 1169 1644 2236 2958 3823 4844 6034 7406 8973 10748 12744 14974 17451
20 40 75 133 225 363 558 818 1146 1538 1981 2451 2911 3309 3576 3624 3344 2604 1247 -911 -4083
-5 -5 -10 -19 -16 51 304 986 2544 5790 12260 25049 50716 103457 213853 446457 933805 1939865 3974510 7993713 15739652
16 18 28 61 142 309 631 1256 2504 5020 10002 19519 36934 67447 118773 201970 332432 531062 825640 1252401 1857838
9 26 54 85 113 139 174 240 369 600 974 1527 2281 3233 4342 5514 6585 7302 7302 6089 3009
14 28 45 76 143 279 537 1027 2014 4145 8946 19863 44343 97800 210836 441850 898246 1770938 3388859 6302846 11411751
21 40 65 95 140 248 555 1371 3318 7539 16000 31910 60287 108701 188228 314652 509955 804138 1237419 1862857 2749454
9 28 69 145 272 472 779 1255 2034 3432 6198 12056 24835 52745 112772 238757 495479 1001904 1967523 3746087 6910594
29 41 51 59 65 69 71 71 69 65 59 51 41 29 15 -1 -19 -39 -61 -85 -111
7 12 26 60 128 241 409 655 1039 1689 2845 4945 8822 16140 30276 57954 112055 216162 411548 767474 1395828
21 33 45 57 69 81 93 105 117 129 141 153 165 177 189 201 213 225 237 249 261
27 43 57 67 78 121 289 797 2086 5009 11158 23415 46838 90026 167145 300838 526281 896675 1490467 2420551 3845586
11 38 78 144 259 448 722 1052 1345 1456 1294 1103 2028 7144 23332 64994 162268 380677 869401 1978519 4534958
27 49 92 166 278 444 709 1166 1960 3258 5161 7529 9685 9959 5028 -10997 -47791 -120401 -251262 -472712 -830080
12 24 37 58 116 281 689 1587 3434 7123 14425 28799 56762 110070 209025 387294 698704 1226562 2096141 3491072 5674488
10 25 59 131 272 525 941 1574 2476 3690 5253 7284 10390 16936 34267 81829 205414 503567 1173671 2588513 5418388
15 22 35 54 79 110 147 190 239 294 355 422 495 574 659 750 847 950 1059 1174 1295
7 16 25 34 43 52 61 70 79 88 97 106 115 124 133 142 151 160 169 178 187
-4 -3 7 42 130 311 637 1172 1992 3185 4851 7102 10062 13867 18665 24616 31892 40677 51167 63570 78106
7 20 49 103 202 387 744 1466 2987 6226 12972 26422 51863 97498 175531 304013 510955 844516 1397947 2367673 4181236
6 26 73 177 381 744 1358 2398 4230 7602 13946 25860 47997 89012 166166 316082 618662 1247330 2569083 5334503 11023997
7 20 51 111 217 413 816 1711 3744 8301 18213 38991 80870 162026 313424 585857 1059845 1859178 3169007 5259511 8516295
24 38 64 115 219 438 907 1901 3931 7858 14997 27161 46568 75502 115582 166451 223650 275390 297878 248791 58425
8 22 50 114 257 555 1137 2218 4144 7436 12800 21040 32769 47757 63683 73968 64256 6978 -146722 -478602 -1119591
27 55 94 155 260 437 719 1147 1772 2646 3787 5098 6215 6254 3422 -5548 -26183 -67327 -142524 -271787 -483818
5 11 17 23 29 35 41 47 53 59 65 71 77 83 89 95 101 107 113 119 125
21 42 77 130 209 333 553 1010 2061 4521 10111 22298 47924 100469 206712 420389 850041 1715168 3457893 6961526 13970951
23 37 51 65 79 93 107 121 135 149 163 177 191 205 219 233 247 261 275 289 303
8 16 31 66 153 353 781 1672 3523 7350 15098 30236 58558 109195 195822 338018 562706 905564 1412257 2139294 3154263

View File

@ -0,0 +1,3 @@
0 3 6 9 12 15
1 3 6 10 15 21
10 13 16 21 30 45

87
2023/src/day09.f90 100644
View File

@ -0,0 +1,87 @@
program day9
implicit none
integer, parameter :: max_chars = 300
integer, parameter :: max_seqs = 1000
character(200) :: fname
character(max_chars) :: fline
integer :: n_arguments
integer :: istat
integer :: seq_len
integer, allocatable :: seq(:), revseq(:)
integer :: i, i2, lnum_sum, fnum_sum, thislseq, thisfseq
n_arguments = command_argument_count()
if (n_arguments .eq. 2) then
call get_command_argument(1, fname)
call get_command_argument(2, fline)
read(fline, *) seq_len
print *, "File: ", trim(fname)
print *, "Sequence length: ", seq_len
print *
else
print *, "Wrong number of arguments: ", n_arguments
stop
end if
allocate(seq(1:seq_len))
allocate(revseq(1:seq_len))
open(10, file=fname)
lnum_sum = 0
fnum_sum = 0
do i=1,max_seqs
read(10, "(a)", iostat=istat) fline
if ((len_trim(fline) .eq. 0) .or. (is_iostat_end(istat))) then
exit
end if
read(fline, *) seq
do i2=1,seq_len
revseq(i2) = seq(seq_len - i2 + 1)
end do
thislseq = seq(seq_len) + diffseq(seq, seq_len)
thisfseq = revseq(seq_len) + diffseq(revseq, seq_len)
lnum_sum = lnum_sum + thislseq
fnum_sum = fnum_sum + thisfseq
print *, i, thislseq, lnum_sum, thisfseq, fnum_sum
end do
print *, "Last number sum: ", lnum_sum
print *, "First number sum: ", fnum_sum
close(10)
deallocate(seq)
deallocate(revseq)
contains
recursive function diffseq(seqin, lenin) result(seqlast)
implicit none
integer, intent(in) :: seqin(:)
integer, intent(in) :: lenin
integer :: seqlast
integer, allocatable :: l1seq(:)
integer :: last_l2
integer :: i
integer :: diff
logical :: allsame
allsame = .true.
diff = seqin(lenin)
do i=1,lenin
if (seqin(i) .ne. diff) then
allsame = .false.
exit
end if
end do
if (allsame) then
seqlast = 0
else
allocate(l1seq(1:(lenin-1)), source=0)
do i=1, lenin-1
l1seq(i) = seqin(i+1) - seqin(i)
end do
last_l2 = diffseq(l1seq, lenin-1)
seqlast = l1seq(lenin - 1) + last_l2
deallocate(l1seq)
end if
end function diffseq
end program day9

View File

@ -4,9 +4,9 @@ program day
character(200) :: fname character(200) :: fname
character(max_chars) :: fline character(max_chars) :: fline
integer :: n_arguments integer :: n_arguments
n_arguments = command_argument_count()
integer :: istat integer :: istat
n_arguments = command_argument_count()
if (n_arguments .eq. 1) then if (n_arguments .eq. 1) then
call get_command_argument(1, fname) call get_command_argument(1, fname)
print *, "File: ", trim(fname) print *, "File: ", trim(fname)