no idea, too old

This commit is contained in:
didier committed 2025-12-25 22:12:33 -05:00
1 parent 1f1243d4df
commit 20cfb3b829
2 files changed
+65

No files matched your search

+1
View File
@@ -344,3 +344,4 @@
@@.@@@@.@.@....@@@.@@@@.@..@@@@@@@.@@@@@@@....@@...@@@@@@...@@@.@@.@@@@.@@@@@@@@@@@.@.@@@@.@@@@@@@@@.@.@@@.@@@.@....@@.@.@..@@@@@@@@@.@.@@@")
(def question-5 "213743501161200-213743501161200\n221359789392478-222960432116258\n553905700373062-561794342755365\n388351876706917-388578461376678\n263685821321516-270464997549766\n384957836075964-385057316204755\n86932924454422-88726115602910\n64713316693400-65189382496202\n68179610157787-68454649435444\n143154545648377-145980913110898\n390250299542523-390843409397977\n392162789636707-394167531415509\n467795551515047-469145316638624\n73412860995201-78319783604609\n174577844186025-180222947242739\n34889394659118-37852045203256\n506719917120116-506719917120116\n64999889315593-65189382496202\n62511033442122-62882231057991\n169629548448978-169629548448978\n195991726717561-200347594718591\n80800364897743-82410540424990\n157966143122749-158625789879543\n414893276002289-420734433214551\n468854880571347-470178150823398\n293047529057561-293047529057561\n526293793744803-526800435871324\n154610263545675-155018832807006\n85676500485010-87494001551296\n404052468013478-411059540873663\n529805857574316-530354749652142\n282126028703430-287392631951184\n536612716581558-542001885354658\n224389325429033-225956850054114\n389327354686290-389941649666180\n226458176996215-227998751964573\n466681105242973-468035461798180\n132182495488136-136864510598769\n158625789879543-158943957000511\n222498723695457-223722626496659\n24396986945805-29009989981082\n387070084421471-387699738663307\n463761550427134-465101663712718\n244484473250009-249824444617715\n235682381324440-239428507922589\n356542431952285-357218504633271\n528809160802420-529163494010802\n203275761047276-207893046967514\n65189382496202-65740304733466\n84564501332038-86342507935742\n528809160802420-529739126171581\n430824287436458-430824287436458\n270464997549767-270464997549767\n73412860995201-73412860995201\n203275761047276-207893046967514\n465765531974637-467339424840641\n88308683283200-90314897336701\n506719917120116-509378158464998\n154610263545675-155018832807006\n436351058276905-441549428537929\n390250299542523-390501802123222\n464766089052130-465995972804612\n153723748856595-154247928476913\n524957458539564-525444885761624\n193355047594087-195991726717559\n68057027039766-68454649435444\n114292754379846-114292754379846\n476176387291714-479287347759176\n68727093315072-69054421292865\n374010991378735-378095042001312\n396702787271742-398555495412596\n92985559435331-99083983384255\n524317721420090-524645436296520\n470916081729043-472406223184007\n307193970359996-309957481846034\n83208072709351-85336482970086\n61908006035935-62767933777530\n12440214380075-19413829756369\n158268094987535-158625789879543\n323855611951188-327225842492665\n232121351950005-235682381324439\n104580961113313-109652180451852\n155719620755384-156378640409574\n225242642256272-226838958939168\n126345620041269-129628037616258\n272979306019768-272979306019768\n229571449179868-230955409924473\n15572428843108-19413829756369\n486438625661094-489174884685392\n399063478386186-400626043814074\n61434917885505-61908006035935\n442807002499434-447467590937981\n153470274802250-153891356149723\n548528649335253-552132613556960\n302406550101741-307193970359994\n284836416410676-290905691766532\n134736737710827-138821293926430\n524645436296520-525444885761624\n347299925469182-350731461622425\n333121507005172-333121507005172\n257633973479609-259311991697339\n418350619486212-420734433214551\n523873015780814-524032209716334\n424331863324814-430824287436457\n143154545648377-148152467497972\n156770859353106-157228370844559\n523401105399726-524032209716334\n3672218268426-9069958349825\n41190120499524-48710502110828\n171431709160547-176780839877720\n65740304733466-66283299959280\n3672218268426-9069958349825\n157444284967581-157743465985657\n99083983384256-99083983384256\n114292754379847-118122243442587\n32783805912506-34889394659117\n495774309849622-495774309849622\n385597213338484-386130309524989\n66422129062863-66711994098586\n390501802123222-390843409397977\n227420995218497-229137292369316\n518765954978807-520809013033287\n81872566000969-83813851796454\n272979306019768-280055074059068\n394469512488834-396279958092492\n469546011173175-471346897231698\n442807002499434-451270889383530\n184738598610317-187210601572675\n364359970290004-369109081626630\n327225842492665-327225842492665\n353087698181504-361406479744402\n293047529057561-299710639297794\n486438625661094-489174884685392\n472788183962691-480272823246663\n152000130191943-152486238796869\n386858817856261-387699738663307\n462503261552047-464039809812541\n183175626133351-189172211000972\n163807315460788-169629548448978\n393534536834350-394918686174827\n344389995827602-347299925469181\n159774306485562-160419960771595\n544514849402253-552132613556960\n65400483278322-66283299959280\n63641646788533-63945948546021\n228387323493940-230123402570745\n223334527687062-225118219054282\n398001413033472-399528430973758\n389120143291068-389327354686290\n251886663550811-259311991697339\n69054421292865-69216943568303\n109652180451852-109652180451852\n53011962076696-56344039055008\n40016Line truncated
(def question-6 "44 18 45 2119 29 9 8 525 2 8 59 9286 858 26 969 666 78 1 33 54 4862 9696 9717 49 538 9887 38 6 48 5 556 576 48 195 7 5 14 89 58 5 79 5453 26 66 52 898 2785 68 957 355 13 45 535 2 371 18 172 98 8 979 1 16 84 4468 15 3 98 53 75 7 89 6518 62 414 278 24 79 7662 4 7 6218 729 5184 33 878 92 89 38 336 747 39 828 41 91 252 234 967 521 512 41 47 33 812 3378 916 76 347 49 26 755 8 2 9832 1682 49 5286 78 1 4172 64 39 479 8 5995 857 37 97 6 392 5 4 53 636 525 82 94 69 95 272 969 46 8 9 431 38 69 134 196 1 664 443 36 2 4 95 159 571 926 5 857 63 62 65 2423 54 929 99 915 16 5 6 791 5 82 13 1 7 91 491 64 353 53 61 2 98 35 2 585 278 45 536 76 81 26 95 51 985 5 567 9 496 46 973 5 1 14 7 75 15 9785 523 98 9 4 87 61 59 5 75 47 5 6873 4 411 32 888 8 2321 29 98 8 61 611 24 63 647 394 174 93 62 51 149 398 875 68 62 57 43 11 52 312 97 82 4 6 2 41 65 35 83 42 633 19 286 199 18 44 7946 72 6799 442 558 3 9 48 97 986 519 7845 111 2314 914 494 9 62 383 22 464 42 92 468 99 78 194 21 64 665 72 1 68 1 76 67 5 339 42 428 97 1 48 88 45 381 66 654 291 882 78 11 2854 15 87 285 7 2 77 2 35 935 6 27 31 8466 467 7164 1378 8 4 24 663 7937 7 3 86 189 763 7 6 993 7 21 727 7 993 92 78 55 574 55 31 91 5933 24 186 82 63 48 193 68 5 326 82 36 25 3 9 788 179 5254 98 333 98 52 61 334 13 85 6294 336 9357 56 88 435 7286 991 849 3 49 922 936 95 21 99 62 472 7391 465 36 2 2116 72 14 4297 11 5 68 44 5 742 51 76 4 45 42 95 474 32 2 53 85 8989 42 42 34 54 12 739 695 228 82 9 6 241 6 64 141 699 99 3 524 25 8979 944 29 487 456 514 16 218 1322 2 797 3727 99 37 471 57 911 45 9 733 5 11 831 5 34 553 69 46 17 1 53 39 685 3 46 695 442 5 4 8 3 9717 78 19 7 417 26 4 28 814 96 8278 47 53 48 47 93 371 2 4 53 1573 974 2293 56 26 3 4 856 93 85 867 62 1 43 73 4 7 3 882 86 37 16 341 1 4 61 63 67 35 44 6 894 399 5 948 5 24 5 3 56 1523 13 463 43 362 51 737 84 21 21 9316 391 51 54 5 596 67 2 7 9 65 486 4 94 111 25 28 7 57 342 498 186 35 94 53 644 898 1782 56 142 27 4 592 995 88 515 163 32 261 83 7 5936 9 956 52 94 855 59 42 74 67 76 66 684 264 16 18 88 9215 42 6 126 72 58 32 54 43 556 42 982 44 785 4 53 915 26 936 6 3 9364 363 84 5144 2 1 185 12 899 89 879 438 9 5 9 57 1 6 35 1929 6572 36 12 26 34 6 8895 77 11 6 79 715 282 67 81 579 81 21 48 965 833 488 4 2844 863 89 9 729 42 64 37 86 22 58 2 1 69 9 99 37 33 447 34 2 74 64 7 1 6 53 71 1647 4 399 2 71 13 61 7448 266 3 67 39 1 6 9213 81 697 62 66 394 31 6 6 99 83 491 35 983 79 975 82 4 49 6 744 34 12 32 469 679 9 4 67 631 296 968 8 55 4 53 46 2 81 78 2 761 66 22 717 8 52 49 55 26 883 72 58 63 28 9 883 5513 55 128 45 86 8 72 233 599 2852 14 2 31 93 9 42 6 7 24 74 6 63 277 22 381 633 312 22 41 69 97 31 567 39 66 77 59 8 434 36 16 6331 8 67 6 69 486 498 742 591 44 958 323 8511 13 18 54 68 5 651 818 836 94 4 97 1763 62 33 1991 999 184 17 968 2 5 3 31 98 9626 79 4 9461 25 738 891 14 4 684 21 2213 85 578 72 45 5 7 545 3448 98 14 47 47 91 4 797 846 6 98 857 21 5 327 1 23 62 74 2526 127 446 536 733 441 369 922 78 129 574 89 379 667 885 53 4 3 2 51 96 82 734 772 19 6 748 779 27 73 53 52 19 98 75 28 9892 39 21 6 37 296 154 994 561 981 73 968 6 69 723 28 6374 69 95 6389 74 12 35 2 2426 237 4 31 7 29 9112 722 12 35 33 692 939 8 89 3666 628 22 233 17 8 17 1 11 83 9 68 2 369 895 53 4 67 4 245 59 4 331 77 469 2 \n658 599 87 246 24 36 41 664 71 61 91 7952 771 548 574 655 82 19 23 795 4775 825 7441 41 446 8624 35 8 21 42 156 585 23 2956 95 888 44 74 18 82 776 4999 37 74 28 956 8285 32 391 322 86 539 263 14 2465 18 672 87 42 2616 5 91 78 3273 61 8 57 59 93 69 45 7985 87 331 511 97 77 7695 2 92 8336 598 2953 41 74 79 88 76 669 573 423 54 76 563 72 472 631 359 791 42 81 75 512 563 4241 25 672 81 741 128 44 82 126 1884 34 3337 39 25 4825 824 24 356 82 8627 956 528 58 56 85 691 15 31 1272 123 58 41 45 74 232 573 93 13 96 331 73 84 593 559 36 359 72 11 38 91 897 923 346 622 55 8317 52 32 17 849 97 275 75 929 76 91 36 22 75 96 51 98 82 55 483 855 193 43 55 2 75 25 76 327 728 94 646 177 15 55 363 39 865 1 363 66 9462 53 565 7 1 16 4 35 64 8919 756 81 58 1 57 355 72 122 29 87 44 711 18 766 86 452 355 4897 1 82 2 69 564 97 39 949 17 21 986 34 22 192 77 323 35 68 393 93 765 46 93 23 66 4 16 643 995 75 75 54 812 373 482 955 135 71 55 3649 38 4411 94 216 4 6 6 32 143 658 9193 764 7736 939 297 84 42 246 36 653 73 26 624 27 8 197 836 784 466 3 925 57 746 87 28 713 982 21 355 45 66 113 64 96 688 929 429 955 732 46 423 9548 4664 11 311 9 1 22 43 8 132 2 15 48 4121Line truncated
+64
View File
@@ -0,0 +1,64 @@
(ns question-6
(:require [clojure.string :as strings]
[inputs]))
(def mock-input "123 328 51 64 \n 45 64 387 23 \n 6 98 215 314\n* + * + ")
(defn split-when [pred]
(fn [xf]
(let [group (volatile! [])]
(fn
([] (xf))
([result] (let [g @group]
(if (seq g)
(xf result g)
(xf result))))
([result input]
(let [g @group]
(if (pred input)
(do (vreset! group [])
(if (seq g) (xf result g) (xf result)))
(do
(vswap! group #(conj % input))
(xf result)))))))))
(defn parse-input-a [document]
(let [split-space #(strings/split (strings/trim %) #"\s+")
parse-cols (fn [& lst] (conj (map Long/parseLong (butlast lst))
(if (= (last lst) "+") + *)))
lines (mapv split-space (strings/split-lines document))]
(apply mapv parse-cols lines)))
(defn parse-input-b [document]
(let [transpose #(apply map vector %)
m (map vec (strings/split-lines document))]
(transpose m)))
(defn question-6-a [document]
(reduce + (map eval (parse-input-a document))))
(defn find-operator [block]
(if (contains? (apply hash-set (flatten block)) \+)
+
*))
(defn find-line-value [line]
(let [number-chars (remove #(contains? #{\space \* \+} %) line)]
(Long/parseLong (apply str number-chars))))
(defn find-block-value [block]
(let [op (find-operator block)]
(reduce op (map find-line-value block))))
(defn question-6-b [document]
(let [m (parse-input-b document)
xf (split-when #(apply = (conj % \space)))
blocks (sequence xf m)]
(reduce + (map find-block-value blocks))))
(defn -main [& args]
(println "Solution to question 6-a is: " (question-6-a mock-input))
(println "Solution to question 6-b is: " (question-6-b inputs/question-6)))