├── .gitignore ├── README.md ├── p1.dyalog ├── p1.txt ├── p10.dyalog ├── p10.txt ├── p11.dyalog ├── p11.txt ├── p11nwise.dyalog ├── p12.dyalog ├── p12.txt ├── p13.dyalog ├── p13.txt ├── p14.dyalog ├── p14.txt ├── p14fast.dyalog ├── p15.txt ├── p16.dyalog ├── p16.txt ├── p17.dyalog ├── p17.txt ├── p18.dyalog ├── p18.txt ├── p19.dyalog ├── p19.txt ├── p2.dyalog ├── p2.txt ├── p20.dyalog ├── p20.txt ├── p21.dyalog ├── p21.txt ├── p22.dyalog ├── p22.txt ├── p23.dyalog ├── p23.txt ├── p24.txt ├── p25.dyalog ├── p25.txt ├── p3.dyalog ├── p3.txt ├── p3fast.dyalog ├── p4.dyalog ├── p4.txt ├── p5.dyalog ├── p5.txt ├── p5faster.dyalog ├── p5foldr.dyalog ├── p6.dyalog ├── p6.txt ├── p6flat.dyalog ├── p6linear.dyalog ├── p7.dyalog ├── p7.txt ├── p8.dyalog ├── p8.txt ├── p9.dyalog └── p9.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.dws 2 | *.so 3 | getinput 4 | *~ 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aoc2018apl 2 | Advent of Code 2018 solutions in Dyalog APL 3 | 4 | Tested on Linux with: 5 | ``` 6 | dyalog -script < pN.dyalog # Dyalog version 17.1 or earlier 7 | dyalog -script pN.dyalog # Dyalog version 18.0 or later 8 | ``` 9 | 10 | Some solutions require Dyalog APL version 17.0 or later. 11 | 12 | See also: 13 | * My [solutions for 2015](https://github.com/jayfoad/aoc2015apl). 14 | * My [solutions for 2016](https://github.com/jayfoad/aoc2016apl). 15 | * My [solutions for 2017](https://github.com/jayfoad/aoc2017apl). 16 | * My [solutions for 2019](https://github.com/jayfoad/aoc2019apl). 17 | * My [solutions for 2020](https://github.com/jayfoad/aoc2020apl). 18 | -------------------------------------------------------------------------------- /p1.dyalog: -------------------------------------------------------------------------------- 1 | p←⍎¨⊃⎕NGET'p1.txt'1 2 | +/p ⍝ part 1 3 | {⍬≢z←⍵/⍨(⍵⍳⍵)≠⍳≢⍵:⊃z ⋄ ∇⍵,⍵+⊃⌽⍵}+\p ⍝ part 2 4 | -------------------------------------------------------------------------------- /p1.txt: -------------------------------------------------------------------------------- 1 | -16 2 | +12 3 | -18 4 | -1 5 | +5 6 | -8 7 | +9 8 | -15 9 | +12 10 | +6 11 | +11 12 | +7 13 | -9 14 | +13 15 | +5 16 | -4 17 | -4 18 | -2 19 | -5 20 | +19 21 | +4 22 | +14 23 | +7 24 | +8 25 | -16 26 | -9 27 | +16 28 | +8 29 | -11 30 | -7 31 | +12 32 | +8 33 | +13 34 | +11 35 | +12 36 | -19 37 | +11 38 | +7 39 | +9 40 | -7 41 | -16 42 | -5 43 | +11 44 | -1 45 | +8 46 | +5 47 | +12 48 | -1 49 | -1 50 | +6 51 | -2 52 | -12 53 | +6 54 | -18 55 | +11 56 | +5 57 | +13 58 | -12 59 | -15 60 | -8 61 | -13 62 | +2 63 | -11 64 | +1 65 | -14 66 | -6 67 | +11 68 | -15 69 | +11 70 | +8 71 | +18 72 | -8 73 | +18 74 | -7 75 | -9 76 | -24 77 | -12 78 | +2 79 | +20 80 | -9 81 | -5 82 | -14 83 | -6 84 | +16 85 | -1 86 | -12 87 | -16 88 | +8 89 | +9 90 | -15 91 | -8 92 | -2 93 | -4 94 | -16 95 | -18 96 | -8 97 | +10 98 | +10 99 | +2 100 | +3 101 | -8 102 | -10 103 | -1 104 | -2 105 | +20 106 | -5 107 | -4 108 | -13 109 | +10 110 | +9 111 | -12 112 | -19 113 | +15 114 | -4 115 | -13 116 | -11 117 | -9 118 | -4 119 | -12 120 | +3 121 | -7 122 | -4 123 | +13 124 | +8 125 | -5 126 | +10 127 | -11 128 | +7 129 | +10 130 | +13 131 | +10 132 | -17 133 | -21 134 | +11 135 | +3 136 | +9 137 | -15 138 | -11 139 | +15 140 | +10 141 | -3 142 | +17 143 | +6 144 | +11 145 | +16 146 | +19 147 | +8 148 | +8 149 | +4 150 | +9 151 | +7 152 | +15 153 | +2 154 | +15 155 | +22 156 | +19 157 | +11 158 | +3 159 | +19 160 | +9 161 | -4 162 | +9 163 | -19 164 | -16 165 | +6 166 | +2 167 | -3 168 | +5 169 | +5 170 | -18 171 | +1 172 | -14 173 | -6 174 | -20 175 | +10 176 | -13 177 | +19 178 | -18 179 | -17 180 | +5 181 | -39 182 | +2 183 | +33 184 | +2 185 | +24 186 | -16 187 | +45 188 | +9 189 | +21 190 | +6 191 | +20 192 | +4 193 | -12 194 | -7 195 | -3 196 | +8 197 | +12 198 | +5 199 | -1 200 | +8 201 | +18 202 | -13 203 | -9 204 | +3 205 | +16 206 | -4 207 | +15 208 | +13 209 | -10 210 | -8 211 | -13 212 | -21 213 | +15 214 | +17 215 | +13 216 | -4 217 | -18 218 | -15 219 | +3 220 | +11 221 | +5 222 | +3 223 | +10 224 | -11 225 | +9 226 | +19 227 | -2 228 | +9 229 | +3 230 | -13 231 | +2 232 | -7 233 | -14 234 | -2 235 | -7 236 | -19 237 | +7 238 | +3 239 | -13 240 | +6 241 | +10 242 | +5 243 | -9 244 | -20 245 | -8 246 | +5 247 | -17 248 | +11 249 | -12 250 | +17 251 | -12 252 | -14 253 | +24 254 | -22 255 | -13 256 | +15 257 | +15 258 | +1 259 | -4 260 | +13 261 | -30 262 | +12 263 | +17 264 | +8 265 | +45 266 | +4 267 | -3 268 | -5 269 | +3 270 | -9 271 | +13 272 | +8 273 | +14 274 | +2 275 | -12 276 | -3 277 | +9 278 | +20 279 | +7 280 | +1 281 | +1 282 | -17 283 | -10 284 | +3 285 | -2 286 | +4 287 | -6 288 | +16 289 | -8 290 | +15 291 | +16 292 | +8 293 | -11 294 | -14 295 | -4 296 | +2 297 | +15 298 | +19 299 | +12 300 | +14 301 | +17 302 | -18 303 | -18 304 | -18 305 | -1 306 | -1 307 | -7 308 | -17 309 | -2 310 | -18 311 | +15 312 | -3 313 | +5 314 | -20 315 | +39 316 | -1 317 | +6 318 | +8 319 | +10 320 | +16 321 | -19 322 | +11 323 | +19 324 | +15 325 | -6 326 | +19 327 | -8 328 | +6 329 | +1 330 | -2 331 | -20 332 | -4 333 | +18 334 | +2 335 | -17 336 | -10 337 | -10 338 | -12 339 | +18 340 | +2 341 | -16 342 | -8 343 | +14 344 | -15 345 | +12 346 | -14 347 | -19 348 | -16 349 | -21 350 | -17 351 | +21 352 | -12 353 | -34 354 | -22 355 | -25 356 | -15 357 | +14 358 | -12 359 | -10 360 | +11 361 | -20 362 | +4 363 | -6 364 | -11 365 | +14 366 | +21 367 | +74 368 | +40 369 | +3 370 | +15 371 | -4 372 | +16 373 | +12 374 | +3 375 | +6 376 | +2 377 | +11 378 | +10 379 | -3 380 | +17 381 | -5 382 | +10 383 | +13 384 | +5 385 | -13 386 | -4 387 | +13 388 | -8 389 | +17 390 | -2 391 | +6 392 | -12 393 | +7 394 | +2 395 | +13 396 | -2 397 | -9 398 | +18 399 | +15 400 | -11 401 | +4 402 | +3 403 | -21 404 | -17 405 | +3 406 | +12 407 | -1 408 | -12 409 | -3 410 | -20 411 | -10 412 | +13 413 | -6 414 | -4 415 | -20 416 | +7 417 | +15 418 | -6 419 | -15 420 | -26 421 | +13 422 | +6 423 | -23 424 | -9 425 | -1 426 | +44 427 | +8 428 | -14 429 | +26 430 | +13 431 | +5 432 | +31 433 | +24 434 | +7 435 | -2 436 | +7 437 | -4 438 | +17 439 | -16 440 | -3 441 | +36 442 | -10 443 | -22 444 | -11 445 | +62 446 | -7 447 | +21 448 | -17 449 | -10 450 | -18 451 | +11 452 | +4 453 | +5 454 | -23 455 | -26 456 | -40 457 | +2 458 | +32 459 | +62 460 | +23 461 | +45 462 | +109 463 | -37 464 | -10 465 | -99 466 | -210 467 | -21 468 | -33 469 | +379 470 | +262 471 | +66 472 | +66407 473 | +13 474 | -8 475 | -14 476 | -16 477 | -6 478 | -19 479 | +12 480 | +15 481 | -10 482 | -19 483 | -8 484 | +12 485 | +13 486 | -11 487 | +18 488 | +7 489 | -11 490 | +14 491 | -12 492 | -11 493 | -2 494 | +4 495 | -19 496 | -9 497 | +3 498 | -5 499 | +7 500 | -4 501 | +9 502 | -19 503 | +20 504 | +7 505 | -14 506 | -2 507 | -7 508 | -8 509 | -2 510 | -16 511 | +8 512 | -10 513 | +1 514 | -4 515 | -16 516 | +2 517 | +1 518 | -13 519 | -2 520 | -3 521 | -16 522 | +5 523 | -6 524 | -17 525 | +3 526 | +9 527 | +14 528 | +1 529 | -11 530 | +6 531 | -2 532 | -12 533 | -10 534 | +11 535 | +19 536 | -9 537 | +5 538 | -11 539 | -8 540 | -17 541 | -19 542 | +8 543 | -3 544 | -17 545 | +13 546 | +14 547 | -16 548 | -8 549 | +19 550 | +17 551 | -16 552 | -16 553 | -13 554 | -11 555 | +9 556 | -19 557 | +6 558 | +12 559 | +5 560 | -12 561 | -12 562 | -16 563 | -14 564 | -6 565 | +7 566 | +8 567 | -12 568 | -18 569 | +12 570 | +13 571 | -17 572 | +3 573 | -5 574 | +1 575 | +6 576 | -4 577 | -18 578 | +1 579 | +11 580 | +2 581 | -8 582 | -15 583 | -17 584 | +16 585 | -10 586 | -12 587 | +16 588 | -14 589 | -1 590 | -11 591 | +5 592 | +14 593 | +20 594 | +16 595 | -18 596 | +16 597 | +17 598 | +13 599 | -9 600 | -6 601 | -16 602 | +19 603 | +13 604 | +8 605 | -13 606 | +1 607 | +19 608 | -12 609 | -20 610 | -20 611 | -11 612 | -12 613 | +4 614 | +12 615 | +6 616 | -17 617 | -9 618 | -3 619 | -18 620 | -15 621 | -2 622 | -5 623 | +17 624 | +12 625 | -8 626 | +4 627 | -12 628 | -7 629 | -18 630 | -4 631 | -1 632 | -19 633 | +1 634 | -7 635 | -8 636 | +5 637 | +1 638 | +19 639 | -7 640 | -19 641 | +18 642 | +12 643 | +6 644 | +19 645 | +8 646 | -1 647 | +20 648 | -17 649 | -16 650 | -5 651 | -1 652 | -3 653 | +6 654 | -13 655 | -2 656 | +6 657 | -8 658 | +12 659 | -13 660 | -3 661 | -13 662 | +8 663 | +4 664 | -16 665 | +19 666 | +18 667 | +16 668 | -13 669 | -1 670 | +3 671 | +9 672 | +18 673 | +1 674 | +3 675 | +14 676 | +10 677 | +3 678 | +1 679 | -8 680 | +18 681 | +4 682 | +26 683 | +22 684 | +13 685 | -12 686 | -7 687 | -3 688 | +6 689 | -17 690 | +5 691 | +14 692 | -7 693 | +12 694 | +10 695 | -7 696 | +8 697 | -7 698 | +18 699 | +17 700 | -6 701 | +12 702 | +17 703 | +2 704 | +3 705 | -9 706 | +18 707 | +10 708 | -17 709 | -10 710 | -2 711 | -13 712 | +6 713 | +4 714 | +17 715 | +12 716 | +14 717 | -15 718 | +5 719 | +17 720 | +4 721 | -1 722 | -14 723 | -19 724 | -1 725 | +5 726 | -15 727 | -16 728 | +1 729 | -11 730 | -13 731 | -5 732 | +15 733 | -4 734 | -15 735 | +1 736 | +22 737 | +17 738 | -20 739 | -21 740 | +13 741 | +1 742 | -2 743 | +17 744 | +23 745 | -35 746 | -14 747 | -18 748 | +6 749 | +1 750 | +1 751 | -13 752 | -10 753 | +34 754 | +35 755 | +8 756 | +4 757 | +14 758 | +24 759 | +16 760 | -5 761 | -2 762 | +10 763 | +16 764 | -10 765 | -11 766 | +1 767 | -2 768 | -3 769 | +7 770 | +5 771 | +20 772 | -14 773 | +2 774 | +2 775 | -5 776 | +14 777 | -18 778 | +23 779 | -3 780 | +2 781 | +4 782 | +2 783 | +7 784 | +8 785 | +3 786 | -16 787 | -5 788 | +4 789 | +12 790 | -20 791 | -15 792 | -22 793 | +5 794 | -10 795 | +31 796 | -2 797 | +9 798 | +10 799 | -14 800 | +18 801 | +6 802 | +3 803 | +19 804 | -15 805 | +9 806 | +7 807 | +18 808 | -1 809 | -8 810 | +19 811 | +12 812 | +1 813 | +16 814 | -5 815 | -4 816 | -9 817 | +16 818 | +13 819 | +2 820 | +7 821 | +5 822 | -3 823 | -19 824 | +12 825 | +9 826 | +2 827 | +9 828 | +16 829 | -17 830 | -13 831 | +12 832 | -5 833 | +11 834 | +4 835 | -1 836 | +2 837 | -6 838 | +18 839 | +19 840 | -10 841 | +3 842 | -19 843 | -19 844 | -13 845 | -16 846 | -2 847 | -13 848 | +8 849 | +18 850 | +6 851 | -11 852 | +2 853 | -16 854 | +11 855 | +12 856 | -20 857 | +18 858 | +17 859 | +14 860 | -13 861 | +26 862 | -1 863 | +20 864 | -1 865 | -17 866 | -11 867 | -8 868 | +13 869 | -7 870 | -5 871 | -5 872 | -7 873 | +18 874 | -20 875 | -4 876 | +29 877 | -2 878 | +21 879 | +21 880 | +16 881 | +15 882 | +14 883 | +21 884 | -15 885 | -14 886 | +17 887 | +5 888 | -10 889 | -27 890 | -18 891 | +10 892 | -20 893 | +34 894 | -13 895 | +18 896 | +17 897 | -21 898 | +32 899 | +13 900 | +6 901 | +6 902 | +28 903 | -37 904 | +20 905 | +29 906 | -25 907 | -69 908 | -57 909 | -3 910 | -59 911 | +3 912 | -21 913 | -9 914 | +14 915 | -19 916 | -18 917 | +20 918 | -5 919 | +15 920 | +5 921 | -9 922 | -24 923 | +20 924 | -14 925 | -10 926 | -15 927 | +30 928 | +21 929 | -9 930 | -34 931 | +4 932 | -31 933 | +25 934 | -85 935 | +25 936 | +38 937 | -36 938 | -28 939 | +58 940 | +121 941 | -31 942 | +13 943 | +202 944 | +66221 945 | -5 946 | -19 947 | -10 948 | -7 949 | -8 950 | -2 951 | +6 952 | -5 953 | -6 954 | +8 955 | -17 956 | +10 957 | +18 958 | +16 959 | +3 960 | -12 961 | -2 962 | -11 963 | +14 964 | +7 965 | +11 966 | -1 967 | -5 968 | +10 969 | +9 970 | -5 971 | -3 972 | -3 973 | -11 974 | -13 975 | +18 976 | -8 977 | -5 978 | +18 979 | +17 980 | -6 981 | +3 982 | +19 983 | -18 984 | +5 985 | +5 986 | -4 987 | -12 988 | +7 989 | +14 990 | +19 991 | -6 992 | +10 993 | -8 994 | -11 995 | +10 996 | -17 997 | +9 998 | +11 999 | +7 1000 | -133358 1001 | -------------------------------------------------------------------------------- /p10.dyalog: -------------------------------------------------------------------------------- 1 | p←↑⍎¨¨'-?\d+'⎕S'&'¨⊃⎕NGET'p10.txt'1 2 | v←0 2↓p ⋄ p←0 ¯2↓p 3 | mean←+⌿÷≢ 4 | n←⌊0.5+mean,-(p-⍤1 mean p)÷(v-⍤1 mean v) 5 | c←(⊢-⍤1⌊⌿)p+n×v 6 | ⍉'#'@(↓⎕IO+c)⊢(1+⌈⌿c)⍴'' ⍝ part 1 7 | n ⍝ part 2 8 | -------------------------------------------------------------------------------- /p10.txt: -------------------------------------------------------------------------------- 1 | position=<-42417, 32097> velocity=< 4, -3> 2 | position=<-10502, -10533> velocity=< 1, 1> 3 | position=<-53094, 32093> velocity=< 5, -3> 4 | position=<-53090, -21188> velocity=< 5, 2> 5 | position=< 53486, 21441> velocity=<-5, -2> 6 | position=<-21142, -42496> velocity=< 2, 4> 7 | position=<-42422, 32088> velocity=< 4, -3> 8 | position=< 42778, 10784> velocity=<-4, -1> 9 | position=< 10826, 42748> velocity=<-1, -4> 10 | position=<-10449, 53401> velocity=< 1, -5> 11 | position=<-42453, -21187> velocity=< 4, 2> 12 | position=< 32154, -31839> velocity=<-3, 3> 13 | position=<-42434, -53156> velocity=< 4, 5> 14 | position=<-21149, 32097> velocity=< 2, -3> 15 | position=<-10497, 53409> velocity=< 1, -5> 16 | position=<-42438, -53151> velocity=< 4, 5> 17 | position=< 21490, 10778> velocity=<-2, -1> 18 | position=< 42831, 42753> velocity=<-4, -4> 19 | position=< 53474, -42501> velocity=<-5, 4> 20 | position=<-42436, -21192> velocity=< 4, 2> 21 | position=< 53450, -53154> velocity=<-5, 5> 22 | position=< 32118, -21185> velocity=<-3, 2> 23 | position=<-21158, -10533> velocity=< 2, 1> 24 | position=< 10842, 42749> velocity=<-1, -4> 25 | position=< 53467, 21436> velocity=<-5, -2> 26 | position=< 32130, -53160> velocity=<-3, 5> 27 | position=< 32119, -53151> velocity=<-3, 5> 28 | position=< 32143, -21183> velocity=<-3, 2> 29 | position=<-10486, 10781> velocity=< 1, -1> 30 | position=<-53098, 21433> velocity=< 5, -2> 31 | position=<-10465, -42503> velocity=< 1, 4> 32 | position=<-53083, 10776> velocity=< 5, -1> 33 | position=< 32173, -53151> velocity=<-3, 5> 34 | position=<-31782, 21436> velocity=< 3, -2> 35 | position=< 32143, 10782> velocity=<-3, -1> 36 | position=< 21487, -42500> velocity=<-2, 4> 37 | position=<-53082, 42752> velocity=< 5, -4> 38 | position=< 42775, -21183> velocity=<-4, 2> 39 | position=< 53431, -53160> velocity=<-5, 5> 40 | position=<-53078, 10784> velocity=< 5, -1> 41 | position=<-10505, 53408> velocity=< 1, -5> 42 | position=< 21507, -53151> velocity=<-2, 5> 43 | position=< 42814, -53160> velocity=<-4, 5> 44 | position=< 53427, 53402> velocity=<-5, -5> 45 | position=<-21164, 10780> velocity=< 2, -1> 46 | position=< 21461, 53404> velocity=<-2, -5> 47 | position=< 32173, 21436> velocity=<-3, -2> 48 | position=<-53086, 21438> velocity=< 5, -2> 49 | position=< 32146, -42503> velocity=<-3, 4> 50 | position=< 32159, 21439> velocity=<-3, -2> 51 | position=< 53442, 42751> velocity=<-5, -4> 52 | position=<-31817, 42752> velocity=< 3, -4> 53 | position=< 53459, -21188> velocity=<-5, 2> 54 | position=< 21458, -21191> velocity=<-2, 2> 55 | position=<-21134, 53402> velocity=< 2, -5> 56 | position=<-10481, -10534> velocity=< 1, 1> 57 | position=<-21137, -53158> velocity=< 2, 5> 58 | position=<-21110, -31839> velocity=< 2, 3> 59 | position=<-21153, 21441> velocity=< 2, -2> 60 | position=<-31766, -42495> velocity=< 3, 4> 61 | position=< 42799, -53155> velocity=<-4, 5> 62 | position=<-42449, 42752> velocity=< 4, -4> 63 | position=<-53102, -10531> velocity=< 5, 1> 64 | position=<-21149, -10527> velocity=< 2, 1> 65 | position=<-31801, 53401> velocity=< 3, -5> 66 | position=<-10462, -31842> velocity=< 1, 3> 67 | position=<-31806, 42751> velocity=< 3, -4> 68 | position=<-10502, 10777> velocity=< 1, -1> 69 | position=<-53129, 10785> velocity=< 5, -1> 70 | position=< 10803, -21186> velocity=<-1, 2> 71 | position=< 42810, -31847> velocity=<-4, 3> 72 | position=< 53450, -21189> velocity=<-5, 2> 73 | position=< 53434, 21433> velocity=<-5, -2> 74 | position=<-21126, 32094> velocity=< 2, -3> 75 | position=< 53446, -53157> velocity=<-5, 5> 76 | position=< 21518, -31839> velocity=<-2, 3> 77 | position=<-21146, -53157> velocity=< 2, 5> 78 | position=< 32135, 32089> velocity=<-3, -3> 79 | position=<-53094, -21188> velocity=< 5, 2> 80 | position=< 32170, -53152> velocity=<-3, 5> 81 | position=<-42476, 21437> velocity=< 4, -2> 82 | position=<-42446, -31840> velocity=< 4, 3> 83 | position=< 53471, -42503> velocity=<-5, 4> 84 | position=< 10850, 42752> velocity=<-1, -4> 85 | position=<-21141, -10531> velocity=< 2, 1> 86 | position=<-10508, 53404> velocity=< 1, -5> 87 | position=< 42818, -21190> velocity=<-4, 2> 88 | position=< 21483, -42503> velocity=<-2, 4> 89 | position=<-10482, -42503> velocity=< 1, 4> 90 | position=<-53089, -31847> velocity=< 5, 3> 91 | position=< 32162, 32092> velocity=<-3, -3> 92 | position=<-31763, 42753> velocity=< 3, -4> 93 | position=<-10462, -10535> velocity=< 1, 1> 94 | position=< 42831, 21433> velocity=<-4, -2> 95 | position=< 42819, -42504> velocity=<-4, 4> 96 | position=< 53426, -21192> velocity=<-5, 2> 97 | position=< 21475, -42495> velocity=<-2, 4> 98 | position=<-10462, 32092> velocity=< 1, -3> 99 | position=< 42802, -10533> velocity=<-4, 1> 100 | position=< 32146, 32088> velocity=<-3, -3> 101 | position=< 10831, -21184> velocity=<-1, 2> 102 | position=< 53466, 42752> velocity=<-5, -4> 103 | position=< 21516, -42499> velocity=<-2, 4> 104 | position=< 32159, -53152> velocity=<-3, 5> 105 | position=<-53123, 32097> velocity=< 5, -3> 106 | position=<-53126, 21434> velocity=< 5, -2> 107 | position=<-31790, -21189> velocity=< 3, 2> 108 | position=<-31789, -31843> velocity=< 3, 3> 109 | position=<-10502, -21185> velocity=< 1, 2> 110 | position=<-53124, 21441> velocity=< 5, -2> 111 | position=< 53486, 10779> velocity=<-5, -1> 112 | position=< 42805, -31846> velocity=<-4, 3> 113 | position=<-42470, 53406> velocity=< 4, -5> 114 | position=< 53469, -42495> velocity=<-5, 4> 115 | position=< 53450, 42751> velocity=<-5, -4> 116 | position=< 42822, -31843> velocity=<-4, 3> 117 | position=< 32133, 21436> velocity=<-3, -2> 118 | position=< 21487, 21437> velocity=<-2, -2> 119 | position=< 32149, -31841> velocity=<-3, 3> 120 | position=<-31778, -53151> velocity=< 3, 5> 121 | position=< 32175, -42504> velocity=<-3, 4> 122 | position=< 10834, 42750> velocity=<-1, -4> 123 | position=< 10855, 10777> velocity=<-1, -1> 124 | position=< 21492, 21438> velocity=<-2, -2> 125 | position=<-21131, 21434> velocity=< 2, -2> 126 | position=< 53455, 32091> velocity=<-5, -3> 127 | position=<-31786, 53408> velocity=< 3, -5> 128 | position=< 10829, 10781> velocity=<-1, -1> 129 | position=< 10831, -10529> velocity=<-1, 1> 130 | position=<-42460, 53405> velocity=< 4, -5> 131 | position=< 10813, -31839> velocity=<-1, 3> 132 | position=<-53076, 21432> velocity=< 5, -2> 133 | position=<-10452, -42499> velocity=< 1, 4> 134 | position=< 21487, -10534> velocity=<-2, 1> 135 | position=<-53082, 10781> velocity=< 5, -1> 136 | position=< 10839, -10527> velocity=<-1, 1> 137 | position=< 42770, 21441> velocity=<-4, -2> 138 | position=< 53466, -21185> velocity=<-5, 2> 139 | position=< 10812, 42753> velocity=<-1, -4> 140 | position=< 32156, 21432> velocity=<-3, -2> 141 | position=< 10803, 53407> velocity=<-1, -5> 142 | position=< 53430, 42747> velocity=<-5, -4> 143 | position=<-53114, 32088> velocity=< 5, -3> 144 | position=< 32156, 42748> velocity=<-3, -4> 145 | position=< 42802, -42499> velocity=<-4, 4> 146 | position=<-53110, -42500> velocity=< 5, 4> 147 | position=< 21474, -31840> velocity=<-2, 3> 148 | position=<-21166, 21432> velocity=< 2, -2> 149 | position=<-10506, 42746> velocity=< 1, -4> 150 | position=<-31819, -42499> velocity=< 3, 4> 151 | position=<-31769, -10528> velocity=< 3, 1> 152 | position=< 53426, 32088> velocity=<-5, -3> 153 | position=<-21150, -10529> velocity=< 2, 1> 154 | position=<-53086, 53408> velocity=< 5, -5> 155 | position=<-31782, 32095> velocity=< 3, -3> 156 | position=<-42449, 42747> velocity=< 4, -4> 157 | position=<-53098, -31847> velocity=< 5, 3> 158 | position=< 32162, -21185> velocity=<-3, 2> 159 | position=<-53110, -42497> velocity=< 5, 4> 160 | position=< 53455, -10532> velocity=<-5, 1> 161 | position=< 32157, -42504> velocity=<-3, 4> 162 | position=< 42802, -53155> velocity=<-4, 5> 163 | position=<-53106, 42749> velocity=< 5, -4> 164 | position=<-31781, -31848> velocity=< 3, 3> 165 | position=<-53100, 53403> velocity=< 5, -5> 166 | position=<-10508, -21187> velocity=< 1, 2> 167 | position=<-42477, 53407> velocity=< 4, -5> 168 | position=<-31795, -42504> velocity=< 3, 4> 169 | position=<-53077, -10527> velocity=< 5, 1> 170 | position=< 32133, 32097> velocity=<-3, -3> 171 | position=<-53090, 53409> velocity=< 5, -5> 172 | position=< 10847, 42749> velocity=<-1, -4> 173 | position=< 21466, -21192> velocity=<-2, 2> 174 | position=< 21476, -21192> velocity=<-2, 2> 175 | position=<-10462, 21439> velocity=< 1, -2> 176 | position=< 53430, -53153> velocity=<-5, 5> 177 | position=< 42831, -10534> velocity=<-4, 1> 178 | position=<-42435, 21432> velocity=< 4, -2> 179 | position=< 32131, 53400> velocity=<-3, -5> 180 | position=<-10481, -31844> velocity=< 1, 3> 181 | position=<-10478, 53404> velocity=< 1, -5> 182 | position=<-42438, -53160> velocity=< 4, 5> 183 | position=< 32170, -53153> velocity=<-3, 5> 184 | position=< 42778, 32092> velocity=<-4, -3> 185 | position=<-42427, 42753> velocity=< 4, -4> 186 | position=< 21476, -21183> velocity=<-2, 2> 187 | position=<-21126, -21191> velocity=< 2, 2> 188 | position=<-21118, -31842> velocity=< 2, 3> 189 | position=<-10505, -31848> velocity=< 1, 3> 190 | position=<-42421, -10536> velocity=< 4, 1> 191 | position=<-31779, 21436> velocity=< 3, -2> 192 | position=<-53106, 21437> velocity=< 5, -2> 193 | position=< 42807, -53151> velocity=<-4, 5> 194 | position=< 10810, 10778> velocity=<-1, -1> 195 | position=< 32154, -10534> velocity=<-3, 1> 196 | position=< 42814, -53160> velocity=<-4, 5> 197 | position=< 53430, 21439> velocity=<-5, -2> 198 | position=<-42462, 32097> velocity=< 4, -3> 199 | position=< 21506, 10777> velocity=<-2, -1> 200 | position=<-53092, -42495> velocity=< 5, 4> 201 | position=<-53081, -10528> velocity=< 5, 1> 202 | position=< 53471, -53153> velocity=<-5, 5> 203 | position=<-53106, -21187> velocity=< 5, 2> 204 | position=< 53450, 21437> velocity=<-5, -2> 205 | position=< 21515, -10527> velocity=<-2, 1> 206 | position=< 42791, -31846> velocity=<-4, 3> 207 | position=< 21463, 21433> velocity=<-2, -2> 208 | position=< 53485, 10776> velocity=<-5, -1> 209 | position=< 42790, -31848> velocity=<-4, 3> 210 | position=<-21122, -21192> velocity=< 2, 2> 211 | position=< 21511, 53406> velocity=<-2, -5> 212 | position=<-10505, -21192> velocity=< 1, 2> 213 | position=<-21163, 21436> velocity=< 2, -2> 214 | position=< 53426, -42496> velocity=<-5, 4> 215 | position=< 32162, 10781> velocity=<-3, -1> 216 | position=<-42470, -10527> velocity=< 4, 1> 217 | position=<-10458, 32093> velocity=< 1, -3> 218 | position=<-21105, 42745> velocity=< 2, -4> 219 | position=< 53479, -31840> velocity=<-5, 3> 220 | position=<-31805, 42744> velocity=< 3, -4> 221 | position=< 21498, 32094> velocity=<-2, -3> 222 | position=<-10486, 32094> velocity=< 1, -3> 223 | position=< 21484, 10781> velocity=<-2, -1> 224 | position=< 32140, 32088> velocity=<-3, -3> 225 | position=<-21130, 10777> velocity=< 2, -1> 226 | position=< 42794, -10533> velocity=<-4, 1> 227 | position=< 21498, -21187> velocity=<-2, 2> 228 | position=<-21116, -31848> velocity=< 2, 3> 229 | position=< 53450, -31844> velocity=<-5, 3> 230 | position=< 32142, 42745> velocity=<-3, -4> 231 | position=<-31782, -53152> velocity=< 3, 5> 232 | position=<-53091, -10527> velocity=< 5, 1> 233 | position=< 42798, 10777> velocity=<-4, -1> 234 | position=<-42422, 42744> velocity=< 4, -4> 235 | position=< 10855, -10529> velocity=<-1, 1> 236 | position=< 21490, 32094> velocity=<-2, -3> 237 | position=<-42437, -42504> velocity=< 4, 4> 238 | position=< 53483, -21192> velocity=<-5, 2> 239 | position=< 53466, 53406> velocity=<-5, -5> 240 | position=<-10458, -31848> velocity=< 1, 3> 241 | position=< 42771, 32090> velocity=<-4, -3> 242 | position=<-31780, 53404> velocity=< 3, -5> 243 | position=<-53115, -10536> velocity=< 5, 1> 244 | position=<-10449, 10776> velocity=< 1, -1> 245 | position=<-31772, 32097> velocity=< 3, -3> 246 | position=< 21515, -21186> velocity=<-2, 2> 247 | position=< 42815, 42749> velocity=<-4, -4> 248 | position=<-21158, 21437> velocity=< 2, -2> 249 | position=< 42774, -31846> velocity=<-4, 3> 250 | position=<-53105, 53405> velocity=< 5, -5> 251 | position=< 21478, -10527> velocity=<-2, 1> 252 | position=<-31781, -21183> velocity=< 3, 2> 253 | position=< 53450, 32093> velocity=<-5, -3> 254 | position=< 10810, -42499> velocity=<-1, 4> 255 | position=< 32132, 10781> velocity=<-3, -1> 256 | position=< 32138, 10785> velocity=<-3, -1> 257 | position=< 10863, -21190> velocity=<-1, 2> 258 | position=< 10859, 53409> velocity=<-1, -5> 259 | position=<-53109, -42499> velocity=< 5, 4> 260 | position=< 32132, 53400> velocity=<-3, -5> 261 | position=< 53434, 32088> velocity=<-5, -3> 262 | position=< 53479, -10530> velocity=<-5, 1> 263 | position=< 53487, 21432> velocity=<-5, -2> 264 | position=< 53427, 10779> velocity=<-5, -1> 265 | position=<-10465, 21434> velocity=< 1, -2> 266 | position=<-21149, 21432> velocity=< 2, -2> 267 | position=< 10823, -42504> velocity=<-1, 4> 268 | position=<-42446, 10783> velocity=< 4, -1> 269 | position=<-31771, 42753> velocity=< 3, -4> 270 | position=< 21501, 10780> velocity=<-2, -1> 271 | position=<-53081, -31847> velocity=< 5, 3> 272 | position=< 53475, 53400> velocity=<-5, -5> 273 | position=<-53074, -53160> velocity=< 5, 5> 274 | position=<-53126, 21441> velocity=< 5, -2> 275 | position=< 10823, -21190> velocity=<-1, 2> 276 | position=< 53485, -53160> velocity=<-5, 5> 277 | position=<-21108, 10785> velocity=< 2, -1> 278 | position=<-42457, 32097> velocity=< 4, -3> 279 | position=<-10486, -53158> velocity=< 1, 5> 280 | position=< 53466, 21432> velocity=<-5, -2> 281 | position=< 10834, 53409> velocity=<-1, -5> 282 | position=< 21493, 32090> velocity=<-2, -3> 283 | position=<-31798, -21183> velocity=< 3, 2> 284 | position=<-42429, -10536> velocity=< 4, 1> 285 | position=<-53131, 10781> velocity=< 5, -1> 286 | position=< 53459, 53404> velocity=<-5, -5> 287 | position=< 53469, 53404> velocity=<-5, -5> 288 | position=< 42828, 53409> velocity=<-4, -5> 289 | position=<-21139, -53160> velocity=< 2, 5> 290 | position=<-31769, -42499> velocity=< 3, 4> 291 | position=< 42821, 10781> velocity=<-4, -1> 292 | position=< 21490, 21434> velocity=<-2, -2> 293 | position=< 21459, -53158> velocity=<-2, 5> 294 | position=< 10842, -10533> velocity=<-1, 1> 295 | position=< 42778, 32097> velocity=<-4, -3> 296 | position=< 32131, 42750> velocity=<-3, -4> 297 | position=< 42821, -10531> velocity=<-4, 1> 298 | position=< 42775, -53159> velocity=<-4, 5> 299 | position=< 42820, -42495> velocity=<-4, 4> 300 | position=< 53468, 53404> velocity=<-5, -5> 301 | position=<-31818, 42746> velocity=< 3, -4> 302 | position=<-42422, -31840> velocity=< 4, 3> 303 | position=< 21479, -21183> velocity=<-2, 2> 304 | position=<-42454, 21435> velocity=< 4, -2> 305 | position=< 10847, -53152> velocity=<-1, 5> 306 | position=<-31813, 53409> velocity=< 3, -5> 307 | position=< 10847, 21435> velocity=<-1, -2> 308 | position=<-53081, 32094> velocity=< 5, -3> 309 | position=<-42473, 32096> velocity=< 4, -3> 310 | position=< 10807, -42503> velocity=<-1, 4> 311 | position=< 10862, 32097> velocity=<-1, -3> 312 | position=< 53469, 10785> velocity=<-5, -1> 313 | position=< 21503, -42498> velocity=<-2, 4> 314 | position=< 53430, 21435> velocity=<-5, -2> 315 | position=< 53427, -31841> velocity=<-5, 3> 316 | position=< 42799, -42495> velocity=<-4, 4> 317 | position=<-21107, -31839> velocity=< 2, 3> 318 | position=< 21511, -53151> velocity=<-2, 5> 319 | position=<-42433, -10530> velocity=< 4, 1> 320 | position=<-31777, -31846> velocity=< 3, 3> 321 | position=<-21141, -21191> velocity=< 2, 2> 322 | position=<-53100, 32094> velocity=< 5, -3> 323 | position=< 21514, 42753> velocity=<-2, -4> 324 | position=<-42466, 10785> velocity=< 4, -1> 325 | position=<-31790, 21441> velocity=< 3, -2> 326 | position=<-42433, 32095> velocity=< 4, -3> 327 | position=<-42430, -42497> velocity=< 4, 4> 328 | position=< 21503, -31840> velocity=<-2, 3> 329 | position=< 21475, -53154> velocity=<-2, 5> 330 | position=<-42449, 32095> velocity=< 4, -3> 331 | position=<-53094, 10784> velocity=< 5, -1> 332 | position=< 21495, -21192> velocity=<-2, 2> 333 | position=< 53434, -21191> velocity=<-5, 2> 334 | position=< 32143, -21189> velocity=<-3, 2> 335 | position=<-21140, -53155> velocity=< 2, 5> 336 | position=< 21495, 42744> velocity=<-2, -4> 337 | position=< 21502, 32097> velocity=<-2, -3> 338 | position=<-53094, -42495> velocity=< 5, 4> 339 | position=<-42474, 53406> velocity=< 4, -5> 340 | position=<-21141, -10535> velocity=< 2, 1> 341 | position=< 42788, -31843> velocity=<-4, 3> 342 | position=<-21139, -21192> velocity=< 2, 2> 343 | position=<-10493, 10782> velocity=< 1, -1> 344 | -------------------------------------------------------------------------------- /p11.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←1 2 | p←⍎⊃⊃⎕NGET'p11.txt'1 3 | g←{r y←10 0+⍵ ⋄ ¯5+10|⌊100÷⍨r×p+y×r}¨⍳300 300 ⍝ grid 4 | ¯1+⊃⍸{⍵=⌈/,⍵}{+/,⍵}⌺3 3⊢g ⍝ part 1 5 | 1↓{(⊃⍒⍵)⌷⍵}↑1{0>m←⌈/,t←{+/,⍵}⌺⍺ ⍺⊢g:⍵ ⋄ (⍺+1)∇⍵,⊂m,((⊃⍸m=t)-⌊0.5×⍺-1),⍺}⍬ ⍝ part 2 6 | -------------------------------------------------------------------------------- /p11.txt: -------------------------------------------------------------------------------- 1 | 5468 2 | -------------------------------------------------------------------------------- /p11nwise.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←1 2 | p←⍎⊃⊃⎕NGET'p11.txt'1 3 | g←{r y←10 0+⍵ ⋄ ¯5+10|⌊100÷⍨r×p+y×r}¨⍳300 300 ⍝ grid 4 | ⊃⍸{⍵=⌈/,⍵}3+/3+⌿g ⍝ part 1 5 | 1↓{(⊃⍒⍵)⌷⍵}↑1{0>m←⌈/,t←⍺+/⍺+⌿g:⍵ ⋄ (⍺+1)∇⍵,⊂m,(⊃⍸m=t),⍺}⍬ ⍝ part 2 6 | -------------------------------------------------------------------------------- /p12.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 ⋄ ⎕PP←17 2 | s←15↓⊃p←'#'=⊃⎕NGET'p12.txt'1 ⍝ initial state 3 | u←5↑¨2↓p ⋄ v←⊃∘⌽¨2↓p ⍝ patterns and replacements 4 | f←{v[u⍳5,/4⌽⍵,⍨8/0]} ⍝ next generation 5 | g←{+/(⍸⍵)-0.5×(≢⍵)-≢s} ⍝ score function 6 | g f⍣20⊢s ⍝ part 1 7 | z←g t←f⍣{≡/(⍸-⍳∘1)¨⍺⍵}s ⍝ iterate until pattern stabilises 8 | z+(z-g f t)ׯ50E9+4÷⍨(≢t)-≢s ⍝ part 2 9 | -------------------------------------------------------------------------------- /p12.txt: -------------------------------------------------------------------------------- 1 | initial state: .#..##..#.....######.....#....####.##.#.#...#...##.#...###..####.##.##.####..######......#..##.##.## 2 | 3 | #.... => . 4 | .##.# => # 5 | #..## => . 6 | ....# => . 7 | ###.# => # 8 | ...#. => # 9 | #...# => # 10 | #.### => . 11 | .#... => # 12 | ...## => . 13 | ..### => . 14 | ####. => . 15 | ##.## => . 16 | ..##. => . 17 | .#.## => # 18 | #..#. => # 19 | ..... => . 20 | #.#.. => . 21 | ##.#. => # 22 | .#### => # 23 | ##### => . 24 | #.##. => # 25 | .#..# => # 26 | ##... => . 27 | ..#.# => # 28 | ##..# => # 29 | .###. => . 30 | .#.#. => # 31 | #.#.# => # 32 | ###.. => . 33 | .##.. => . 34 | ..#.. => . 35 | -------------------------------------------------------------------------------- /p13.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | sort←{(⊂⍋⍵)⌷⍵} 3 | p←↑⊃⎕NGET'p13.txt'1 4 | g←'|'@(∊∘'^v')'-'@(∊∘'<>')⊢p ⍝ grid 5 | m←4>t←'^>v<'⍳p 6 | 7 | x←↑⍸m 8 | c←0×d←(,m)/,t 9 | turn←{⍵='/':(⍺⊃d)←4|1-⍺⊃d ⋄ ⍵='\':(⍺⊃d)←3-⍺⊃d ⋄ ⍵='+':(⍺⊃d)←4|(⍺⊃d)+¯1+3|⍺⊃c ⋄ 0} 10 | move←{z←(⍵⌷x)+(⍵⊃d)⌷4 2⍴¯1 0 0 1 1 0 0 ¯1 ⋄ (⊂z)∊↓x:r,←z ⋄ (⍵⌷x)←z ⋄ _←⍵ turn (a←z⌷g) ⋄ (⍵⊃c)+←'+'=a} 11 | tick←{move¨⍋x} 12 | r←⍬ ⋄ {}tick⍣{×≢r}⊢0 ⋄ ⌽2↑r ⍝ part 1 13 | 14 | x←↑⍸m 15 | v←1+c←0×d←(,m)/,t 16 | move←{z←(⍵⌷x)+(⍵⊃d)⌷4 2⍴¯1 0 0 1 1 0 0 ¯1 ⋄ i←(↓x)⍳⊂z ⋄ v[⍵ i/⍨1 1≡v[⍵ i/⍨i<≢v]]←0 ⋄ (⍵⌷x)←z ⋄ _←⍵ turn (a←z⌷g) ⋄ (⍵⊃c)+←'+'=a} 17 | {}tick⍣{1=+/v}⊢0 ⋄ ⌽v⌿x ⍝ part 2 18 | -------------------------------------------------------------------------------- /p13.txt: -------------------------------------------------------------------------------- 1 | /---------------------------------------------------------------------------------------------\ 2 | /----------------------<--------------------+----------------------------\ | 3 | | | | | 4 | | /------------------\ | | /--------------\ | 5 | | | | | | | | | 6 | | | | | /--------------------+------------------------------+--------------+-------\ | 7 | | | | | | /-------------+------------------------------+--------------+-------+----------+-----\ 8 | | | | | | /+-------------+-----------------\ | /------------+-------+--------\ | | 9 | | | | | | || | | | | | | | | | 10 | | | /--------+---------------------+-------+-----++-------------+-------<---------+------------+-+--------\ | | | | | 11 | | | | /----+---------------------+-------+-----++-------------+-----------------+------------+-+-----\ | | | | | | 12 | | | | | | /--------+-------+-----++-------------+------------\ | /------+-+-\ | | | | | | | 13 | | | | /-+----+------------+--------+-------+-----++-------------+------------+----+-----+-\ | | | | | | | /--+-+-----+---\ 14 | | | /----+-+-+----+------------+--------+-------+-----++---\ | | | /---+-+----+-+-+---+--+---+-------+-----+--+\| | | 15 | | | | | |/+----+------------+--------+-------+-----++---+---------+------------+----+-+---+\| | | | | | | | /--+--+++--\ | | 16 | | | /+----+-+++----+------------+--------+-------+-----++---+---\ | | | | ||| | | | | | | | | | ||| | | | 17 | | | || | ||| | /--+--------+\ | || | /+-----+------------+---\| | ||| | | | | | | | | | ||| | | | 18 | | | || | ||| | | | || /--+-----++---+--++-----+------------+---++-+---+++----+-+-+---+--+---+-------+--+--+--+++--+--+\ | 19 | | | || | ||| /--+---------+--+-\/-----++-\ | /+-----++---+\ || | | || | ||| | | | | | | /-----+--+--+--+++\ | || | 20 | | | || | ||| | | | | || || | | || || || || | | || | ||| | | | | | | ^ | | | |||| | || | 21 | | | || | ||| | | /----+--+-++-----++-+-+-++-----++---++-++-\ | | || | ||| | | | | | | | | | | |||| | || | 22 | | | || | ||\-+--+----+----+--+-++-----++-+-+-++-----++---++-++-+---+------------+---++-+---+++----+-+-+---/ | | | | | | |||| | || | 23 | | | /-++----+-++--+--+----+-->-+--+-++-----++-+-+-++-----++>--++-++-+---+------------+---++\| ||| | | | | | | | | | |||| | || | 24 | | | | || | || | | | | | || || | | || || || || | | | |||| ||| | | | | | | | | | |||| | || | 25 | | | | || | || | | | | \-++-----++-+-+-++-----++---++-++-+---+------------/ |||| ||| /+-+-+------+---+-+-----+-\| | |||| | || | 26 | /+--+-+-++----+-++--+--+----+----+----++-----++\| | || || || || | | |||| |||/--++-+-+--\ | | | | || | |||| | || | 27 | || | | || | || | | | /--+----++-----++++-+-++-----++---++-++-+---+----------------++++\ |||| || | | | | | | | || | |||| | || | 28 | || | | \+----+-++--+--+----+-+--+----++-----++++-+-++-----++---++-+/ | | |||\+--++++--++-+-+--+---+---+-+-----+-++--+--+/|| | || | 29 | || | | \----+-++--+--+----+-+--+----++-----++++-+-++-----++---/| | | | ||| | |||| || | | | | /+-+-----+-++--+--+-++-+-\|| | 30 | || | | | || | | /+-+--+---\|| |||| \-++-----++----+-+--+---+----------------+++-+--++++--++-+-+--+---+--++-+-----+-++--+--+-++-+-++/ | 31 | || | | | || | | || | | ||| |||| || /++----+-+\ | | ||| | |||| || | | | | || | | || | | || | || | 32 | || | | | || | |/--++-+--+---+++-----++++---++----+++----+-++-+---+-------\ ||| | |||| || | | | | || \-----+-++--+--+-+/ | || | 33 | || | | | || | || || | | ||| |||| || /-+++----+-++-+---+-------+--------+++\| |||| || | | | | || | || | | | | || | 34 | || | | | || | || || | | ||| |||| || | ||| | || | | | ||||| /++++--++-+-+--+---+--++------\| || | | | | || | 35 | || | | | || | || || | | ||| |||| ||/-+-+++----+-++-+---+-------+--------+++++\||||| || | | | | || || || | | | | || | 36 | || | | | || | /++--++-+--+---+++-----++++---+++-+-+++----+-++-+-\ | | /----+++++++++++--++-+-+--+---+--++------++-++--+--+-+--+-++\ | 37 | || | | | || | ||| || | | ||| |||| ||| | ||| | || | | | |/--+----+++++++++++--++-+-+--+-\ | || || || | | | | ||| | 38 | |\--+-+-------+-++--+-+++>-++-+--+---+++-----++++---+++-+-+++----+-++-+-+-/ /-----++--+----+++++++++++--++-+-+--+-+-+--++------++-++--+--+-+--+\||| | 39 | | | | | || | ||| || | /+---+++-----++++---+++\|/+++----+-++-+-+---+-----++--+----+++++++++++--++-+-+--+-+-+--++-\ || || | | | ||||| | 40 | | /+-+-------+-++--+\||| |v | || ||| |||| ||||||\++----+-+/ | | | || | ||||||||||| || | | | | | || | || || | | | ||||| | 41 | | || | | || ||||| || | || |||/----++++---++++++-++----+-+--+-+---+-----++--+----+++++++++++--++-+-+\ | | | || | || || | | | ||||| | 42 | | || | | || ||||| || | || |||| |||| |||||| || | | | | | /--++--+----+++++++++++--++-+-++-+-+-+--++-+----++-++--+--+-+\ ||||| | 43 | | /++-+-------+-++--+++++--++-+-++---++++----++++---++++++-++----+-+--+-+---+--+--++--+----+++++++++++--++-+\|| | | | || | || || | | || ||||| | 44 | |/+++-+-------+-++--+++++--++-+-++---++++----++++---++++++-++\ | | | | | | || | ||||||||||| || |||| | | | || | || ||/-+--+-++-+++++-\| 45 | ||||| | | || ||||| || | || |||| |||| |||||| ||| | | | | | | || | ||||||||||| || |||| | | | ||/+----++-+++-+--+\|| ||||| || 46 | ||||| | | || ||||| || | || ||||/---++++---++++++-+++\ | | | | | | || | ||||||||||| || |||| | | | |||| || ||| | |||| ||||| || 47 | ||||| | | || ||||| || | || ||||| |||| |||||| |||| | | | | /-+--+-<++--+----+++++++++++--++-++++-+-+-+--++++----++-+++-+--++++-+++++\|| 48 | ||||| | | || ||||| || | |\---+++++---+/|| |||||| |||| | | | |/+-+--+--++--+----+++++++++++--++-++++\| | | |||| || ||| | |||| |||||||| 49 | ||||| | /-+-++--+++++--++-+-+----+++++---+-++-\ |||||| ||||/-+-+--+-+++-+--+--++--+----+++++++++++\ || |||||| | | |||| || ||| | |||| |||||||| 50 | ||||| | | |/++--+++++--++-+-+----+++++---+-++-+-++++++-+++++-+-+--+-+++-+--+--++-\| |||||||||||| || |||||| | | |||| || ||| | |||| |||||||| 51 | ||||| | | |||| ||||| || | | ||||| | || | |||||\-+++++-+-+--+-+++-+--+--++-++----++++++++++++-++-++++++-+-+--+++/ || ||| | |||| |||||||| 52 | ||||| | | |||| ||||| || | | ||||| /-+-++-+-+++++--+++++-+-+--+-+++-+--+--++-++----++++++++++++-++-++++++\| | ||| || |\+-+--++++-/||||||| 53 | ||||| | | |||| ||||| || | | ||||| | | || | ||||| /+++++-+-+--+-+++-+--+--++-++----++++++++++++\|| |||||||| | ||| || | | | |||| ||||||| 54 | ||||| | | |||| ||||| /++-+-+----+++++-+-+-++-+-+++++-++++++-+-+--+-+++-+--+--++-++----+++++++++++++++-++++++++-+\ ||| || | | | |||| ||||||| 55 | ||||| | | |||| ||||| ||| | | /-+++++-+-+-++-+-+++++-++++++-+-+--+-+++-+--+--++\|| |||||||\+++++++-++/||||| || ||| /--++-+-+-+--++++\ ||||||| 56 | ||||| | | |||| \++++-+++-+-+--+-+/||| | | || | ||||| |||||| | | | ||\-+--+--+++++----+++++++-+++++++-++-+++++-++-+++--+--++-+-+-+--+++++-++++/|| 57 | ||||| | | |||| |||| ||| | | | | ||| | | || | \++++-++++++-/ | | || | | ||||\----+++++++-+++++++-++-+++++-++-+++--+--++-+-+-+--+++++-+++/ || 58 | ||||| | | |||| |||| ||| | | | | ||| | | || | |||| |||||| | | || | | |||| ||||||| ||||||| || ||||| || ||| | || | | | ||||| ||| || 59 | ||||| | | |||| |||| ||| | | | | ||| | | || | |||| |||||| | | || | | |||| ||||||\-+++++++-++-+++++-++-+++--+--/| | | v ||||| ||| || 60 | ||||| | | |||| |||| ||| |/+--+-+-+++-+-+-++-+--++++-++++++---+-\| || | | |||| |||||| ||||||| || ||||| || ||| | | | | | ||||| ||| || 61 | ||||| | | |||| |||| ||| ||| | | ||| | | || | \+++-++++++---+-++-++--+--+--++++-----++++++--+++++++-++-+++++-++-+++--+---/ | | | ||||| ||| || 62 | ||||| | | |||| |||| ||| ||| | | ||| | | || | ||| |||||| | || || | | |||| |||||| ||||||| || ||||| || ||| | | | | ||||| ||| || 63 | \++++-+-----+-++++---++++-+++-+++--+-+-+++-+-+-/|/+---+++-++++++---+-++-++--+--+\ |||| |||||| ||||||| \+-+++++-++-+++--+-----+-+-+--/|||| ||| || 64 | |||| | | |||| /-++++-+++-+++--+-+-+++-+-+--+++---+++-++++++---+-++-++\ | || |||| |||||| ||||||| | ||||| || ||| | | | | |||| ||| || 65 | |||| | /-+-++++-+-++++-+++-+++--+-+-+++-+-+--+++---+++-++++++---+-++-+++-+--++-++++-----++++++--+++++++--+-+++++\|| ||| | | | | |||| ||| || 66 | |||| | | | |||| | |||| ||| ||| | | ||| | | ||| ||| |||||| | ||/+++-+--++-++++-----++++++--+++++++--+-++++++++-+++--+-----+-+-+---++++-+++\ || 67 | |||| | | | |||| | |||| ||| ||| | | ||| | | ||| ||| |||||| \-++++++-+--++-++++-----/||||| ||||||| | |||||||| ||| | | | | |||| |||| || 68 | \+++-+---+-+-++++-+-++++-+++-+++--+-+-+++-+-+--+++---+++-+++/|\-----++++++-+--++-++++------+++++--+++/||| | |||||||| ||| | | | | |||| |||| || 69 | ||| | | | |||| |/++++-+++-+++-\| | ||| | | ||| ||| ||| | |||||| | || |||| /+++++--+++-+++--+-++++++++-+++--+-----+-+-+--\|||| |||| || 70 | ||| | | | |||| |||||| ||| ||| || | ||| | | ||| ||| ||| | |||||| | /++-++++-----++++++--+++-+++--+-++++++++-+++-\| | | \--+++++-++++-+/ 71 | ||| | | | |||| |||||| ||| ||| || | ||| | | ||| ||| ||| | |||||| | ||| |||| |||||| ||| ||| | |||||||| ||| || | | ||||| |||| | 72 | ||| | | | |||| |||||| |||/+++-++-+-+++-+-+--+++---+++-+++-+------++++++-+-+++-++++-----++++++--+++-+++--+-++++++++-+++\|| | | ||||| |||| | 73 | /+++-+---+-+-++++-++++++-+++++++-++-+-+++-+-+--+++---+++-+++-+------++++++-+-+++\|||| |||||| ||| ||| | |||||||| |||||| | \----+++++-++++-/ 74 | |||| | | | |||| |||||| ||||||| || | ||| | | ||| ||| ||| | |||||| | |||||||| |||||| ||| |\+--+-++++++++-++++++-----/ ||||| |||| 75 | |||| | | | |||| |||||| ||||||| || | ||| | | ||| ||| ||| | ||\+++-+-++++++++-----++++++--+++-+-+--+-++++++++-++++++------------+++++-+++/ 76 | |||\-+---+-+-++++-++++/| ||||||| || | ||| | | ||| ||| ||| | || ||| | |||||||| /-++++++-\||| | | | |||||||| |||||| ||||| ||| 77 | ||| | | | |||| ||||/+-+++++++-++-+-+++-+-+--+++---+++-+++-+------++-+++-+-++++++++---+-++++++-++++-+-+--+-++++++++-++++++-----\ ||||| ||| 78 | ||| | | | |||| |||||| ||||||| || | ||| | | ||| ||| ||| | || ||| | |||||||| | |||||| |||| | | | |||||||| |||||| | /---+++++-+++-\ 79 | ||| | | | |||| |\++++-+++++++-/| |/+++-+-+--+++---+++-+++-+------++-+++-+-++++++++---+-++++++-++++-+-+--+-++++++++-++++++-\ | | ||||| ||| | 80 | ||| | | | |||| | |||| ||||||| | |||||/+-+--+++---+++-+++-+----\ || |\+-+-++++++++---+-++++++-++++-+-+--+-+/|||||| |||||| | | | ||||| ||| | 81 | ||| | | | |||| | |||| ||||\++--+-+++++++-+--+++---+++-+++-+----+-++-+-+-+-++++++++---+-++++/| |||| | | | | |||||| |||||| | | | ||||| ||| | 82 | ||| | | | |||| | |||| |||| || | ||||||| | ||| ||| ||| | | || | | | |||||||| | |||| | |||| | | | | |||||| |||||| | | | ||||| ||| | 83 | ||| | | | |||| | |||| |||| || | ||||||| | ||| ||| ||| | | || | | | |||||||| | |||| | |||| | | | | |||||| |||||| | | | ||||| ||| | 84 | ||| | | | |||| | ||||/++++-++--+-+++++++-+--+++---+++-+++-+----+-++-+-+-+-++++++++---+>++++-+-++++-+-+--+-+\|||||| |||||| | | | ||||| ||| | 85 | ||| | | | |||| | ||||||||| || | ||||||\-+--+++---+++-+++-+----+-++-+-+-+-++++++++---+-++++-+-++++-+-+--+-+++/|||| |||||| | | | ||||| ||| | 86 | ||| |/--+-+-++++-+-+++++++++-++--+-++++++--+--+++---+++-+++-+----+-++-+-+-+-++++++++---+-++++-+-++++-+-+\ | ||| |||| |||||| | | | ||||| ||| | 87 | ||| || | | |||| | ||||||||| || | ||\+++--+--/|| ||| ||| | | || | | | |||||||| | |||| | |||| | || | ||| |||| |||||| | | | ||||| ||| | 88 | ||| || | | |||| | ||||||||| || | || ||| | || ||| ||| | | || | | | |||||||| | |||| | |||| | || | ||| |||| |||||| | | | ||||| ||| | 89 | \++--++--+-+-++++-+-+++++++++-++--+-++-+++--+---++---+++-+++-+----+-++-+-+-+-+++/|||| | |||| | |||| | || | ||| |||| |||||| | | | ||||| ||| | 90 | || || | | |||| | ||||||||| || | || ||| | /-++---+++-+++-+----+-++-+-+-+-+++-++++---+-++++-+\|||| | || | ||| |||| |||||| | | | ||||| ||| | 91 | || || |/+-++++-+-+++++++++-++--+-++\||| | | || ||| ||| | | || | | | ||| |||| | |||| |||||| |/++-+-+++-++++-++++++\| | | ||||| ||| | 92 | || || |||/++++-+-+++++++++\|| | |||||| | | || ||| ||| | | || | | | |\+-++++---+-++++-++++++-++++-+-+++-++++-++++++++---+--+---+++/| ||| ^ 93 | |\--++--++++++++-+-/||||||||||| | |||||| | | || ||| ||| | | || | | | \-+-++++---+-++++-++++++-++++-+-+++-++++-++++/||| | | ||| | ||| | 94 | | || |||||||| | ||||||||||| | |||||| | | || ||| |\+-+----+-++-+-+-+---+-++++---+-+/|| |||||| |||| | ||| |||| |||| ||| | \---+++-+-+++-/ 95 | | || |||||||| | |||||||||||/-+-++++++--+-+-++---+++-+-+-+----+-++-+-+-+---+-++++---+-+-++-++++++-++++-+-+++-++++-++++-+++--\| ||| | ||| 96 | | \+--++++++++-+--++++++++++++-+-++++++--+-+-++---+++-+-+-+----+-++-+-+-+---+-++++---+-+-/| |||||| |||| | ||| |||| |||| ||| || ||| | ||| 97 | | | |||||\++-+--++++++++++++-+-++++++--+-+-++---+++-+-+-+----+-++-+-+-+---+-+++/ | | | |||||| |||| | ||| |||| |||| ||| || ||| | ||| 98 | | \--+++++-++-+--++++++++++++-+-++++++--+-+-++---+++-+-+-+----+-++-+-+-+---+-+++----+-+--+-++++++-+++/ | ||| |||| |||| ||| || ||| | ||| 99 | /-+-------+++++\|| | |||||||||||| | |||||| \-+-++---+++-+-+-+----+-++-+-+-+---+-+++----+-+--+-++++++-+++--+-+++-++++-++++-+++--++------++/ | ||| 100 | | | ||||\+++-+--++++++++++++-+-++++++----+-++---+++-+-+-+----+-++-+-+-+---+-+++----+-+--+-++++++-+++--+-+++-++/| |||| ||| || || | ||| 101 | | | |||| ||| | |||||||||||| | |||||| | || ||| | \-+----+-++-+-+-+---+-+++----+-+--+-++++++-+++--+-+++-++-+-++++-+++--++------++--+-++/ 102 | | | |||| ||| | |||||||||||| | |||||| | || ||| | | | || | | \---+-+++----+-+--+-++++++-+++--+-+++-++-+-++++-+++--++------++--+-/| 103 | | | |||| ||| | ||||||||||\+-+-++++++----+-++---+/|/+---+----+\|| | | | ||| | | | |||||| ||\--+-+++-++-+-+/|| ||| || || | | 104 | | | |||| ||| | |||||||^|\-+-+-++++++----+-++---+-+++---+----++/| | | | ||| | | | |||||| || /+-+++-++-+-+-++-+++--++----\ || | | 105 | | | |||| ||| | ||||||\++--+-+-++++++----+-++---+-+++---+----++-/ | | | ||| | | | |||||| || || ||| || | | || ||| || | || | | 106 | | | |||| ||| | |||||| || | | |||||| | || | ||| | || | | | ||| | | | |||||\-++--++-++/ || | \-++-+++--++----+-++--+--/ 107 | | | |||| ||| | ||\+++-++--+-+-++++++----+-++---+-+++---+----++---+-+-----+-/|| /--+-+--+-+++++--++--++-++--++-+---++-+++--++---\| || | 108 | | | ||\+-+++-+--++-+++-++--+-+-++++++----+-+/ | ||| | || | | | || | | | | ||||| || || || || | || ||| || || || | 109 | | | || | ||| | || ||| || \-+-++++++----+-+----+-+++---+----++---+-+-----+--++-+--+-+--+-+++++--++--++-++--++-+---++-+++--/| || || | 110 | | | || | ||| | || ||| || | |||||| | | |/+++---+----++---+-+-----+--++-+--+-+--+-+++++--++--++-++--++-+---++-+++---+---++-++--+-----\ 111 | | | || | ||| | || ||| || | |||\++----+-+----+++++---+----++---+-+-----+--++-+--+-+--+-+++++--++--++-/| || | || ||| | || || | | 112 | | | || | |||/+--++-+++-++----+-+++-++----+-+----+++++---+----++---+-+-----+--++-+--+-+--+-+++++--++--++\ | || | || ||| | || || | | 113 | | | || | ||||| || \++-++----+-+++-++----+-+----+++++---+----++---+-+-----+--++-+--+-+--+-+++++--++--+++-/ || | || ||| | || || | | 114 | | | || | ||||\--++--++-++----+-+++-++----+-+----+++++---+----++---+-/ | || | | | | ||||| || ||| || | || ||| | || || | | 115 | | | |\-+-++++---++--++-++----+-++/ || | \----+++++---+----++---+-------/ || | | | | ||||| || ||| || | || \++---+---++-++--/ | 116 | |/+-------+--+-++++---++--++-++----+-++--++\ | ||||| | || | || | | \--+-+++++--++--+++----++-+---++--++---+---++-/| | 117 | ||| | | |||| || || || | || ||| | ||\++---+----++---+--->------++-+--+----/ ||||| || ||| || | \+--++---+---++--/ | 118 | ||| | | |\++---++--++-++----+-++--+++---+------++-++---+----++---+----------++-+--+------++++/ || ||| || | | || | || | 119 | ||| | | | || || || ||/---+-++--+++---+---\ || \+---+----+/ | /-------++\| | |||| || \++----++-+----+--++---+---+/ | 120 | ||| | | | \+---++--++-+++---+-++--+++---+---+--++--+---+----+----+--+-------++++--+------+++/ || || || | | || | | | 121 | |||/------+--+-+--+---++--++-+++---+-++--+++---+---+--++--+---+--\ | | | |||\--+------+++----++---++----++-+----+--++---+---/ | 122 | |||| |/-+-+--+---++--++-+++---+-++--+++---+---+--++--+---+--+-+----+--+\ \++---+------+++----++---++----/| | | || | | 123 | |||| || | | | || || ||| | || ||| | | || | | | | | ||/------++---+------+++----++---++-----+-+----+--++---+-----\ | 124 | |||| || | | | /++--++-+++---+-++--+++---+---+--++--+---+--+-+----+--+++------++---+------+++<---++---++-----+-+----+--++-\ | | | 125 | |||| ||/+-+--+--+++--++-+++\ | || ||| | | || | | | | | ||| || | |||/---++---++-----+-+---\| || | | | | 126 | |||| |||| | | ||| \+-++++--+-++--+++---+---+--++--+---+--+-+----+--+++------++---+------++++---++---++-----+-/ || || | | | | 127 | |||| |||| | | ||| | |||| | || ||| | | || | | | | | ||| || | |||| || || | || || | | | | 128 | |||| |||| | | ||| | |||| | || ||| | | || | | | | | \++------+/ | |||| || || | || || | | | | 129 | \+++------++++-/ | ||| | |||| | || |\+---+---+--++--+---+--+-/ | || | | |||| || || | || || | | | | 130 | ||| |||| | |\+---+-++++--+-++--+-+---+---+--++--+---+--+------/ || | /+------++++---++---++-----+-----++--++-+-+-----+------\ | 131 | ||| |||| | | | | |||| | |\--+-+---+---+--++--+---+--+----------++------+---++------++++---++---++-----+-----++--+/ | | | | | 132 | |\+------++++----+--+-+---+-++++--+-+---+-+---+---+--++--+---+--+----------++------+---++------++++---++---/| | || | | | | | | 133 | | | |||| | | | \-++++--+-/ | | | | || \---+--+----------++------+---++------++++---/| | | || | | | | | | 134 | | | |||| | | | |||| | | | | | || | | || | || |||| | | | || | | | | | | 135 | | | |||| | \-+-----++++--+-----+-+---+---+--++------+--+----------++------+---++------++++----+----+-----+-----++--+--/ | | | | 136 | | | |||| | | |||| | | | \---+--++------+--+----------++->----+---++------+/|| | | | || | | | | | 137 | | | |||| | \-----++++--+-----+-+-------+--++------+--+----------++------+---++------+-++----+----+-----+-----++--+----/ | | | 138 | | | |||| \----------++++--+-----+-+-------+--++------+--+----------++------+---++------+-++----+----/ | || | | | | 139 | | | |||| |||| | \-+-------+--++------/ | |\------+---++------+-++----+----------+-----++--+----------/ | | 140 | | | |||| ||\+--+-------+-------/ \+---------+----------+-------+---++->----/ || | | || | | | 141 | | | |||\---------------+/ | | | | | | | || || | | || | | | 142 | | | ||\----------------+--/ \-------+-----------+---------+----------+-------/ || || | | || | | | 143 | | \------++-----------------+-------------+-----------+---------/ | || || | | || | | | 144 | | || | | | | |\--------/\----+----------+-----/| | | | 145 | | \+-----------------+-------------+-----------+--------------------+-----------+---------------+----------/ | | | | 146 | \-<-------+-----------------+-------------/ | | \---------------+-----------------+--+-----------------/ | 147 | \-----------------+-------------------------+--------------------/ | | | | 148 | \-------------------------+------------------------------------------------+-----------------/ | | 149 | | \--------------------/ | 150 | \-------------------------------------------------------------------------------------------/ 151 | -------------------------------------------------------------------------------- /p14.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | input←⍎⊃⊃⎕NGET'p14.txt'1 3 | scores←3 7 4 | 5 | nxt←{(≢scores)|⍵+1+cur⊣scores,←(t<10)↓10 10⊤t←+/cur←scores[⍵]} 6 | super←{nxt⍣(⌈0.2×≢scores)⊢⍵} 7 | pos←super⍣{input<¯10+≢scores}0 1 8 | ∊⍕¨r←10↑input↓scores ⍝ part 1 9 | 10 | match←⍎¨⍕input 11 | {}super⍣{∨/match⍷scores}pos 12 | ⊃⍸match⍷scores ⍝ part 2 13 | -------------------------------------------------------------------------------- /p14.txt: -------------------------------------------------------------------------------- 1 | 640441 2 | -------------------------------------------------------------------------------- /p14fast.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | input←⍎⊃⊃⎕NGET'p14.txt'1 3 | scores←3 7 4 | 5 | nxt←{⍵+1+tmp,←scores[⍵]} 6 | super←{tmp∘←⍬ ⋄ (≢scores)|(scores,←∊(t<10)↓¨↓⍉10 10⊤t←+/(0.5×≢tmp)2⍴tmp)⊢nxt⍣(1+⌊10÷⍨¯1+(≢scores)-⌈/⍵)⊢⍵}⍣4 7 | pos←super⍣{input<¯10+≢scores}0 1 8 | ∊⍕¨r←10↑input↓scores ⍝ part 1 9 | 10 | match←⍎¨⍕input 11 | {}super⍣{∨/match⍷scores}pos 12 | ⊃⍸match⍷scores ⍝ part 2 13 | -------------------------------------------------------------------------------- /p15.txt: -------------------------------------------------------------------------------- 1 | ################################ 2 | ###################..########### 3 | #################.....########## 4 | ################.......######### 5 | ################......#####...## 6 | #################.....G###.....# 7 | ###########.#####....#####..#### 8 | ###########..####.#.###....##### 9 | ##########.GG#.....##......##### 10 | ###########.........#...G..##### 11 | ###########....GG..........##### 12 | ##########G.GG....G....GG..##### 13 | #########.G...#####........##### 14 | #######.G...G#######.E...E..#### 15 | ###########.#########.......#### 16 | ##########..#########......##### 17 | ##...#####..#########.G....##### 18 | ####..#..#..#########.#.....#### 19 | ###.G.#.....#########..#..#.E### 20 | #####........#######.......E.### 21 | #####.........#####.......###### 22 | ######............E....E..###### 23 | #G.###..G.................###### 24 | #..####...............#....##### 25 | #....E#...G.......######...##### 26 | #.............E..#######.####### 27 | ###.........E#....############## 28 | ######.E.....#..################ 29 | #######..........############### 30 | #######......#.################# 31 | #####...#...#################### 32 | ################################ 33 | -------------------------------------------------------------------------------- /p16.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | p←⊃⎕NGET'p16.txt'1 3 | 4 | an←{2⊥∧/(2/⍨⌈2⍟1+⍺⌈⍵)⊤⍺⍵} 5 | or←{2⊥∨/(2/⍨⌈2⍟1+⍺⌈⍵)⊤⍺⍵} 6 | 7 | addr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]+r[b]⊣r←⍵} 8 | addi←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]+b⊣r←⍵} 9 | mulr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]×r[b]⊣r←⍵} 10 | muli←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]×b⊣r←⍵} 11 | banr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]an r[b]⊣r←⍵} 12 | bani←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]an b⊣r←⍵} 13 | borr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]or r[b]⊣r←⍵} 14 | bori←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]or b⊣r←⍵} 15 | setr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]⊣r←⍵} 16 | seti←{_ a b c←⍺ ⋄ r⊣r[c]←a⊣r←⍵} 17 | gtir←{_ a b c←⍺ ⋄ r⊣r[c]←a>r[b]⊣r←⍵} 18 | gtrr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]>r[b]⊣r←⍵} 19 | gtri←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]>b⊣r←⍵} 20 | eqir←{_ a b c←⍺ ⋄ r⊣r[c]←a=r[b]⊣r←⍵} 21 | eqrr←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]=r[b]⊣r←⍵} 22 | eqri←{_ a b c←⍺ ⋄ r⊣r[c]←r[a]=b⊣r←⍵} 23 | 24 | all←{16 4⍴⍺(addr,addi,mulr,muli,banr,bani,borr,bori,setr,seti,gtir,gtrr,gtri,eqir,eqrr,eqri)⍵} 25 | 26 | p1←⍎¨↑'\d+'⎕S'&'¨0 ¯1↓(+/'B'=⊃¨p)4⍴p 27 | mat←{x y z←↓⍵ ⋄ z≡⍤1⊢y all x}⍤2⊢p1 28 | +/2<+/mat ⍝ part 1 29 | 30 | ops←p1[;1;0] 31 | map←16/0 ⋄ {}{map[n⊃ops]←c←1⍳⍨⍵⌷⍨n←1⍳⍨1=+/⍵ ⋄ m⊣m[;c]←0⊣m←⍵}⍣16⊢mat 32 | p2←⍎¨{⍵↑⍨+/∧\×≢¨⍵}⌽p 33 | ⊃⊃{map[⊃⍺]⌷⍺ all ⍵}/p2,⊂0 0 0 0 ⍝ part 2 34 | -------------------------------------------------------------------------------- /p17.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | c←⊃¨p←⊃⎕NGET'p17.txt'1 3 | p←⍎¨¨'\d+'⎕S'&'¨p 4 | a b←(⌊/,⌈/)∊1↓¨p/⍨c='x' 5 | g←(1+b)1000⍴'' 6 | to←{⍺+⍳⍵-⍺} 7 | {g[⍵[1] to 1+⍵[2];⍵[0]]←'#'}¨p/⍨c='x' 8 | {g[⍵[0];⍵[1] to 1+⍵[2]]←'#'}¨p/⍨c='y' 9 | d←{x y←⍵ ⋄ t←y↓g[;x] ⋄ n←1⍳⍨t∊'#~' ⋄ g[y+⍳n;x]←'|' ⋄ _←f⍣(nk j ⋄ ⍱/t:∇⍵-0 1 ⋄ d¨y,⍨¨t/(i-1)j} 12 | d 500 0 13 | +/,'|~'∊⍨a↓g ⍝ part 1 14 | +/,'~'=a↓g ⍝ part 2 15 | -------------------------------------------------------------------------------- /p18.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | p←↑⊃⎕NGET'p18.txt' 1 3 | f←{(⍺='.')∧2<+/⍵='|':'|' ⋄ (⍺='|')∧2<+/⍵='#':'#' ⋄ (⍺='#')∧(1=+/⍵='#')∨0=+/⍵='|':'.' ⋄ ⍺} 4 | g←{⍵f⍤¯2{,⍵}⌺3 3⊢⍵} 5 | v←{×/+/'|#'∘.=,⍵} ⍝ value 6 | v g⍣10⊢p ⍝ part 1 7 | v ⍬{(≢⍺)≠n←⍺⍳⊂⍵:⍺⊃⍨n+((≢⍺)-n)|1E9-n ⋄ (⍺,⊂⍵)∇g ⍵}p ⍝ part 2 8 | -------------------------------------------------------------------------------- /p18.txt: -------------------------------------------------------------------------------- 1 | |#.....|...#|#...|......|..||.##..##..|||#|....|.. 2 | .#.#.#..|.#..||.##....|#.|.##....##..#|...#..#.|.. 3 | #..##...|#.#||#....##...#....##..#.#.|...|.#.....# 4 | .|.|.|..||#.....#.#..#..........#.||.#..|.|#.|.#.. 5 | #..|.......#||.........||.#...#|.....||.|#...|#..# 6 | |.#|.....#|##.|||.#|#|.#..|..#..#..||...||.......# 7 | |..#|..#||#..#.......#.#|.#...........#.##........ 8 | .....||.#.#|..#...|.#...#.#..........|...|.#....#| 9 | .|.##|.|...#.|#..|.||.#.|.#.|.#..#.|#|...|##..##|. 10 | ...#....#...|.|.##.###.#|...#..........||...|...|| 11 | |#..##|..|...#..#...||......|.|.#..#...#|..|#|..## 12 | #.|..#..#.....|.##..#|.....##......|...||..#..#... 13 | |#.....|#||#.....|.##|.#.#.#.#.|#.#...|#|#..||.... 14 | ...##|....|.|..|#.||||.##.#..#..###..|.#.#|.#...|. 15 | ..||.||..|....|.#.|....#..|#.|#..#.|.|.|||......#. 16 | ...#.#|..#|.###.##..|...#.||#....||....||..#....|. 17 | .#|.|......#.##.....#.....#.#..|..|#|#..#......|.. 18 | .#.|.|##...||#...#|....|||.....##......|...|#|...| 19 | |...|##.|....|.....|||.#.##..|.##|#....#...|....#. 20 | ..#.||.##.#...|#...#|##.||##.#.....|...|...#|.|... 21 | #.#.|..#.#.###...|..||..|...||.|..#.#...#..|..|... 22 | .#.|.#|.|.##.|..##.#|.#.##...|||...#|..|.#.##...|. 23 | ....##|..|.#.....|.|.#..|#..#|..#.#....#..#......# 24 | |...||..|.#..|..#.###||.......###.....#..........| 25 | .|.||....|#..#.|...|.#..##...|.........#..#|.|.#.. 26 | .|...|.|#|.||#...#...#.|..|...|||#....||#..|....#. 27 | |......#......#.|#.....|#||.#...#...##....#..#.... 28 | .......|#.|#...|.#.....#..||....#..#...|.#.#||.### 29 | ##.#.#|..||##.#|.|.#......###.|...#|...#|.##....|| 30 | ..#.|...#.|.........|#.......|.....#.|..#..|...|#| 31 | |||...|..|#|...##.......|....||.|.##..|.....#.#|.. 32 | #.#...|..##.##.#...#..#.|.##...|##.#|..|..#.....|. 33 | .#|..#.|#|.#......#..#...||.........#.#...##||.... 34 | #|##..#....#.....|..................#..|.#|...#..| 35 | .....#..........#.|..#..|.....|#....||###.|......| 36 | .....#.|.....|...#..#....|#...|#.#|##....#..||...| 37 | .#|..||.#.|.....#...|##.#|.|.#...|..#|##.|..|.#... 38 | .......|.||..||..#..|#.#|....#..####.##...#....#.. 39 | #..||..|..........|.#.......#..|..#|.|.....#.....# 40 | #...#....#|.##..#...#..|#.#..|||.#.#..||...|.|..#. 41 | ...#.##..||.#.#....|...|..#.#..|||...#......|#..#. 42 | .|..#||..|##..|.|.#.|..#..|....|..||.#|.|...#.|#.. 43 | .....###..|||...||.|.|.|.|#..##|..##....###.||..|. 44 | .|....#.#|#.......|.|..#......###.|.|..|.......#.. 45 | .#.#.....|.|....#..|...|.|..#.|##....#..||...#...| 46 | |#|..#|...####....#.#.|.|.|..#..##|##..#..|||#..|. 47 | #|#...#|....|....###...|.....|..|....|.....##..|.. 48 | .|...#...##|.|##..|...|.|#...|.#.|.....|..|....||. 49 | #...#||.#....|..|..#.|#.||.|.|#...#.|.#...||#.#.|| 50 | ....|...||...#..#|..|##.#.|.##.#|...#||.|.|.#..#|# 51 | -------------------------------------------------------------------------------- /p19.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | p←⊃⎕NGET'p19.txt'1 3 | ip←⍎(⊃p)∩⎕D 4 | addr←{a b c←⍵ ⋄ r[c]←r[a]+r[b]} 5 | addi←{a b c←⍵ ⋄ r[c]←r[a]+b} 6 | mulr←{a b c←⍵ ⋄ r[c]←r[a]×r[b]} 7 | muli←{a b c←⍵ ⋄ r[c]←r[a]×b} 8 | setr←{a b c←⍵ ⋄ r[c]←r[a]} 9 | seti←{a b c←⍵ ⋄ r[c]←a} 10 | gtir←{a b c←⍵ ⋄ r[c]←a>r[b]} 11 | gtrr←{a b c←⍵ ⋄ r[c]←r[a]>r[b]} 12 | gtri←{a b c←⍵ ⋄ r[c]←r[a]>b} 13 | eqir←{a b c←⍵ ⋄ r[c]←a=r[b]} 14 | eqrr←{a b c←⍵ ⋄ r[c]←r[a]=r[b]} 15 | eqri←{a b c←⍵ ⋄ r[c]←r[a]=b} 16 | ⎕FX(⊂'r←f r'),{'r[ip]←¯1+⊃⎕LC⋄',⍵,'⋄→2+r[ip]'}¨1↓p 17 | ⊃f 6↑0 ⍝ part 1 18 | 19 | g←{+/⍵{⍵/⍨0=⍵|⍺}1+⍳⍵} ⍝ sum of divisors 20 | ⎕FX(⊂'→0')(@2)⎕NR'f' 21 | g 3⊃f 6↑1 ⍝ part 2 22 | -------------------------------------------------------------------------------- /p19.txt: -------------------------------------------------------------------------------- 1 | #ip 4 2 | addi 4 16 4 3 | seti 1 9 5 4 | seti 1 5 2 5 | mulr 5 2 1 6 | eqrr 1 3 1 7 | addr 1 4 4 8 | addi 4 1 4 9 | addr 5 0 0 10 | addi 2 1 2 11 | gtrr 2 3 1 12 | addr 4 1 4 13 | seti 2 6 4 14 | addi 5 1 5 15 | gtrr 5 3 1 16 | addr 1 4 4 17 | seti 1 2 4 18 | mulr 4 4 4 19 | addi 3 2 3 20 | mulr 3 3 3 21 | mulr 4 3 3 22 | muli 3 11 3 23 | addi 1 5 1 24 | mulr 1 4 1 25 | addi 1 2 1 26 | addr 3 1 3 27 | addr 4 0 4 28 | seti 0 2 4 29 | setr 4 8 1 30 | mulr 1 4 1 31 | addr 4 1 1 32 | mulr 4 1 1 33 | muli 1 14 1 34 | mulr 1 4 1 35 | addr 3 1 3 36 | seti 0 0 0 37 | seti 0 2 4 38 | -------------------------------------------------------------------------------- /p2.dyalog: -------------------------------------------------------------------------------- 1 | p←⊃⎕NGET'p2.txt'1 2 | ×/+/2 3∘.∊{≢⍵}⌸¨p ⍝ part 1 3 | ⊃{⍵/⍨25=≢¨⍵},∘.{⍺/⍨⍺=⍵}⍨p ⍝ part 2 4 | -------------------------------------------------------------------------------- /p2.txt: -------------------------------------------------------------------------------- 1 | qysdgimlcaghpfozuwejmhrbvx 2 | qysdtiklcagnpfhzuwbjmhrtvx 3 | qysdtiflcsgnpfozuwejmhruvx 4 | qkshtiklnagnpfozuwejmhrbvx 5 | qysdtnklcagnpmozuwejmhrrvx 6 | qysdttkecagnpfozuwijmhrbvx 7 | qyedtiklcagnvfozuweymhrbvx 8 | qyzdtikzcagnpfozuwejmhqbvx 9 | qysdtiklcagnpfozlwedmhqbvx 10 | qjsdtiklcagnpfozubejmhrbvq 11 | qysdtiklcagnpfozvvejmhrbex 12 | qdsdziklcagnpfouuwejmhrbvx 13 | qysttikqccgnpfozuwejmhrbvx 14 | qysdtiklcagnpbozwwecmhrbvx 15 | qysdtiklcagnpfozuwexmmrjvx 16 | nysdtiklcqgjpfozuwejmhrbvx 17 | cysdoiqlcagnpfozuwejmhrbvx 18 | qysdthxlcagnpfozuwejmcrbvx 19 | qyswtiklcrgnpfozuwejmhrbvf 20 | qysdtiklcagnpfozurejmhvpvx 21 | qysdtiklcegnpfdzuwejghrbvx 22 | qysdtjkluagnpfozuwenmhrbvx 23 | qysdtimlcagnpjwzuwejmhrbvx 24 | qyrdtiklcegnpeozuwejmhrbvx 25 | qysdmiklcagnpfokswejmhrbvx 26 | qysdtizlcagnpiozuwecmhrbvx 27 | qysdtiklcignafxzuwejmhrbvx 28 | qycdjiklcagnpzozuwejmhrbvx 29 | qysdtiklcagnpjozuwepihrbvx 30 | qyedtiklcrgnpfozuvejmhrbvx 31 | mysdtikrcagnpfozwwejmhrbvx 32 | qysdtiklcagnpfozuhcjmhrbsx 33 | qmsdtiklcagnpfozuwehmhrevx 34 | qgsdtiklcagnpfozuwejvhrbvp 35 | lysdtikleagnpfozuwejmhrnvx 36 | qxsdtivlzagnpfozuwejmhrbvx 37 | qysdtiklcoggpfozuwebmhrbvx 38 | wysdtiklcagnpfozuwejmornvx 39 | jysdtiklvagntfozuwejmhrbvx 40 | qmsdtiklcagnpfozuwejmrrbax 41 | qysdttklcagnpfoiuwejmhrbvh 42 | qysdtnklcaenpfozupejmhrbvx 43 | qysdtoklcagnpfozuwexmhrbvq 44 | qysdtiklcagnpuoeuwejmhrjvx 45 | iysdtitncagnpfozuwejmhrbvx 46 | qysdtixrcagnprozuwejmhrbvx 47 | qyfdtiplcagnpfouuwejmhrbvx 48 | qysdtmklcagnpfowuwejmhrbox 49 | qysdtiklcagnxiozuwejphrbvx 50 | fysdtiklcagnptozuwejmhrbvo 51 | qysdqiklcagnplozuwejmhmbvx 52 | qysdtwkacagnpfosuwejmhrbvx 53 | qysdtitlcagnpfozufajmhrbvx 54 | qysdtcklcagopfdzuwejmhrbvx 55 | qmfdtdklcagnpfozuwejmhrbvx 56 | qysztiklcaonpfozuwejmhrbfx 57 | qygdtiklcggnpfozuwejmhrhvx 58 | qysdiiklcagnpfozukejmcrbvx 59 | qysdtrkloagnpfozuwujmhrbvx 60 | qycdtiklcagnpfozywejmhrlvx 61 | qgsdtikdcagnpfozgwejmhrbvx 62 | qyudtikleagvpfozuwejmhrbvx 63 | pysdtiqlcagnpfozuwejmarbvx 64 | qysdtiklcaenpfozuwehahrbvx 65 | qhsttiklcagnpfovuwejmhrbvx 66 | zysdtikqmagnpfozuwejmhrbvx 67 | rysdtikacagnpfozuwevmhrbvx 68 | zysntikllagnpfozuwejmhrbvx 69 | qysttimlcagndfozuwejmhrbvx 70 | qysdtiklcaxopfqzuwejmhrbvx 71 | qysdtislcagnpfozuwejmtrbnx 72 | qysdviklcagnpfozswejmhibvx 73 | qmsdtiklrygnpfozuwejmhrbvx 74 | qysztiklcagnpfozuwejmorbrx 75 | xysdtiklcagnzwozuwejmhrbvx 76 | qysjthklcagnpfozowejmhrbvx 77 | qysdtiklcagnpfofxwemmhrbvx 78 | jysdtiklcagnpfozfwehmhrbvx 79 | qysdtgklaagnpfozhwejmhrbvx 80 | qqsdtiklcaenpfozuwejmhrvvx 81 | qysdtikloajppfozuwejmhrbvx 82 | qysdtiklcagnpwozuwejmhrhsx 83 | qpsdtiklcapnprozuwejmhrbvx 84 | qyzdtiklcagnpcozuwejmhrbvc 85 | qusdhiklcagnpfozuwejmhrbxx 86 | qysdtiklcagnpfozqwejthrvvx 87 | qysvtiklcagnpfoiuwedmhrbvx 88 | qgsdtiklcagvpfozuwejmhrbvf 89 | qysdtikxcawnpfozuwejmarbvx 90 | qyvctiklcaynpfozuwejmhrbvx 91 | qyyltiklnagnpfozuwejmhrbvx 92 | oysdtillcagnpfozuwejmnrbvx 93 | qysdtiklcagnpfozuvmjmhrbzx 94 | qykdtikocagnpfhzuwejmhrbvx 95 | qysdtvkloagnpfozuwejmkrbvx 96 | qysetiklcagnpfozuwejmhrxvh 97 | qysdtiklcavnpfuzuwejmhrbvh 98 | qmndtiklcagnpfojuwejmhrbvx 99 | qysdtialcagnpfozuwejmdrqvx 100 | qysdtiklcagnpfozuwejtzrbvv 101 | qysdtiklxagnpyozufejmhrbvx 102 | qysdtiklcagnpfgzewejahrbvx 103 | qysdtiklcagppsozuwejmhrdvx 104 | qykdtiklcainpfozuwejqhrbvx 105 | qysdtiklcagnpfszxwejmhubvx 106 | qyrdtiklcagkptozuwejmhrbvx 107 | qysdsiklcagnpfozsvejmhrbvx 108 | qypdtiklcagypfozuwejmhrlvx 109 | qssdtiklcagnpfozuwqjmirbvx 110 | qyshtiklcagnpfrzuwyjmhrbvx 111 | qysdtiklcagnpfqzuwenmgrbvx 112 | qysdtiklcagnpfonuwejmhkwvx 113 | qysdhiklcagnpfokuwejmhrfvx 114 | jysrtiklcaenpfozuwejmhrbvx 115 | qysdtiilcagnpfozuwejmhcbvl 116 | qysdtiklcagnheozuwejmhrbvn 117 | qysdtikucagwpfojuwejmhrbvx 118 | qysdtinlctgnpfozuwujmhrbvx 119 | qysdtiklcagnpiozuwejmtrbjx 120 | qysktiklcagqpfozuwcjmhrbvx 121 | qysddiklcagnpfozpwejmhrbvh 122 | wysdtiplcagnpfozuwejyhrbvx 123 | qysdtiklcagnpfjzlwejmhrcvx 124 | qysdtikleagopbozuwejmhrbvx 125 | qysdtqklcwgnpfozuwejmirbvx 126 | qysdtiklcugnpmozuwejmhrbvp 127 | qysdtiklcagnpfozpwejmnrbvz 128 | qysdtiklcagnpcozuwejmhbbmx 129 | uysitiklcagnpfozewejmhrbvx 130 | qykdtiklcasnpfozuwejdhrbvx 131 | qyjdtiklcagnpqozuzejmhrbvx 132 | qysdtiklcagaifozuwejmhrbvh 133 | qysdtiklcagnhfozuwyjrhrbvx 134 | qysetiklcaanpfozuwyjmhrbvx 135 | qyfdtiklcagnphozulejmhrbvx 136 | qysdtikkcrgnpfozuwejmhpbvx 137 | qysdtiklcarnpfdzuwejmhrbvq 138 | qysdtiklcfyrpfozuwejmhrbvx 139 | rysdtitlcagnpfoznwejmhrbvx 140 | qysdtiilcagnffozugejmhrbvx 141 | qysdyifloagnpfozuwejmhrbvx 142 | qysdtiklcegnpfozuwejmlrcvx 143 | qysdtiklcagnpfozuwajmhbbqx 144 | qysptrklcarnpfozuwejmhrbvx 145 | qysdtiklcagnldozuwejmhwbvx 146 | qysdtiklczgqpfozuwejmhobvx 147 | qyxdtiklcagcpfoiuwejmhrbvx 148 | qysatiklczgnpfozawejmhrbvx 149 | qysduiklcagnpfoziwejyhrbvx 150 | qysdtgklqagnpfozujejmhrbvx 151 | qysdtiqlcagnpfozzdejmhrbvx 152 | qysdtiklcngnpfofuwejmzrbvx 153 | qysdtiklcagnyfozuwejrnrbvx 154 | qysdtiplcagnpfozowmjmhrbvx 155 | qyswtiklcagnplozuwedmhrbvx 156 | qyseiiklcagnpfozuwejmhibvx 157 | qysdtiklcagnpfozutusmhrbvx 158 | qysdtimlcagnpfozccejmhrbvx 159 | qnsdniklcagnpfobuwejmhrbvx 160 | qysrtiklcagnpfofuwejmhrbyx 161 | qyzdtiklcagnpfoizwejmhrbvx 162 | qysdtjslcdgnpfozuwejmhrbvx 163 | qysdtiklcagnpxoyuwejmrrbvx 164 | qysdtikllagnpfmzuwbjmhrbvx 165 | qysdtitlcagnkfozuwejwhrbvx 166 | qymdtiklcggnpfozuwejmzrbvx 167 | qysdtiklclfnpfozuhejmhrbvx 168 | qysdtyklcagnpfozuwejmhhbix 169 | qysetiklcagnpfozuwejmhrspx 170 | qysdipklcagnpfozuwejmhrbex 171 | uysgtiklcagnpmozuwejmhrbvx 172 | qysdtiklmagnpfozuwqlmhrbvx 173 | qysdtiklcagnyfozxwejmhrmvx 174 | qysutillcagnpfozuwejmhrbbx 175 | casdtiklcagnpfopuwejmhrbvx 176 | qesdtiklctgnpfmzuwejmhrbvx 177 | qysdtiklcagopfozjwejmdrbvx 178 | jzsdtiklcagnpfozuwejmurbvx 179 | qysdtiklcjgnpfonuwejrhrbvx 180 | qysdtiklcrgnpnozuwejmhqbvx 181 | oyhdtiklcagnpfozuwekmhrbvx 182 | qysstiklcagjpfozuwejmhrbnx 183 | qyudtiklsagnpsozuwejmhrbvx 184 | qysdtiilcagnpfozusejmhrbva 185 | qysdtiklcaknpfozmwejmhgbvx 186 | qysdbiklcpgnpfozuwejmrrbvx 187 | qybdtiklcagvpfokuwejmhrbvx 188 | qysatiklcagnpwofuwejmhrbvx 189 | qysdtiklcadnpfonuwejmcrbvx 190 | qysdtijfcagnpfozuvejmhrbvx 191 | qysdtiklcagnpfhluuejmhrbvx 192 | qysdtiklcagnpfoguwejqhrwvx 193 | qlsdtiklcagnpfojuwehmhrbvx 194 | qyhdtiolcagnpfozuwejmhrzvx 195 | qmsdtiklcagnppozuwpjmhrbvx 196 | qysdtiklvvgnpfvzuwejmhrbvx 197 | qysdtiklcagnpfszuwajmhrcvx 198 | qysdtiklcagnpfmzuwekmhrbyx 199 | qysdtiklcagwpfozumevmhrbvx 200 | qysdtaklcagnpfozuwejvhzbvx 201 | qysotiklcagntffzuwejmhrbvx 202 | qysdtiklcagnpfowuweqmhrivx 203 | qysdtrkloagnxfozuwujmhrbvx 204 | qasdiiklcagnpfozuwegmhrbvx 205 | qysbtiklcagnpfozuwejthrbhx 206 | hysdtikllagnpfozuwejmhrbbx 207 | qyqdtiklcagnpsozuwejmcrbvx 208 | qysdtiklcagnpiqzuwejmhrbux 209 | qnsdtiklcagnpfozdwejmhbbvx 210 | qysjbiklcagzpfozuwejmhrbvx 211 | qysdtiklcagnpfifuwejmhrbvg 212 | qysdtiklcaggpkozunejmhrbvx 213 | qxsdtiklcavnpfozuwfjmhrbvx 214 | qysdtikycabnpfkzuwejmhrbvx 215 | qyswtzklcagnpfozuwejmhrlvx 216 | qysdtikqcagnpfozuwejrhnbvx 217 | qysdtiplaagnpfozuwejmhruvx 218 | qjcdtiklcagnpfozujejmhrbvx 219 | nysdtyklcagnpfozutejmhrbvx 220 | qysrtiklcagnpfnzuwejmhrbdx 221 | zysdtielcagnpfozuwezmhrbvx 222 | qysdtikpvagnpfozuzejmhrbvx 223 | qysdwiklcagnpfozueejmhrlvx 224 | dysdmiklcagnpfozuwejzhrbvx 225 | qysdtiklcjgnpfozuweimhmbvx 226 | qysdtiklciynpyozuwejmhrbvx 227 | qksdtiklcagnpbozubejmhrbvx 228 | qysdtiklkagnpfozuwejmhrjvb 229 | yyxdtiklcagnpfomuwejmhrbvx 230 | qysdtiklcagnfnozuwejmhrbvv 231 | qysdtzklcagnpfozuwejmhrmvb 232 | qysduiklclgnpfozuwejmhrbvn 233 | qyndtmklcavnpfozuwejmhrbvx 234 | qisdkiklcagnpfozuwqjmhrbvx 235 | qysdtrkycagypfozuwejmhrbvx 236 | qhsdtiklcwgnmfozuwejmhrbvx 237 | qysdaiklcannpfozupejmhrbvx 238 | zysdtiklcagnpjozuwejmhrbwx 239 | qysdtikxcagnpfozuwejmcrxvx 240 | qysdtzklcagnpfozewejmhrbvk 241 | qysdwtklcagnhfozuwejmhrbvx 242 | qysdtqklcaenpfozuwejmdrbvx 243 | qysdtiklcagnpfozuoeemhqbvx 244 | nysdtikocagnpfozuwejmhwbvx 245 | qysxtiklcagnpfozqwejmhrbax 246 | qysdtielcasnpfozuwejmhsbvx 247 | qysdtiklcaknpfozuwejcwrbvx 248 | qysytiklcagnpfozdfejmhrbvx 249 | qysdtiklcagmpfozuwejmgrbox 250 | qysdtielcagnpfpzuwejhhrbvx 251 | -------------------------------------------------------------------------------- /p20.dyalog: -------------------------------------------------------------------------------- 1 | p←1↓¯2↓⊃⎕NGET'p20.txt' 2 | r←s←1 2⍴0 3 | {⍵='(':s⍪←⊢⌿r ⋄ ⍵='|':r⍪←⊢⌿s ⋄ ⍵=')':s↓⍨←¯1 ⋄ r⍪←(⊢⌿r)+1,0J1*'NESW'⍳⍵}¨p 4 | t←⊃{⌊/⍵}⌸/⌽↓⍉r 5 | ⌈/t ⍝ part 1 6 | +/999+/,|p-⍤1⊢⍵}¨⍳⌈⌿p ⍝ part 2 8 | -------------------------------------------------------------------------------- /p6.txt: -------------------------------------------------------------------------------- 1 | 227, 133 2 | 140, 168 3 | 99, 112 4 | 318, 95 5 | 219, 266 6 | 134, 144 7 | 306, 301 8 | 189, 188 9 | 58, 334 10 | 337, 117 11 | 255, 73 12 | 245, 144 13 | 102, 257 14 | 255, 353 15 | 303, 216 16 | 141, 167 17 | 40, 321 18 | 201, 50 19 | 60, 188 20 | 132, 74 21 | 125, 199 22 | 176, 307 23 | 204, 218 24 | 338, 323 25 | 276, 278 26 | 292, 229 27 | 109, 228 28 | 85, 305 29 | 86, 343 30 | 97, 254 31 | 182, 151 32 | 110, 292 33 | 285, 124 34 | 43, 223 35 | 153, 188 36 | 285, 136 37 | 334, 203 38 | 84, 243 39 | 92, 185 40 | 330, 223 41 | 259, 275 42 | 106, 199 43 | 183, 205 44 | 188, 212 45 | 231, 150 46 | 158, 95 47 | 174, 212 48 | 279, 97 49 | 172, 131 50 | 247, 320 51 | -------------------------------------------------------------------------------- /p6flat.dyalog: -------------------------------------------------------------------------------- 1 | p←↑⍎¨⊃⎕NGET'p6.txt'1 2 | +/,10000>+⌿+/|p-⍤1⍤1 3↑⍳⌈⌿p ⍝ part 2 3 | -------------------------------------------------------------------------------- /p6linear.dyalog: -------------------------------------------------------------------------------- 1 | p←↑⍎¨⊃⎕NGET'p6.txt'1 2 | sort←{(⊂⍋⍵)⌷⍵} 3 | f←{+\(+/⍵),¯1↓(-≢⍵)++\0,z⊣z[⍵]+←2⊣z←0/⍨⌈/⍵} 4 | +/(sort f⊣/p)⍸9999-f⊢/p ⍝ part 2 5 | -------------------------------------------------------------------------------- /p7.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | p←5 36∘.⌷⊃⎕NGET'p7.txt'1 3 | ⎕A{0=≢⍺:⍬ ⋄ s,(⍺~s)∇⍵/⍨(⊣⌿⍵)≠s←⊃⍺~⊢⌿⍵}p ⍝ part 1 4 | ⍬{0=≢,w←⍵/⍨~(⊣⌿⍵)∊⍺~a←' '@(⍺⍳∪⍺)⊢⍺:0 ⋄ t←(5-≢∪a)↑(∪,w)~a,⊢⌿w ⋄ 1+(a,t/⍨61+⎕A⍳t)∇w}p,⍨2↑⍉⍪⎕A ⍝ part 2 5 | -------------------------------------------------------------------------------- /p7.txt: -------------------------------------------------------------------------------- 1 | Step P must be finished before step Z can begin. 2 | Step E must be finished before step O can begin. 3 | Step X must be finished before step T can begin. 4 | Step W must be finished before step V can begin. 5 | Step K must be finished before step Y can begin. 6 | Step C must be finished before step M can begin. 7 | Step S must be finished before step R can begin. 8 | Step T must be finished before step H can begin. 9 | Step Z must be finished before step V can begin. 10 | Step F must be finished before step L can begin. 11 | Step V must be finished before step A can begin. 12 | Step I must be finished before step A can begin. 13 | Step J must be finished before step M can begin. 14 | Step N must be finished before step Y can begin. 15 | Step A must be finished before step B can begin. 16 | Step H must be finished before step Q can begin. 17 | Step Q must be finished before step O can begin. 18 | Step D must be finished before step O can begin. 19 | Step Y must be finished before step O can begin. 20 | Step G must be finished before step L can begin. 21 | Step B must be finished before step M can begin. 22 | Step L must be finished before step U can begin. 23 | Step M must be finished before step O can begin. 24 | Step O must be finished before step U can begin. 25 | Step R must be finished before step U can begin. 26 | Step M must be finished before step U can begin. 27 | Step Q must be finished before step U can begin. 28 | Step K must be finished before step U can begin. 29 | Step D must be finished before step R can begin. 30 | Step A must be finished before step M can begin. 31 | Step A must be finished before step Q can begin. 32 | Step V must be finished before step Y can begin. 33 | Step H must be finished before step G can begin. 34 | Step P must be finished before step K can begin. 35 | Step N must be finished before step A can begin. 36 | Step P must be finished before step H can begin. 37 | Step X must be finished before step Z can begin. 38 | Step X must be finished before step K can begin. 39 | Step Y must be finished before step U can begin. 40 | Step F must be finished before step Q can begin. 41 | Step W must be finished before step M can begin. 42 | Step B must be finished before step L can begin. 43 | Step E must be finished before step L can begin. 44 | Step N must be finished before step O can begin. 45 | Step I must be finished before step G can begin. 46 | Step J must be finished before step H can begin. 47 | Step Z must be finished before step N can begin. 48 | Step V must be finished before step N can begin. 49 | Step F must be finished before step B can begin. 50 | Step A must be finished before step Y can begin. 51 | Step Q must be finished before step R can begin. 52 | Step L must be finished before step O can begin. 53 | Step H must be finished before step U can begin. 54 | Step V must be finished before step G can begin. 55 | Step Z must be finished before step B can begin. 56 | Step V must be finished before step J can begin. 57 | Step V must be finished before step O can begin. 58 | Step T must be finished before step D can begin. 59 | Step Y must be finished before step M can begin. 60 | Step B must be finished before step R can begin. 61 | Step O must be finished before step R can begin. 62 | Step C must be finished before step V can begin. 63 | Step W must be finished before step T can begin. 64 | Step P must be finished before step N can begin. 65 | Step L must be finished before step R can begin. 66 | Step V must be finished before step U can begin. 67 | Step C must be finished before step J can begin. 68 | Step N must be finished before step R can begin. 69 | Step X must be finished before step S can begin. 70 | Step X must be finished before step A can begin. 71 | Step G must be finished before step O can begin. 72 | Step A must be finished before step O can begin. 73 | Step X must be finished before step O can begin. 74 | Step D must be finished before step Y can begin. 75 | Step C must be finished before step G can begin. 76 | Step K must be finished before step D can begin. 77 | Step N must be finished before step B can begin. 78 | Step C must be finished before step B can begin. 79 | Step W must be finished before step F can begin. 80 | Step E must be finished before step Z can begin. 81 | Step S must be finished before step V can begin. 82 | Step G must be finished before step M can begin. 83 | Step T must be finished before step B can begin. 84 | Step W must be finished before step C can begin. 85 | Step D must be finished before step G can begin. 86 | Step L must be finished before step M can begin. 87 | Step H must be finished before step D can begin. 88 | Step G must be finished before step R can begin. 89 | Step T must be finished before step J can begin. 90 | Step A must be finished before step R can begin. 91 | Step B must be finished before step O can begin. 92 | Step J must be finished before step R can begin. 93 | Step G must be finished before step U can begin. 94 | Step K must be finished before step O can begin. 95 | Step V must be finished before step L can begin. 96 | Step M must be finished before step R can begin. 97 | Step D must be finished before step U can begin. 98 | Step H must be finished before step Y can begin. 99 | Step P must be finished before step W can begin. 100 | Step K must be finished before step I can begin. 101 | Step J must be finished before step G can begin. 102 | -------------------------------------------------------------------------------- /p8.dyalog: -------------------------------------------------------------------------------- 1 | p←⍎⊃⊃⎕NGET'p8.txt' 1 2 | e←{⍵≡⍬:⍬ ⋄ ⍺⍺¨⍵} 3 | n←0 ⋄ {a b←p[(n+←2)⊢n+⍳2] ⋄ +/p[(n+←b)⊢n+⍳b],∇ e⍳a}0 ⍝ part 1 4 | n←0 ⋄ {a b←p[(n+←2)⊢n+⍳2] ⋄ c←∇ e⍳a ⋄ m←p[(n+←b)⊢n+⍳b] ⋄ a=0:+/m ⋄ +/c[m∩⍳a]}0 ⍝ part 2 5 | -------------------------------------------------------------------------------- /p8.txt: -------------------------------------------------------------------------------- 1 | 7 11 7 2 5 5 3 6 1 9 0 11 6 5 4 2 3 8 4 1 6 2 7 2 1 1 1 2 3 2 3 1 1 5 0 7 1 2 8 6 7 1 6 1 1 1 1 2 1 9 0 10 1 6 9 4 9 5 1 2 8 3 1 2 1 3 1 1 1 2 3 3 2 5 3 2 3 3 6 1 8 0 9 9 5 1 1 3 3 6 2 7 1 1 1 2 3 2 2 2 1 6 0 11 8 5 1 3 3 9 5 1 2 8 6 2 3 1 2 1 2 1 8 0 6 4 8 5 5 1 3 3 1 1 3 3 3 1 3 1 1 3 1 2 4 3 5 1 5 0 8 6 6 4 4 7 8 1 1 3 1 2 1 2 1 6 0 7 1 8 4 1 3 1 3 1 2 1 1 3 1 1 8 0 9 7 6 4 1 5 3 1 7 4 2 1 1 3 3 3 1 3 1 4 2 2 5 3 7 1 5 0 11 8 1 4 1 9 9 5 5 5 9 3 3 1 2 1 2 1 8 0 10 9 4 1 2 4 6 1 2 1 3 2 2 1 3 3 1 2 1 1 7 0 6 1 1 9 3 8 5 3 2 3 1 1 2 1 3 3 5 1 4 2 2 3 4 1 5 0 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7 0 6 9 7 5 9 1 3 1 1 1 3 1 3 3 1 8 0 10 1 3 9 4 9 6 2 9 4 1 1 2 3 3 2 1 3 3 1 7 0 6 3 1 8 2 7 1 1 1 1 3 3 3 3 3 3 5 5 5 3 7 1 8 0 10 1 4 4 8 5 7 1 1 2 6 1 1 3 1 3 1 2 1 1 5 0 11 1 4 1 3 2 6 9 1 2 7 6 2 3 3 1 1 1 9 0 8 8 7 2 6 1 8 1 8 3 2 1 3 1 3 3 2 3 1 1 4 2 3 2 3 2 3 3 3 2 2 8 4 5 9 5 8 2 4 9 8 1 2 | -------------------------------------------------------------------------------- /p9.dyalog: -------------------------------------------------------------------------------- 1 | ⎕IO←0 2 | (p w)←⍎¨'\d+'⎕S'&'⊃⊃⎕NGET'p9.txt'1 3 | 4 | ins←{q←(p←⍵ 1⌷m)1⌷m ⋄ n←m[(p 1)(q 0)]←≢m ⋄ m⍪←p q ⋄ n} 5 | del←{f←{⍵ 0⌷m} ⋄ p←f(r,←f(q←f⍣6⊢⍵)) ⋄ m[(p 1)(q 0)]←q p ⋄ m⍪←0 ⋄ q} 6 | run←{ins⍣(23|⍵)del∘(ins⍣22)⍣(⌊⍵÷23)⊢0} 7 | hscore←{⌈/+⌿z⍵⍴(⍵×z←⌈⍵÷⍨≢r)↑r+23×1+⍳≢r} 8 | 9 | r←⍬ ⋄ m←1 2⍴0 ⋄ (hscore p)⊣run w ⍝ part 1 10 | r←⍬ ⋄ m←1 2⍴0 ⋄ (hscore p)⊣run w×100 ⍝ part 2 11 | -------------------------------------------------------------------------------- /p9.txt: -------------------------------------------------------------------------------- 1 | 470 players; last marble is worth 72170 points 2 | --------------------------------------------------------------------------------