chore: move jj up a level

thecoded.prof 1414ea66 c977d2e0

verified
-1
.envrc
··· 1 - use_flake .
···
.gitignore 2024/.gitignore
+1
2024/day_5/.gitignore
···
··· 1 + /target
+7
2024/day_5/Cargo.lock
···
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "day_5" 7 + version = "0.1.0"
+6
2024/day_5/Cargo.toml
···
··· 1 + [package] 2 + name = "day_5" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [dependencies]
+1366
2024/day_5/input.txt
···
··· 1 + 48|39 2 + 39|84 3 + 39|23 4 + 95|51 5 + 95|76 6 + 95|61 7 + 14|52 8 + 14|49 9 + 14|39 10 + 14|53 11 + 85|19 12 + 85|25 13 + 85|61 14 + 85|35 15 + 85|58 16 + 74|86 17 + 74|55 18 + 74|49 19 + 74|18 20 + 74|83 21 + 74|47 22 + 45|49 23 + 45|76 24 + 45|86 25 + 45|22 26 + 45|35 27 + 45|18 28 + 45|37 29 + 52|58 30 + 52|16 31 + 52|23 32 + 52|12 33 + 52|31 34 + 52|27 35 + 52|46 36 + 52|15 37 + 49|71 38 + 49|44 39 + 49|54 40 + 49|91 41 + 49|58 42 + 49|25 43 + 49|52 44 + 49|84 45 + 49|46 46 + 86|26 47 + 86|95 48 + 86|52 49 + 86|51 50 + 86|48 51 + 86|91 52 + 86|55 53 + 86|22 54 + 86|11 55 + 86|37 56 + 69|18 57 + 69|86 58 + 69|98 59 + 69|34 60 + 69|79 61 + 69|95 62 + 69|22 63 + 69|27 64 + 69|15 65 + 69|65 66 + 69|37 67 + 66|83 68 + 66|65 69 + 66|18 70 + 66|92 71 + 66|48 72 + 66|32 73 + 66|16 74 + 66|47 75 + 66|22 76 + 66|95 77 + 66|37 78 + 66|49 79 + 15|22 80 + 15|83 81 + 15|37 82 + 15|49 83 + 15|65 84 + 15|85 85 + 15|31 86 + 15|95 87 + 15|79 88 + 15|47 89 + 15|74 90 + 15|16 91 + 15|86 92 + 71|16 93 + 71|66 94 + 71|92 95 + 71|84 96 + 71|15 97 + 71|54 98 + 71|25 99 + 71|53 100 + 71|31 101 + 71|98 102 + 71|46 103 + 71|69 104 + 71|74 105 + 71|58 106 + 79|49 107 + 79|34 108 + 79|86 109 + 79|26 110 + 79|18 111 + 79|14 112 + 79|22 113 + 79|91 114 + 79|77 115 + 79|48 116 + 79|37 117 + 79|52 118 + 79|95 119 + 79|35 120 + 79|74 121 + 76|39 122 + 76|84 123 + 76|94 124 + 76|77 125 + 76|12 126 + 76|24 127 + 76|46 128 + 76|69 129 + 76|15 130 + 76|53 131 + 76|23 132 + 76|19 133 + 76|52 134 + 76|11 135 + 76|66 136 + 76|25 137 + 19|94 138 + 19|79 139 + 19|71 140 + 19|92 141 + 19|66 142 + 19|16 143 + 19|53 144 + 19|45 145 + 19|69 146 + 19|31 147 + 19|24 148 + 19|25 149 + 19|12 150 + 19|54 151 + 19|84 152 + 19|58 153 + 19|98 154 + 11|25 155 + 11|27 156 + 11|84 157 + 11|12 158 + 11|24 159 + 11|66 160 + 11|19 161 + 11|51 162 + 11|69 163 + 11|16 164 + 11|53 165 + 11|94 166 + 11|58 167 + 11|44 168 + 11|23 169 + 11|39 170 + 11|35 171 + 11|52 172 + 92|37 173 + 92|91 174 + 92|31 175 + 92|48 176 + 92|76 177 + 92|14 178 + 92|34 179 + 92|55 180 + 92|32 181 + 92|85 182 + 92|86 183 + 92|98 184 + 92|83 185 + 92|49 186 + 92|18 187 + 92|26 188 + 92|95 189 + 92|11 190 + 92|74 191 + 23|16 192 + 23|18 193 + 23|86 194 + 23|74 195 + 23|92 196 + 23|66 197 + 23|79 198 + 23|55 199 + 23|45 200 + 23|47 201 + 23|26 202 + 23|37 203 + 23|15 204 + 23|24 205 + 23|12 206 + 23|98 207 + 23|34 208 + 23|48 209 + 23|65 210 + 23|27 211 + 37|51 212 + 37|61 213 + 37|26 214 + 37|47 215 + 37|49 216 + 37|84 217 + 37|52 218 + 37|34 219 + 37|55 220 + 37|39 221 + 37|14 222 + 37|19 223 + 37|77 224 + 37|35 225 + 37|58 226 + 37|91 227 + 37|83 228 + 37|76 229 + 37|85 230 + 37|11 231 + 37|32 232 + 55|44 233 + 55|19 234 + 55|52 235 + 55|39 236 + 55|84 237 + 55|54 238 + 55|32 239 + 55|47 240 + 55|71 241 + 55|51 242 + 55|83 243 + 55|35 244 + 55|91 245 + 55|85 246 + 55|76 247 + 55|11 248 + 55|58 249 + 55|61 250 + 55|53 251 + 55|49 252 + 55|25 253 + 55|77 254 + 27|48 255 + 27|18 256 + 27|65 257 + 27|34 258 + 27|74 259 + 27|37 260 + 27|47 261 + 27|98 262 + 27|55 263 + 27|83 264 + 27|79 265 + 27|16 266 + 27|86 267 + 27|85 268 + 27|45 269 + 27|66 270 + 27|22 271 + 27|49 272 + 27|15 273 + 27|26 274 + 27|14 275 + 27|92 276 + 27|95 277 + 51|16 278 + 51|84 279 + 51|54 280 + 51|77 281 + 51|27 282 + 51|94 283 + 51|66 284 + 51|23 285 + 51|19 286 + 51|25 287 + 51|71 288 + 51|65 289 + 51|15 290 + 51|52 291 + 51|39 292 + 51|44 293 + 51|46 294 + 51|24 295 + 51|12 296 + 51|31 297 + 51|92 298 + 51|69 299 + 51|58 300 + 51|53 301 + 83|32 302 + 83|52 303 + 83|35 304 + 83|76 305 + 83|94 306 + 83|44 307 + 83|84 308 + 83|14 309 + 83|71 310 + 83|77 311 + 83|61 312 + 83|12 313 + 83|85 314 + 83|23 315 + 83|39 316 + 83|51 317 + 83|19 318 + 83|54 319 + 83|25 320 + 83|49 321 + 83|11 322 + 83|53 323 + 83|58 324 + 83|91 325 + 94|66 326 + 94|15 327 + 94|74 328 + 94|12 329 + 94|55 330 + 94|86 331 + 94|16 332 + 94|69 333 + 94|26 334 + 94|45 335 + 94|34 336 + 94|65 337 + 94|98 338 + 94|18 339 + 94|23 340 + 94|48 341 + 94|46 342 + 94|92 343 + 94|37 344 + 94|31 345 + 94|22 346 + 94|27 347 + 94|24 348 + 94|79 349 + 54|15 350 + 54|26 351 + 54|92 352 + 54|46 353 + 54|69 354 + 54|22 355 + 54|23 356 + 54|66 357 + 54|24 358 + 54|74 359 + 54|31 360 + 54|37 361 + 54|16 362 + 54|48 363 + 54|34 364 + 54|94 365 + 54|65 366 + 54|79 367 + 54|45 368 + 54|18 369 + 54|12 370 + 54|27 371 + 54|86 372 + 54|98 373 + 58|23 374 + 58|31 375 + 58|48 376 + 58|25 377 + 58|79 378 + 58|65 379 + 58|15 380 + 58|24 381 + 58|16 382 + 58|54 383 + 58|86 384 + 58|22 385 + 58|94 386 + 58|46 387 + 58|27 388 + 58|12 389 + 58|45 390 + 58|69 391 + 58|92 392 + 58|74 393 + 58|66 394 + 58|44 395 + 58|98 396 + 58|18 397 + 61|65 398 + 61|46 399 + 61|54 400 + 61|19 401 + 61|77 402 + 61|52 403 + 61|39 404 + 61|25 405 + 61|66 406 + 61|12 407 + 61|24 408 + 61|94 409 + 61|44 410 + 61|51 411 + 61|27 412 + 61|15 413 + 61|69 414 + 61|71 415 + 61|23 416 + 61|84 417 + 61|58 418 + 61|92 419 + 61|16 420 + 61|53 421 + 77|53 422 + 77|84 423 + 77|24 424 + 77|58 425 + 77|65 426 + 77|12 427 + 77|31 428 + 77|92 429 + 77|46 430 + 77|23 431 + 77|66 432 + 77|27 433 + 77|25 434 + 77|39 435 + 77|19 436 + 77|71 437 + 77|16 438 + 77|45 439 + 77|52 440 + 77|94 441 + 77|69 442 + 77|44 443 + 77|54 444 + 77|15 445 + 32|35 446 + 32|61 447 + 32|51 448 + 32|71 449 + 32|91 450 + 32|53 451 + 32|46 452 + 32|39 453 + 32|52 454 + 32|11 455 + 32|23 456 + 32|77 457 + 32|76 458 + 32|12 459 + 32|27 460 + 32|54 461 + 32|94 462 + 32|19 463 + 32|58 464 + 32|44 465 + 32|25 466 + 32|24 467 + 32|69 468 + 32|84 469 + 31|85 470 + 31|79 471 + 31|35 472 + 31|91 473 + 31|86 474 + 31|18 475 + 31|76 476 + 31|98 477 + 31|55 478 + 31|45 479 + 31|95 480 + 31|11 481 + 31|49 482 + 31|22 483 + 31|14 484 + 31|74 485 + 31|34 486 + 31|32 487 + 31|26 488 + 31|48 489 + 31|83 490 + 31|61 491 + 31|37 492 + 31|47 493 + 34|26 494 + 34|77 495 + 34|85 496 + 34|47 497 + 34|61 498 + 34|52 499 + 34|19 500 + 34|11 501 + 34|58 502 + 34|91 503 + 34|35 504 + 34|95 505 + 34|39 506 + 34|25 507 + 34|14 508 + 34|53 509 + 34|71 510 + 34|84 511 + 34|76 512 + 34|51 513 + 34|83 514 + 34|55 515 + 34|49 516 + 34|32 517 + 46|22 518 + 46|26 519 + 46|98 520 + 46|27 521 + 46|45 522 + 46|15 523 + 46|83 524 + 46|86 525 + 46|24 526 + 46|18 527 + 46|65 528 + 46|79 529 + 46|34 530 + 46|16 531 + 46|55 532 + 46|74 533 + 46|95 534 + 46|66 535 + 46|92 536 + 46|37 537 + 46|47 538 + 46|48 539 + 46|69 540 + 46|31 541 + 26|53 542 + 26|95 543 + 26|35 544 + 26|47 545 + 26|19 546 + 26|76 547 + 26|83 548 + 26|55 549 + 26|11 550 + 26|51 551 + 26|77 552 + 26|52 553 + 26|39 554 + 26|71 555 + 26|91 556 + 26|44 557 + 26|32 558 + 26|84 559 + 26|85 560 + 26|14 561 + 26|49 562 + 26|61 563 + 26|25 564 + 26|58 565 + 91|24 566 + 91|23 567 + 91|94 568 + 91|69 569 + 91|46 570 + 91|27 571 + 91|76 572 + 91|58 573 + 91|53 574 + 91|11 575 + 91|19 576 + 91|39 577 + 91|52 578 + 91|61 579 + 91|84 580 + 91|51 581 + 91|25 582 + 91|54 583 + 91|77 584 + 91|35 585 + 91|44 586 + 91|12 587 + 91|15 588 + 91|71 589 + 53|48 590 + 53|69 591 + 53|44 592 + 53|94 593 + 53|92 594 + 53|66 595 + 53|79 596 + 53|98 597 + 53|31 598 + 53|27 599 + 53|45 600 + 53|15 601 + 53|16 602 + 53|22 603 + 53|12 604 + 53|86 605 + 53|54 606 + 53|24 607 + 53|58 608 + 53|23 609 + 53|74 610 + 53|46 611 + 53|65 612 + 53|25 613 + 12|74 614 + 12|16 615 + 12|65 616 + 12|66 617 + 12|95 618 + 12|31 619 + 12|34 620 + 12|37 621 + 12|47 622 + 12|24 623 + 12|98 624 + 12|92 625 + 12|15 626 + 12|22 627 + 12|69 628 + 12|86 629 + 12|27 630 + 12|46 631 + 12|55 632 + 12|26 633 + 12|45 634 + 12|18 635 + 12|79 636 + 12|48 637 + 24|34 638 + 24|15 639 + 24|26 640 + 24|27 641 + 24|95 642 + 24|55 643 + 24|37 644 + 24|14 645 + 24|74 646 + 24|48 647 + 24|31 648 + 24|66 649 + 24|45 650 + 24|98 651 + 24|18 652 + 24|86 653 + 24|92 654 + 24|16 655 + 24|65 656 + 24|47 657 + 24|83 658 + 24|79 659 + 24|22 660 + 24|85 661 + 84|54 662 + 84|98 663 + 84|53 664 + 84|46 665 + 84|58 666 + 84|23 667 + 84|22 668 + 84|12 669 + 84|16 670 + 84|94 671 + 84|45 672 + 84|66 673 + 84|65 674 + 84|31 675 + 84|86 676 + 84|79 677 + 84|25 678 + 84|24 679 + 84|69 680 + 84|15 681 + 84|74 682 + 84|27 683 + 84|92 684 + 84|44 685 + 18|53 686 + 18|35 687 + 18|55 688 + 18|77 689 + 18|85 690 + 18|37 691 + 18|83 692 + 18|26 693 + 18|52 694 + 18|14 695 + 18|39 696 + 18|51 697 + 18|19 698 + 18|71 699 + 18|11 700 + 18|84 701 + 18|91 702 + 18|49 703 + 18|32 704 + 18|34 705 + 18|76 706 + 18|95 707 + 18|61 708 + 18|47 709 + 25|65 710 + 25|12 711 + 25|94 712 + 25|37 713 + 25|45 714 + 25|24 715 + 25|92 716 + 25|66 717 + 25|79 718 + 25|74 719 + 25|22 720 + 25|86 721 + 25|98 722 + 25|18 723 + 25|44 724 + 25|48 725 + 25|23 726 + 25|27 727 + 25|16 728 + 25|69 729 + 25|31 730 + 25|46 731 + 25|54 732 + 25|15 733 + 98|83 734 + 98|11 735 + 98|22 736 + 98|49 737 + 98|37 738 + 98|61 739 + 98|85 740 + 98|79 741 + 98|95 742 + 98|32 743 + 98|35 744 + 98|34 745 + 98|48 746 + 98|76 747 + 98|77 748 + 98|91 749 + 98|47 750 + 98|74 751 + 98|86 752 + 98|26 753 + 98|51 754 + 98|14 755 + 98|18 756 + 98|55 757 + 22|76 758 + 22|61 759 + 22|47 760 + 22|35 761 + 22|85 762 + 22|77 763 + 22|51 764 + 22|95 765 + 22|26 766 + 22|14 767 + 22|37 768 + 22|71 769 + 22|83 770 + 22|32 771 + 22|55 772 + 22|39 773 + 22|52 774 + 22|49 775 + 22|91 776 + 22|19 777 + 22|18 778 + 22|34 779 + 22|11 780 + 22|48 781 + 47|95 782 + 47|11 783 + 47|14 784 + 47|51 785 + 47|49 786 + 47|54 787 + 47|39 788 + 47|94 789 + 47|85 790 + 47|44 791 + 47|61 792 + 47|71 793 + 47|58 794 + 47|83 795 + 47|19 796 + 47|32 797 + 47|77 798 + 47|25 799 + 47|84 800 + 47|53 801 + 47|76 802 + 47|52 803 + 47|35 804 + 47|91 805 + 35|54 806 + 35|27 807 + 35|77 808 + 35|84 809 + 35|71 810 + 35|46 811 + 35|12 812 + 35|16 813 + 35|51 814 + 35|39 815 + 35|52 816 + 35|61 817 + 35|15 818 + 35|92 819 + 35|94 820 + 35|53 821 + 35|66 822 + 35|58 823 + 35|44 824 + 35|19 825 + 35|25 826 + 35|24 827 + 35|23 828 + 35|69 829 + 65|45 830 + 65|86 831 + 65|95 832 + 65|83 833 + 65|31 834 + 65|11 835 + 65|35 836 + 65|34 837 + 65|18 838 + 65|74 839 + 65|32 840 + 65|91 841 + 65|26 842 + 65|22 843 + 65|49 844 + 65|37 845 + 65|14 846 + 65|79 847 + 65|55 848 + 65|85 849 + 65|76 850 + 65|47 851 + 65|98 852 + 65|48 853 + 44|74 854 + 44|16 855 + 44|86 856 + 44|27 857 + 44|48 858 + 44|24 859 + 44|94 860 + 44|15 861 + 44|65 862 + 44|69 863 + 44|66 864 + 44|12 865 + 44|22 866 + 44|34 867 + 44|23 868 + 44|79 869 + 44|92 870 + 44|98 871 + 44|31 872 + 44|37 873 + 44|18 874 + 44|54 875 + 44|45 876 + 44|46 877 + 16|18 878 + 16|55 879 + 16|92 880 + 16|22 881 + 16|79 882 + 16|98 883 + 16|26 884 + 16|74 885 + 16|45 886 + 16|86 887 + 16|76 888 + 16|31 889 + 16|47 890 + 16|32 891 + 16|83 892 + 16|91 893 + 16|48 894 + 16|49 895 + 16|85 896 + 16|34 897 + 16|65 898 + 16|14 899 + 16|95 900 + 16|37 901 + 48|71 902 + 48|61 903 + 48|52 904 + 48|95 905 + 48|76 906 + 48|37 907 + 48|91 908 + 48|51 909 + 48|77 910 + 48|84 911 + 48|34 912 + 48|49 913 + 48|18 914 + 48|83 915 + 48|11 916 + 48|47 917 + 48|26 918 + 48|35 919 + 48|32 920 + 48|55 921 + 48|14 922 + 48|85 923 + 48|19 924 + 39|15 925 + 39|65 926 + 39|79 927 + 39|19 928 + 39|69 929 + 39|53 930 + 39|44 931 + 39|31 932 + 39|45 933 + 39|54 934 + 39|46 935 + 39|92 936 + 39|98 937 + 39|16 938 + 39|24 939 + 39|58 940 + 39|94 941 + 39|25 942 + 39|71 943 + 39|66 944 + 39|12 945 + 39|27 946 + 95|58 947 + 95|11 948 + 95|39 949 + 95|44 950 + 95|19 951 + 95|94 952 + 95|35 953 + 95|83 954 + 95|71 955 + 95|91 956 + 95|54 957 + 95|77 958 + 95|53 959 + 95|52 960 + 95|14 961 + 95|84 962 + 95|49 963 + 95|85 964 + 95|32 965 + 95|23 966 + 95|25 967 + 14|35 968 + 14|76 969 + 14|94 970 + 14|25 971 + 14|46 972 + 14|58 973 + 14|84 974 + 14|23 975 + 14|11 976 + 14|71 977 + 14|12 978 + 14|77 979 + 14|32 980 + 14|19 981 + 14|61 982 + 14|44 983 + 14|54 984 + 14|85 985 + 14|91 986 + 14|51 987 + 85|53 988 + 85|49 989 + 85|76 990 + 85|71 991 + 85|44 992 + 85|94 993 + 85|11 994 + 85|12 995 + 85|39 996 + 85|91 997 + 85|77 998 + 85|52 999 + 85|54 1000 + 85|69 1001 + 85|46 1002 + 85|23 1003 + 85|51 1004 + 85|84 1005 + 85|32 1006 + 74|61 1007 + 74|95 1008 + 74|26 1009 + 74|91 1010 + 74|48 1011 + 74|14 1012 + 74|37 1013 + 74|52 1014 + 74|34 1015 + 74|39 1016 + 74|32 1017 + 74|77 1018 + 74|22 1019 + 74|51 1020 + 74|76 1021 + 74|35 1022 + 74|11 1023 + 74|85 1024 + 45|83 1025 + 45|91 1026 + 45|11 1027 + 45|51 1028 + 45|79 1029 + 45|34 1030 + 45|47 1031 + 45|98 1032 + 45|55 1033 + 45|14 1034 + 45|74 1035 + 45|48 1036 + 45|26 1037 + 45|61 1038 + 45|32 1039 + 45|85 1040 + 45|95 1041 + 52|19 1042 + 52|98 1043 + 52|54 1044 + 52|71 1045 + 52|45 1046 + 52|25 1047 + 52|65 1048 + 52|92 1049 + 52|53 1050 + 52|66 1051 + 52|39 1052 + 52|84 1053 + 52|94 1054 + 52|69 1055 + 52|24 1056 + 52|44 1057 + 49|23 1058 + 49|11 1059 + 49|39 1060 + 49|51 1061 + 49|53 1062 + 49|35 1063 + 49|61 1064 + 49|24 1065 + 49|19 1066 + 49|94 1067 + 49|12 1068 + 49|77 1069 + 49|32 1070 + 49|69 1071 + 49|76 1072 + 86|49 1073 + 86|14 1074 + 86|83 1075 + 86|32 1076 + 86|76 1077 + 86|85 1078 + 86|61 1079 + 86|77 1080 + 86|18 1081 + 86|19 1082 + 86|34 1083 + 86|35 1084 + 86|47 1085 + 86|39 1086 + 69|92 1087 + 69|16 1088 + 69|83 1089 + 69|66 1090 + 69|48 1091 + 69|24 1092 + 69|26 1093 + 69|47 1094 + 69|14 1095 + 69|45 1096 + 69|55 1097 + 69|74 1098 + 69|31 1099 + 66|26 1100 + 66|79 1101 + 66|91 1102 + 66|31 1103 + 66|34 1104 + 66|85 1105 + 66|45 1106 + 66|98 1107 + 66|86 1108 + 66|14 1109 + 66|55 1110 + 66|74 1111 + 15|45 1112 + 15|14 1113 + 15|26 1114 + 15|32 1115 + 15|18 1116 + 15|98 1117 + 15|48 1118 + 15|34 1119 + 15|66 1120 + 15|92 1121 + 15|55 1122 + 71|45 1123 + 71|24 1124 + 71|44 1125 + 71|86 1126 + 71|12 1127 + 71|79 1128 + 71|23 1129 + 71|65 1130 + 71|94 1131 + 71|27 1132 + 79|85 1133 + 79|55 1134 + 79|11 1135 + 79|83 1136 + 79|61 1137 + 79|51 1138 + 79|76 1139 + 79|47 1140 + 79|32 1141 + 76|51 1142 + 76|27 1143 + 76|44 1144 + 76|35 1145 + 76|54 1146 + 76|58 1147 + 76|61 1148 + 76|71 1149 + 19|65 1150 + 19|23 1151 + 19|46 1152 + 19|15 1153 + 19|27 1154 + 19|74 1155 + 19|44 1156 + 11|61 1157 + 11|15 1158 + 11|77 1159 + 11|71 1160 + 11|54 1161 + 11|46 1162 + 92|47 1163 + 92|22 1164 + 92|79 1165 + 92|45 1166 + 92|65 1167 + 23|46 1168 + 23|22 1169 + 23|69 1170 + 23|31 1171 + 37|95 1172 + 37|53 1173 + 37|71 1174 + 55|95 1175 + 55|14 1176 + 27|31 1177 + 1178 + 61,58,51,32,12,14,71 1179 + 58,25,54,14,12,94,32,76,39 1180 + 35,53,26,77,14,71,25,76,85,55,51,49,95 1181 + 32,91,76,11,35,61,51,77,52,19,71,84,53,58,25,44,54,94,23,12,46,69,24 1182 + 18,37,26,47,83,85,49,32,76,35,61,77,52,19,71 1183 + 39,19,84,53,58,25,54,12,69,66,31 1184 + 61,52,71,84,44,66,92 1185 + 71,84,44,46,45 1186 + 32,91,76,35,51,77,52,71,84,53,58,25,44,54,94,23,12 1187 + 48,18,37,34,26,55,47,95,83,49,32,91,11,35,61,77,52,39,71 1188 + 25,54,12,46,79,74,18 1189 + 94,65,44,39,46,66,52,15,54,71,84,92,12,77,23,27,31,16,25,58,19,69,53 1190 + 19,71,53,25,44,54,94,23,46,69,24,15,66,16,65,31,79 1191 + 49,76,11,35,77,52,39,71,54,23,12,46,69 1192 + 69,58,19,71,35,61,16,46,54 1193 + 54,16,35,94,25,15,51 1194 + 34,26,55,47,95,14,85,49,32,91,76,11,35,61,51,77,52,39,19,71,84,53,58 1195 + 76,54,77,24,46,12,27,35,53,52,61,39,58,69,94,71,91,23,51 1196 + 14,27,83,85,37,65,16,18,79,22,48,66,86,92,47 1197 + 19,52,61,58,44,84,51 1198 + 27,15,66,16,92,31,98,79,74,86,18,37,26,55,85 1199 + 94,46,27,66,65,45,98,74,86,48,18,37,34 1200 + 66,46,53,52,77,35,16,27,61 1201 + 18,37,34,55,47,95,83,14,85,49,32,91,76,11,35,61,51,77,39,71,84 1202 + 61,51,77,52,39,19,71,84,53,58,25,54,94,23,12,46,69,24,27,15,66,16,92 1203 + 98,74,86,22,48,18,37,34,26,55,47,95,83,14,85,49,32,91,76,11,51 1204 + 49,32,51,39,84,53,69 1205 + 46,15,66,65,45,98,86,48,18,34,55,47,95 1206 + 25,94,23,12,66,16,92,31,79,86,22,48,18 1207 + 32,91,76,51,77,52,39,19,53,58,25,54,94,23,12,69,24 1208 + 34,26,55,47,83,14,76,35,61,51,77,39,19,84,53 1209 + 34,18,95,74,35,37,47,52,76,32,22,48,51,86,77,85,11,55,83,14,26 1210 + 25,44,54,23,46,69,27,16,92,31,45,98,22,48,18 1211 + 91,58,11,76,26,49,19,95,14,61,39 1212 + 48,18,37,34,55,47,95,14,85,49,32,91,76,35,61,51,77,52,39,19,71 1213 + 31,66,27,79,23,86,22,92,15,44,54,94,16,37,12,18,45 1214 + 16,24,66,53,12,77,19,65,15,51,27,94,23,52,39,46,58,69,92,84,71,54,25 1215 + 44,54,94,12,46,24,27,15,92,31,86,22,37 1216 + 39,71,53,54,15,45,98 1217 + 69,53,44,54,77,58,27,39,61,25,12,94,23,51,35,84,71,15,46,66,16,19,52 1218 + 94,46,69,31,66,84,86,58,98,16,24 1219 + 55,47,95,49,76,51,19,71,84,58,44 1220 + 12,46,69,16,92,65,31,45,98,79,74,86,22,48,18,37,34,26,47 1221 + 52,11,77,58,27,35,39,24,44,19,46,23,54,53,71,76,12 1222 + 71,66,94,15,84,46,61,52,11,19,53,23,51,69,27,54,58,12,39,44,24 1223 + 79,86,22,18,37,47,83,14,91,76,51 1224 + 79,48,47,95,11 1225 + 12,24,46,34,66,74,86,98,69,37,45,92,26,55,47,18,65,22,16 1226 + 71,65,54,15,39,69,98,23,46,58,94,24,45 1227 + 79,74,86,83,14 1228 + 35,19,84,69,27 1229 + 54,46,66,31,98,48,18,37,34 1230 + 18,65,34,14,55,66,24 1231 + 94,46,27,65,98,22,26 1232 + 66,69,45,46,79,23,86,92,58,94,84,53,24,31,44,54,16,12,65,27,98 1233 + 27,66,92,65,31,98,86,18,26,55,95,83,85 1234 + 86,34,79,83,66,55,22,16,32 1235 + 85,49,32,76,11,77,52,39,84,53,25,54,94,12,46 1236 + 74,47,31,22,92,18,79,37,48,14,16,85,98,83,34,45,65,95,66,27,86 1237 + 86,22,18,37,34,26,47,95,83,85,49,32,11,35,61,77,39 1238 + 79,55,95,49,91 1239 + 54,94,23,12,46,69,24,27,15,66,16,65,31,45,98,79,74,86,22,48,18,37,34 1240 + 27,53,58,92,69,79,94 1241 + 83,14,85,49,32,91,76,11,35,61,51,77,52,39,19,71,84,53,58,44,54,94,23 1242 + 23,12,46,69,24,27,15,66,16,92,65,31,98,79,74,86,22,48,18,37,34,26,55 1243 + 53,54,19,85,46,91,84,71,44,52,23,51,77,76,39,32,25,94,49,11,61 1244 + 32,35,55,22,74 1245 + 35,61,51,77,39,19,71,84,53,58,25,44,54,94,23,12,46,69,24,27,15,66,16 1246 + 95,74,11,49,85,83,45,34,32,61,37,35,14,55,18,79,26,22,98,86,91,47,48 1247 + 66,31,45,98,22,48,47,95,83,14,85 1248 + 61,51,77,52,39,19,71,84,53,58,25,54,94,23,12,46,69,27,15,16,92 1249 + 85,49,91,35,61,77,52,39,19,71,84,53,58,25,94,12,46 1250 + 47,26,79,65,34,37,74,83,98,22,45,55,18,16,66,69,15,86,95 1251 + 61,51,46,23,12,25,85,58,52,39,54,19,76,91,94,32,35 1252 + 48,37,95,85,32,91,76,51,71 1253 + 84,58,25,44,54,94,23,12,46,69,24,27,15,66,16,92,65,31,98,79,86 1254 + 77,54,14,35,49,84,76,51,11,44,94,95,52,71,19 1255 + 69,24,27,15,66,16,92,65,31,45,98,79,74,22,48,18,37,34,26,55,47,95,83 1256 + 61,71,53,44,46,24,66 1257 + 66,16,45,18,55,47,83,85,32 1258 + 69,24,27,66,98,79,86,22,48,18,37,34,26,55,47,95,83 1259 + 85,19,71,84,44,11,53,47,77,49,76,54,14,91,25 1260 + 11,83,61,77,51,35,58,94,95 1261 + 49,32,91,76,11,35,61,51,77,52,39,19,84,58,25,44,94,23,12,46,69 1262 + 25,44,54,94,23,12,24,27,15,66,16,92,65,31,79,74,86,22,18 1263 + 71,49,48,95,76,83,34,47,37 1264 + 14,49,32,91,61,77,52,19,84,58,44 1265 + 45,44,79,53,16,23,15,58,92,31,66,22,98,74,25,24,46,69,65,86,54,27,94 1266 + 11,61,52,53,58,94,66 1267 + 77,84,54,69,71,76,24,23,94,11,44,27,91,12,61,53,35,19,39,46,25 1268 + 92,65,31,45,74,86,48,18,37,34,26,55,47,95,83,14,85,91,76 1269 + 46,24,15,66,16,92,98,79,86,18,34,26,55 1270 + 11,35,61,51,77,52,39,19,71,53,58,25,44,54,94,23,12,69,24,15,66 1271 + 49,76,39,53,58 1272 + 71,84,53,58,25,44,54,94,23,12,69,24,27,15,66,16,92,65,31,45,98,79,74 1273 + 14,25,47,32,54,19,85,95,58 1274 + 53,12,25,19,15,54,52,31,44,39,69 1275 + 32,91,76,35,61,51,77,52,39,19,84,58,25,44,54,94,23,12,46,69,24 1276 + 55,83,91,49,86,22,76,37,32,14,39,47,34 1277 + 94,23,12,46,69,24,27,66,16,92,65,31,45,98,79,74,86,22,48,18,37,34,26 1278 + 55,83,49,32,35,39,19 1279 + 19,16,92,46,31,69,44,52,39,12,71,45,53,15,84,66,58 1280 + 71,84,35,53,58,11,91,61,51,83,25,14,47,77,32,76,44,55,95,52,19,49,39 1281 + 24,27,65,31,45,98,22,48,18,34,26,55,47,95,14 1282 + 46,23,58,31,98,12,92,24,45,54,71,94,19,16,53,25,39,44,69 1283 + 92,65,98,18,47,83,14,85,76 1284 + 26,32,34,83,49,91,52,85,47,11,51,76,74,35,48 1285 + 65,45,98,79,74,22,48,18,55,47,95,83,14,85,49,32,91,76,11 1286 + 47,39,26,22,49,34,76 1287 + 77,52,84,54,23,46,27,16,31 1288 + 15,66,16,92,65,31,98,74,86,48,18,37,34,55,47 1289 + 92,55,48,18,27,45,65,24,66,83,69 1290 + 22,18,37,95,85,49,32,35,61,77,19 1291 + 49,91,77,71,58,25,54,94,69 1292 + 39,51,85,77,49,19,61,18,22,37,14,34,11 1293 + 47,85,32,91,76,52,39,19,71,84,53,44,54 1294 + 76,35,61,52,39,71,53,58,25,94,12,46,24,27,15 1295 + 61,51,84,25,46,35,76,32,52,12,23,69,19,94,58,11,39,53,24,54,77,44,91 1296 + 31,45,66,49,79,95,26,98,65,48,14,55,22,74,92 1297 + 92,46,48,26,66 1298 + 25,44,94,12,65,31,79,22,18 1299 + 45,98,79,55,14,34,26,83,74,15,86,92,85,49,18,66,65,16,22 1300 + 25,32,53,58,94,23,19,54,71,11,39,77,52,84,69,76,49 1301 + 52,39,84,53,25,44,12,24,15,66,16,92,65,31,45 1302 + 52,39,19,58,44,54,94,23,12,69,24,15,66,16,92,31,45 1303 + 95,66,47,26,18,83,32,45,85,98,86,37,55 1304 + 31,45,86,48,37,26,95,83,14,85,32,76,35 1305 + 94,24,92,58,19,54,69,16,84,53,27,51,77,12,15,61,39,25,52,23,71,66,44 1306 + 44,54,94,23,12,46,69,24,66,92,31,98,79 1307 + 66,16,92,65,45,98,79,74,86,22,48,18,37,26,55,47,95,83,14,49,32 1308 + 98,18,47,14,85,49,51 1309 + 55,85,91,11,84 1310 + 32,91,11,35,51,77,52,39,19,84,58,54,94,23,69 1311 + 83,84,11,26,77,34,14,85,71,52,18 1312 + 32,49,91,76,83,94,71,19,23,61,58 1313 + 44,69,16,98,65,58,12,84,94,25,79,27,31,54,46,24,86,66,74,45,92 1314 + 65,94,15,12,45,74,23,58,16,84,86,31,69,24,98,92,66 1315 + 61,51,77,52,19,71,84,53,25,44,94,23,12,46,69,24,27,15,66 1316 + 79,34,55,61,98,45,47,74,83,49,76,11,32 1317 + 86,22,48,18,37,83,85,32,91,76,11,35,61,51,77,52,39 1318 + 65,45,86,55,95,85,32,76,11 1319 + 15,66,16,92,31,45,98,79,74,86,22,48,18,37,34,26,95,83,14,85,49 1320 + 54,58,53,16,71,15,98,69,94,65,46,31,66,25,92,84,44,24,19,23,27 1321 + 26,61,37,14,71,51,19,76,91 1322 + 15,92,79,74,86,22,48,26,55,83,14,85,49 1323 + 26,74,83,76,49,31,47,35,37,95,86 1324 + 71,83,95,34,19,39,14,51,85,49,52,61,32,48,55 1325 + 69,15,66,92,79,74,37,34,55,47,95 1326 + 47,51,19,39,35,85,84,91,26,71,49,55,25,11,52 1327 + 26,14,76,32,37,95,86,35,55,79,83,11,91,47,34,22,31,98,85,45,48 1328 + 35,53,19,32,91,46,12,25,11,61,54,51,71 1329 + 98,79,74,86,22,18,37,34,26,55,47,95,83,85,49,32,91,11,51 1330 + 79,22,34,47,32,11,77 1331 + 31,69,45,95,83,16,55,65,98,22,26,37,74 1332 + 74,86,22,37,34,26,55,95,85,32,91,76,11,77,52 1333 + 39,19,71,53,25,44,54,46,69,24,27,66,16,65,31,45,98 1334 + 47,51,11,77,58,85,52 1335 + 45,48,37,83,49,32,91 1336 + 85,26,77,95,19,18,51,34,55,52,91,32,11,84,39 1337 + 79,45,18,94,48,74,16,12,92,98,37,26,27,23,69,46,34,86,31 1338 + 48,34,14,45,86,98,18,85,47,22,55,76,79,32,31,91,35,83,37 1339 + 76,77,52,71,44 1340 + 26,55,47,95,83,14,85,49,32,91,76,11,35,61,51,77,52,39,19,71,84,58,25 1341 + 45,98,79,86,48,18,34,26,47,95,85,91,61 1342 + 24,44,19,71,15,12,27,51,52,92,84 1343 + 69,24,27,65,98,22,48,18,55,47,83 1344 + 61,34,11,74,91,51,48,55,52,86,37,85,14,49,95,76,22 1345 + 71,46,27,15,66,92,79 1346 + 58,46,16,31,27,54,53,66,12,23,71,52,84,25,44,94,77 1347 + 61,77,39,19,71,84,25,44,54,94,24,27,15,66,16 1348 + 51,52,15,12,24,66,54,35,46,16,69,84,53 1349 + 74,86,22,48,18,34,26,55,47,95,83,14,85,49,32,91,76,11,35,61,51,77,52 1350 + 34,26,47,14,32,76,35,39,71 1351 + 37,26,47,83,85,49,76,11,35,61,51,77,53 1352 + 66,24,98,86,15 1353 + 91,76,35,61,51,52,39,19,53,58,54,94,23,46,27 1354 + 16,92,45,74,86,22,18,37,34,26,55,85,49,32,91 1355 + 12,74,58,79,23,31,22,25,86 1356 + 98,79,22,48,18,14,85,49,32,76,11,61,51 1357 + 34,26,55,47,95,83,14,85,49,32,91,76,11,35,61,51,52,39,19,71,84,53,58 1358 + 51,52,39,58,25,44,54,12,46,69,24,66,16,92,65 1359 + 24,44,58,12,46,92,22,79,86,74,54,65,23 1360 + 86,22,18,26,95,32,91,76,51 1361 + 71,54,69,24,15,66,16,31,45,98,74 1362 + 15,92,65,31,45,98,79,74,86,22,48,18,34,26,55,95,14,85,49 1363 + 53,44,54,94,23,12,46,69,24,27,15,66,92,98,74,86,22 1364 + 16,92,65,31,45,98,22,18,37,34,55,95,83,14,32 1365 + 34,47,95,83,14,85,49,91,76,11,35,51,77,52,19,71,84,53,58 1366 + 55,45,76,37,35,83,31
+166
2024/day_5/src/main.rs
···
··· 1 + #![feature(test)] 2 + 3 + extern crate test; 4 + 5 + use std::fs; 6 + 7 + #[derive(Debug)] 8 + enum Input { 9 + Rule(String, String), 10 + Update(String), 11 + None 12 + } 13 + 14 + impl Input { 15 + fn is_rule(&self) -> bool { 16 + match *self { 17 + Input::Rule(_, _) => true, 18 + _ => false 19 + } 20 + } 21 + 22 + fn is_none(&self) -> bool { 23 + match *self { 24 + Input::None => true, 25 + _ => false 26 + } 27 + } 28 + } 29 + 30 + fn part_1(input: &Vec<Input>) { 31 + let rules = input.iter().filter(|i| i.is_rule()).collect::<Vec<&Input>>(); 32 + 33 + let mut sum: usize = 0; 34 + 35 + for item in input { 36 + match item { 37 + Input::Update(update) => { 38 + let mut c = true; 39 + for rule in rules.clone() { 40 + match rule { 41 + Input::Rule(before, after) => { 42 + if update.find(before).is_some() && update.find(after).is_some() { 43 + let i_b = update.find(before).unwrap(); 44 + let i_a = update.find(after).unwrap(); 45 + 46 + if i_b > i_a { 47 + c = false; 48 + } 49 + } 50 + }, 51 + _ => () 52 + } 53 + }; 54 + 55 + if c { 56 + let sp = update.split(',').collect::<Vec<&str>>(); 57 + sum += sp[sp.len() / 2].parse::<usize>().unwrap(); 58 + } 59 + }, 60 + _ => () 61 + } 62 + } 63 + 64 + println!("Part 1: {sum}") 65 + 66 + } 67 + 68 + fn part_2(input: &Vec<Input>) { 69 + let rules = input.iter().filter(|i| i.is_rule()).collect::<Vec<&Input>>(); 70 + 71 + let mut sum: usize = 0; 72 + 73 + for item in input { 74 + match item { 75 + Input::Update(update) => { 76 + let mut updated = update.split(',').collect::<Vec<&str>>(); 77 + let mut c = true; 78 + for _ in 0..2 { 79 + for rule in rules.clone() { 80 + match rule { 81 + Input::Rule(before, after) => { 82 + if update.find(before).is_some() && update.find(after).is_some() { 83 + let b_idx = updated.iter().position(|i| *i == before).unwrap_or(usize::MAX); 84 + let a_idx = updated.iter().position(|i| *i == after).unwrap_or(usize::MAX); 85 + 86 + if b_idx > a_idx { 87 + updated = [&updated[0..a_idx], [updated[b_idx]].as_slice(), &updated[a_idx..b_idx], &updated[b_idx+1..]].concat().to_vec(); 88 + c = false; 89 + } 90 + } 91 + }, 92 + _ => () 93 + } 94 + }; 95 + } 96 + 97 + if !c { 98 + sum += updated[updated.len() / 2].parse::<usize>().unwrap(); 99 + } 100 + }, 101 + _ => () 102 + } 103 + } 104 + 105 + println!("Part 2: {sum}") 106 + } 107 + 108 + fn parse_input(input: &str) -> Option<Vec<Input>> { 109 + Some(input.lines().map(|line| { 110 + if line.find('|').is_some() { 111 + let mut s = line.split('|'); 112 + Input::Rule(s.next().unwrap().to_string(), s.next().unwrap().to_string()) 113 + } else { 114 + if !line.is_empty() { 115 + Input::Update(line.to_string()) 116 + } else { 117 + Input::None 118 + } 119 + } 120 + }).filter(|i| !i.is_none()).collect()) 121 + } 122 + 123 + fn main() { 124 + let file = fs::read_to_string("./input.txt").expect("Couldn't read file"); 125 + 126 + let input = parse_input(file.as_str()).unwrap(); 127 + part_1(&input); 128 + part_2(&input); 129 + } 130 + 131 + #[test] 132 + fn test_main() { 133 + let file = fs::read_to_string("./text_input.txt").expect("Couldn't read file"); 134 + 135 + let input = parse_input(file.as_str()).unwrap(); 136 + part_1(&input); 137 + part_2(&input); 138 + } 139 + 140 + #[bench] 141 + fn full(b: &mut test::Bencher) { 142 + b.iter(|| main()); 143 + } 144 + 145 + #[bench] 146 + fn input_only(b: &mut test::Bencher) { 147 + let input = fs::read_to_string("./input.txt").expect("Couldn't read file"); 148 + 149 + b.iter(|| parse_input(input.as_str())); 150 + } 151 + 152 + #[bench] 153 + fn part_one(b: &mut test::Bencher) { 154 + let file = fs::read_to_string("./input.txt").expect("Couldn't read file"); 155 + 156 + let input = parse_input(file.as_str()).unwrap(); 157 + b.iter(|| part_1(&input)); 158 + } 159 + 160 + #[bench] 161 + fn part_two(b: &mut test::Bencher) { 162 + let file = fs::read_to_string("./input.txt").expect("Couldn't read file"); 163 + 164 + let input = parse_input(file.as_str()).unwrap(); 165 + b.iter(|| part_2(&input)); 166 + }
+28
2024/day_5/text_input.txt
···
··· 1 + 47|53 2 + 97|13 3 + 97|61 4 + 97|47 5 + 75|29 6 + 61|13 7 + 75|53 8 + 29|13 9 + 97|29 10 + 53|29 11 + 61|53 12 + 97|53 13 + 61|29 14 + 47|13 15 + 75|47 16 + 97|75 17 + 47|61 18 + 75|61 19 + 47|29 20 + 75|13 21 + 53|13 22 + 23 + 75,47,61,53,29 24 + 97,61,53,29,13 25 + 75,29,13 26 + 75,97,47,61,53 27 + 61,13,29 28 + 97,13,75,29,47
+1
2024/day_6/.gitignore
···
··· 1 + /target
+7
2024/day_6/Cargo.lock
···
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "day_6" 7 + version = "0.1.0"
+6
2024/day_6/Cargo.toml
···
··· 1 + [package] 2 + name = "day_6" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [dependencies]
+130
2024/day_6/input.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 + ...#............................#.......#...........#.........#........#.....#...........#...................................#.... 52 + .....................#...................#................................#...............................#......#.........#..##.. 53 + .............#........................................................................................#........................##. 54 + .....#.......#.......#............................................................................................................ 55 + ............................................#................................................................#..............#..... 56 + ....#..#......................................................#...................................................#............... 57 + .................................#...##..................#.................................................#....#................. 58 + ........#...................................#...#..........................................................#...................... 59 + ........................#........##...........#.......#........#...................................#.............................. 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 + ........................#...............................#.#.............#................................#..................#.....
+166
2024/day_6/src/main.rs
···
··· 1 + #![feature(test)] 2 + 3 + extern crate test; 4 + 5 + use std::fs; 6 + 7 + fn walk_guard(mut grid: Vec<Vec<char>>) -> (Vec<Vec<char>>, bool) { 8 + println!("walking"); 9 + let mut x: i32 = -1; 10 + let y = grid.iter().position(|line| { 11 + let t = line.iter().position(|c| *c == '<' || *c == '>' || *c == 'v' || *c == '^'); 12 + if t.is_some() { 13 + x = t.unwrap().try_into().unwrap(); 14 + true 15 + } else { 16 + false 17 + } 18 + }); 19 + 20 + if y.is_none() { 21 + return (grid, true) 22 + } 23 + 24 + let real_x: usize = x.try_into().unwrap(); 25 + let real_y: usize = y.unwrap(); 26 + 27 + match grid[real_y][real_x] { 28 + '^' => { 29 + if real_y.checked_sub(1).is_some() { 30 + let ahead = grid[real_y-1][real_x]; 31 + if ahead == '.' { 32 + grid[real_y-1][real_x] = '^'; 33 + grid[real_y][real_x] = 'X'; 34 + } else { 35 + grid[real_y][real_x] = '>'; 36 + } 37 + } else { 38 + grid[real_y][real_x] = 'X'; 39 + } 40 + }, 41 + '>' => { 42 + if (real_x + 1) < grid[real_y].len() { 43 + let ahead = grid[real_y][real_x+1]; 44 + if ahead == '.' { 45 + grid[real_y][real_x+1] = '>'; 46 + grid[real_y][real_x] = 'X'; 47 + } else { 48 + grid[real_y][real_x] = 'v'; 49 + } 50 + } else { 51 + grid[real_y][real_x] = 'X'; 52 + } 53 + }, 54 + 'v' => { 55 + if (real_y + 1) < grid.len() { 56 + let ahead = grid[real_y+1][real_x]; 57 + if ahead == '.' { 58 + grid[real_y+1][real_x] = 'v'; 59 + grid[real_y][real_x] = 'X'; 60 + } else { 61 + grid[real_y][real_x] = '<'; 62 + } 63 + } else { 64 + grid[real_y][real_x] = 'X'; 65 + } 66 + }, 67 + '<' => { 68 + if real_x.checked_sub(1).is_some() { 69 + let ahead = grid[real_y][real_x-1]; 70 + if ahead == '.' { 71 + grid[real_y][real_x-1] = '<'; 72 + grid[real_y][real_x] = 'X'; 73 + } else { 74 + grid[real_y][real_x] = '^'; 75 + } 76 + } else { 77 + grid[real_y][real_x] = 'X'; 78 + } 79 + }, 80 + _ => {} 81 + }; 82 + (grid, false) 83 + } 84 + 85 + fn part_1(input: &Vec<Vec<char>>) { 86 + let mut grid = input.to_vec(); 87 + let mut c = false; 88 + 89 + while !c { 90 + (grid, c) = walk_guard(grid); 91 + for line in &grid { 92 + println!("{:?}", line); 93 + } 94 + } 95 + 96 + let mut sum: usize = 0; 97 + for line in grid { 98 + for c in line { 99 + if c == 'X' { 100 + sum += 1; 101 + } 102 + } 103 + } 104 + 105 + println!("Part 1: {sum}") 106 + } 107 + 108 + fn part_2(input: &Vec<Vec<char>>) { 109 + 110 + } 111 + 112 + fn parse_input(input: &str) -> Option<Vec<Vec<char>>> { 113 + Some( 114 + input.lines().map( 115 + |line| 116 + line.chars().collect() 117 + ).collect() 118 + ) 119 + } 120 + 121 + fn main() { 122 + let file = fs::read_to_string("./input.txt").expect("Couldn't read file"); 123 + 124 + let input = parse_input(file.as_str()).unwrap(); 125 + part_1(&input); 126 + part_2(&input); 127 + } 128 + 129 + #[test] 130 + fn test_main() { 131 + let file = fs::read_to_string("./test_input.txt").expect("Couldn't read file"); 132 + 133 + let input = parse_input(file.as_str()).unwrap(); 134 + 135 + println!("{:?}", input); 136 + part_1(&input); 137 + part_2(&input); 138 + } 139 + 140 + #[bench] 141 + fn full(b: &mut test::Bencher) { 142 + b.iter(|| main()); 143 + } 144 + 145 + #[bench] 146 + fn input_only(b: &mut test::Bencher) { 147 + let input = fs::read_to_string("./input.txt").expect("Couldn't read file"); 148 + 149 + b.iter(|| parse_input(input.as_str())); 150 + } 151 + 152 + #[bench] 153 + fn part_one(b: &mut test::Bencher) { 154 + let file = fs::read_to_string("./input.txt").expect("Couldn't read file"); 155 + 156 + let input = parse_input(file.as_str()).unwrap(); 157 + b.iter(|| part_1(&input)); 158 + } 159 + 160 + #[bench] 161 + fn part_two(b: &mut test::Bencher) { 162 + let file = fs::read_to_string("./input.txt").expect("Couldn't read file"); 163 + 164 + let input = parse_input(file.as_str()).unwrap(); 165 + b.iter(|| part_2(&input)); 166 + }
+10
2024/day_6/test_input.txt
···
··· 1 + ....#..... 2 + .........# 3 + .......... 4 + ..#....... 5 + .......#.. 6 + .......... 7 + .#..^..... 8 + ........#. 9 + #......... 10 + ......#...
+45
2025/nilla.nix
···
··· 1 + let 2 + pins = import ./npins; 3 + 4 + nilla = import pins.nilla; 5 + in 6 + nilla.create ({ config }: { 7 + config = { 8 + inputs = { 9 + fenix = { 10 + src = pins.fenix; 11 + }; 12 + 13 + nixpkgs = { 14 + src = pins.nixpkgs; 15 + 16 + settings = { 17 + overlays = [ 18 + config.inputs.fenix.result.overlays.default 19 + ]; 20 + }; 21 + }; 22 + }; 23 + 24 + shells.default = config.shells.rust; 25 + shells.rust = { 26 + systems = [ "x86_64-linux" ]; 27 + 28 + shell = { mkShell, fenix, bacon, pkg-config, ... }: 29 + mkShell { 30 + packages = [ 31 + (fenix.complete.withComponents [ 32 + "cargo" 33 + "clippy" 34 + "rust-src" 35 + "rustc" 36 + "rustfmt" 37 + "rust-analyzer" 38 + ]) 39 + bacon 40 + pkg-config 41 + ]; 42 + }; 43 + }; 44 + }; 45 + })
+247
2025/npins/default.nix
···
··· 1 + /* 2 + This file is provided under the MIT licence: 3 + 4 + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 + 6 + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 + 8 + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 + */ 10 + # Generated by npins. Do not modify; will be overwritten regularly 11 + let 12 + # Backwards-compatibly make something that previously didn't take any arguments take some 13 + # The function must return an attrset, and will unfortunately be eagerly evaluated 14 + # Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments 15 + mkFunctor = 16 + fn: 17 + let 18 + e = builtins.tryEval (fn { }); 19 + in 20 + (if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; }; 21 + 22 + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 23 + range = 24 + first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); 25 + 26 + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 27 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); 28 + 29 + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 30 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); 31 + concatStrings = builtins.concatStringsSep ""; 32 + 33 + # If the environment variable NPINS_OVERRIDE_${name} is set, then use 34 + # the path directly as opposed to the fetched source. 35 + # (Taken from Niv for compatibility) 36 + mayOverride = 37 + name: path: 38 + let 39 + envVarName = "NPINS_OVERRIDE_${saneName}"; 40 + saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; 41 + ersatz = builtins.getEnv envVarName; 42 + in 43 + if ersatz == "" then 44 + path 45 + else 46 + # this turns the string into an actual Nix path (for both absolute and 47 + # relative paths) 48 + builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" ( 49 + if builtins.substring 0 1 ersatz == "/" then 50 + /. + ersatz 51 + else 52 + /. + builtins.getEnv "PWD" + "/${ersatz}" 53 + ); 54 + 55 + mkSource = 56 + name: spec: 57 + { 58 + pkgs ? null, 59 + }: 60 + assert spec ? type; 61 + let 62 + # Unify across builtin and pkgs fetchers. 63 + # `fetchGit` requires a wrapper because of slight API differences. 64 + fetchers = 65 + if pkgs == null then 66 + { 67 + inherit (builtins) fetchTarball fetchurl; 68 + # For some fucking reason, fetchGit has a different signature than the other builtin fetchers … 69 + fetchGit = args: (builtins.fetchGit args).outPath; 70 + } 71 + else 72 + { 73 + fetchTarball = 74 + { 75 + url, 76 + sha256, 77 + }: 78 + pkgs.fetchzip { 79 + inherit url sha256; 80 + extension = "tar"; 81 + }; 82 + inherit (pkgs) fetchurl; 83 + fetchGit = 84 + { 85 + url, 86 + submodules, 87 + rev, 88 + name, 89 + narHash, 90 + }: 91 + pkgs.fetchgit { 92 + inherit url rev name; 93 + fetchSubmodules = submodules; 94 + hash = narHash; 95 + }; 96 + }; 97 + 98 + # Dispatch to the correct code path based on the type 99 + path = 100 + if spec.type == "Git" then 101 + mkGitSource fetchers spec 102 + else if spec.type == "GitRelease" then 103 + mkGitSource fetchers spec 104 + else if spec.type == "PyPi" then 105 + mkPyPiSource fetchers spec 106 + else if spec.type == "Channel" then 107 + mkChannelSource fetchers spec 108 + else if spec.type == "Tarball" then 109 + mkTarballSource fetchers spec 110 + else if spec.type == "Container" then 111 + mkContainerSource pkgs spec 112 + else 113 + builtins.throw "Unknown source type ${spec.type}"; 114 + in 115 + spec // { outPath = mayOverride name path; }; 116 + 117 + mkGitSource = 118 + { 119 + fetchTarball, 120 + fetchGit, 121 + ... 122 + }: 123 + { 124 + repository, 125 + revision, 126 + url ? null, 127 + submodules, 128 + hash, 129 + ... 130 + }: 131 + assert repository ? type; 132 + # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository 133 + # In the latter case, there we will always be an url to the tarball 134 + if url != null && !submodules then 135 + fetchTarball { 136 + inherit url; 137 + sha256 = hash; 138 + } 139 + else 140 + let 141 + url = 142 + if repository.type == "Git" then 143 + repository.url 144 + else if repository.type == "GitHub" then 145 + "https://github.com/${repository.owner}/${repository.repo}.git" 146 + else if repository.type == "GitLab" then 147 + "${repository.server}/${repository.repo_path}.git" 148 + else 149 + throw "Unrecognized repository type ${repository.type}"; 150 + urlToName = 151 + url: rev: 152 + let 153 + matched = builtins.match "^.*/([^/]*)(\\.git)?$" url; 154 + 155 + short = builtins.substring 0 7 rev; 156 + 157 + appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; 158 + in 159 + "${if matched == null then "source" else builtins.head matched}${appendShort}"; 160 + name = urlToName url revision; 161 + in 162 + fetchGit { 163 + rev = revision; 164 + narHash = hash; 165 + 166 + inherit name submodules url; 167 + }; 168 + 169 + mkPyPiSource = 170 + { fetchurl, ... }: 171 + { 172 + url, 173 + hash, 174 + ... 175 + }: 176 + fetchurl { 177 + inherit url; 178 + sha256 = hash; 179 + }; 180 + 181 + mkChannelSource = 182 + { fetchTarball, ... }: 183 + { 184 + url, 185 + hash, 186 + ... 187 + }: 188 + fetchTarball { 189 + inherit url; 190 + sha256 = hash; 191 + }; 192 + 193 + mkTarballSource = 194 + { fetchTarball, ... }: 195 + { 196 + url, 197 + locked_url ? url, 198 + hash, 199 + ... 200 + }: 201 + fetchTarball { 202 + url = locked_url; 203 + sha256 = hash; 204 + }; 205 + 206 + mkContainerSource = 207 + pkgs: 208 + { 209 + image_name, 210 + image_tag, 211 + image_digest, 212 + ... 213 + }: 214 + if pkgs == null then 215 + builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers" 216 + else 217 + pkgs.dockerTools.pullImage { 218 + imageName = image_name; 219 + imageDigest = image_digest; 220 + finalImageTag = image_tag; 221 + }; 222 + in 223 + mkFunctor ( 224 + { 225 + input ? ./sources.json, 226 + }: 227 + let 228 + data = 229 + if builtins.isPath input then 230 + # while `readFile` will throw an error anyways if the path doesn't exist, 231 + # we still need to check beforehand because *our* error can be caught but not the one from the builtin 232 + # *piegames sighs* 233 + if builtins.pathExists input then 234 + builtins.fromJSON (builtins.readFile input) 235 + else 236 + throw "Input path ${toString input} does not exist" 237 + else if builtins.isAttrs input then 238 + input 239 + else 240 + throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset"; 241 + version = data.version; 242 + in 243 + if version == 7 then 244 + builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins 245 + else 246 + throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" 247 + )
+44
2025/npins/sources.json
···
··· 1 + { 2 + "pins": { 3 + "fenix": { 4 + "type": "Git", 5 + "repository": { 6 + "type": "GitHub", 7 + "owner": "nix-community", 8 + "repo": "fenix" 9 + }, 10 + "branch": "monthly", 11 + "submodules": false, 12 + "revision": "df3c2e78ec13418f85c1f26e77a50f865ec57d38", 13 + "url": "https://github.com/nix-community/fenix/archive/df3c2e78ec13418f85c1f26e77a50f865ec57d38.tar.gz", 14 + "hash": "sha256-+oo9W5rz03TjfpNqDSLEQwgKiuBbjrHdORyTHli2RuM=" 15 + }, 16 + "nilla": { 17 + "type": "Git", 18 + "repository": { 19 + "type": "GitHub", 20 + "owner": "nilla-nix", 21 + "repo": "nilla" 22 + }, 23 + "branch": "main", 24 + "submodules": false, 25 + "revision": "6d814dafa6f397ac2087333e5515c617faccba6f", 26 + "url": "https://github.com/nilla-nix/nilla/archive/6d814dafa6f397ac2087333e5515c617faccba6f.tar.gz", 27 + "hash": "sha256-A4zg3po1tyfh1if+LIllKtUGoWLFSwJSztvH2MG22qU=" 28 + }, 29 + "nixpkgs": { 30 + "type": "Git", 31 + "repository": { 32 + "type": "GitHub", 33 + "owner": "nixos", 34 + "repo": "nixpkgs" 35 + }, 36 + "branch": "nixos-unstable", 37 + "submodules": false, 38 + "revision": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c", 39 + "url": "https://github.com/nixos/nixpkgs/archive/2d293cbfa5a793b4c50d17c05ef9e385b90edf6c.tar.gz", 40 + "hash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=" 41 + } 42 + }, 43 + "version": 7 44 + }
day_1/.gitignore 2024/day_1/.gitignore
day_1/Cargo.lock 2024/day_1/Cargo.lock
day_1/Cargo.toml 2024/day_1/Cargo.toml
day_1/input.txt 2024/day_1/input.txt
day_1/src/main.rs 2024/day_1/src/main.rs
day_3/.gitignore 2024/day_3/.gitignore
day_3/Cargo.lock 2024/day_3/Cargo.lock
day_3/Cargo.toml 2024/day_3/Cargo.toml
day_3/input.txt 2024/day_3/input.txt
day_3/src/main.rs 2024/day_3/src/main.rs
day_4/.gitignore 2024/day_4/.gitignore
day_4/Cargo.lock 2024/day_4/Cargo.lock
day_4/Cargo.toml 2024/day_4/Cargo.toml
day_4/input.txt 2024/day_4/input.txt
day_4/src/main.rs 2024/day_4/src/main.rs
flake.lock 2024/flake.lock
flake.nix 2024/flake.nix