diff --git a/01/input b/01/input new file mode 100644 index 0000000..51d7adf --- /dev/null +++ b/01/input @@ -0,0 +1,2255 @@ +5104 +6131 +3553 +4496 +5847 +3253 +1828 +1045 +6369 +5544 +2756 +7382 + +6879 +9715 +10122 + +14438 +1135 +13406 +4888 + +67712 + +1965 +4515 +4150 +3583 +3007 +4852 +6397 +6237 +5505 +3106 +6357 +2504 +4074 + +1689 +5612 +5531 +3138 +1203 +4821 +3468 +2424 +3425 +5566 +4374 +5233 +5452 +3049 +2260 + +3933 +6073 +2260 +2376 +7298 +3397 +3479 +5316 +6750 +4800 + +14581 +6385 +18287 +14353 + +44790 + +66296 + +3368 +1373 +9644 +1682 +11146 +6876 + +2544 +5471 +3632 +1837 +2272 +2956 +4989 +1754 +4574 +5076 +3201 +2199 +5688 +1161 +3326 + +4897 +3510 +4961 +2747 +3931 +2722 +4021 +2231 +5466 +6371 +4691 +2851 +1846 +4720 + +13096 +5576 +5765 +3715 +8851 + +3339 +6453 +4991 +3935 +5900 +2326 +4731 +3323 +6270 +7505 + +2208 +3058 +6908 +6343 +6513 +5383 +6087 +5836 +4824 +5588 +5039 +6138 +1077 + +9045 +6898 +8327 +4103 +4006 +6797 +8591 +6515 +5228 + +39541 + +33536 +7614 + +4637 +7862 +3038 +6682 +8880 +2784 +7924 +5589 +2107 + +33278 +18120 + +1005 +3479 +4129 +2799 +5324 +7799 +5380 +6998 +1877 + +31663 +9259 + +1009 +3987 +1254 +6449 +5134 +6090 +6341 +3229 +5902 +4492 +4025 + +10079 +16006 +19943 +1970 + +3428 +5671 +1030 +2461 +6073 +2875 +3493 +3103 +1476 +4305 +2664 +5017 +4210 +3629 + +45170 + +11282 +8209 +10075 +1366 +13841 +3412 + +9981 +7808 +1565 +3171 +6684 +1905 +1087 + +14447 +11220 +3519 +10317 +14174 + +7518 +3810 +12824 +3137 +2272 +2616 + +7827 +29197 + +8799 +12459 +16530 +16661 + +1965 +10267 +11399 +11562 +13367 +10223 + +6410 +2536 +7255 +2151 +3190 +5786 +4114 +6875 +4013 +2381 +6020 + +1751 +6262 +5190 +5091 +6453 +3652 +2929 +3411 +4954 +1275 +1468 +2689 +1200 +4362 + +4928 +5282 +6845 +5328 +2101 +6522 +3929 +3276 +4740 +4493 +4003 +6797 + +6529 +11489 +1696 +12922 +8959 +10927 + +13381 +5921 +5375 +10424 +9279 +10031 + +3800 +2166 +1964 +4182 +3395 +5956 +6024 +2473 +2780 +3686 +5791 +1449 +2698 +4430 +1008 + +37175 +26191 + +2863 +1329 +6266 +5911 +6331 +5211 +2420 +6006 +2259 +4125 +1885 +2284 +6213 + +3560 +4007 +5585 +4484 +1828 +7935 +5895 +3139 +6413 + +1201 +3350 +3763 +1920 +4653 +1662 +2559 +1918 +6378 +6688 +2569 +3180 + +4347 +1526 +7318 +3860 +4250 +6191 +10198 + +8179 +5824 +4470 +7569 +3163 +1859 +2541 +3433 +1851 +7360 + +1028 +3103 +3166 +2025 +5630 +5067 +1819 +1590 +2290 +3636 +2411 +2856 +1918 +3050 + +3582 +4564 +3311 +4695 +4780 +5863 +3626 +5304 +4009 +1499 +1528 +2261 +2743 +3992 + +6432 +4354 +1747 +3799 +7415 +6951 +4928 +7862 +6082 +1010 +3586 + +11375 +14308 +7595 +18952 + +23213 +18972 + +15795 +17712 +5850 + +4756 +3643 +3397 +6067 +5206 +1658 +2436 +4293 +2352 +5096 +2038 +3780 +2620 +3124 +2525 + +8776 +3372 +2945 +7681 +7636 +1851 +2755 +2058 +7856 + +9353 +5890 +3167 +2211 +6056 +4894 +10709 +2793 + +3477 +7013 +4750 +7568 +7135 +4165 +7490 +5932 +1434 +6230 +7262 + +2988 +3138 +6692 +5152 +6590 +7063 +5578 +3263 +2918 +4021 +6292 +3340 + +8043 +7625 +3391 +6085 +6245 +4824 +5767 +6627 +2367 +2729 + +1520 +6438 +2132 +1601 +4488 +5254 +2935 +2368 +1569 +3680 +5772 +6031 +6288 +5836 + +5254 +4257 +6075 +5658 +6032 +6121 +5074 +4844 +3709 +4521 +5464 +1705 +6448 +6340 + +14988 +3400 +15846 +12040 +6216 + +45130 + +4014 +2376 +2115 +3132 +5487 +6934 +5925 +2810 +4421 +6486 +2346 +5692 + +12105 +2383 +9893 +5469 +7597 +5977 +7022 + +2795 +6488 +20406 + +12538 +3692 +3757 +12964 +15776 + +1139 +2432 +1346 +1249 +1454 +5679 +2131 +1057 +6395 +2604 +6336 +1444 +6703 + +1499 +6392 +4154 +1207 +3827 +4646 +4283 +2106 +2958 +1327 +3760 +2575 +3961 + +11023 +7199 +6134 +12194 +10621 + +6715 +5245 +4073 +5978 +3950 +5613 +3517 +3845 +5611 +2993 +4704 +4468 +4833 + +25207 +18060 +8124 + +3263 +2985 +6577 +3964 +1392 +2316 +5224 +3923 +1392 +5569 +4833 +5873 +1627 + +1347 +5148 +4046 +3618 +3677 +6767 +3809 +1979 +8779 +2274 + +15152 +5482 +5835 +4176 + +1191 +5296 +1107 +7245 +4121 +2598 +4148 +2388 +5949 +1851 +3747 +3829 + +1942 +6426 +4916 +4572 +2965 +3453 +7020 +8067 +1144 +5931 +2985 + +3315 +1989 +1609 +2161 +5836 +3243 +3901 +2795 +4187 +2790 +2083 +3164 +4843 +5887 + +16209 +2858 +2586 +15877 +13993 + +8898 +4191 +1864 +9272 +9284 +5581 +4912 +1084 +6000 + +3410 +5934 +1609 +4699 +5008 +3104 +6016 +3130 +7286 +1906 + +7381 +4765 +2427 +2044 +6493 +2845 +1431 +5109 +7242 +3930 +1350 +4999 + +10119 +12971 +5407 +6448 +14453 + +5647 +5083 +3317 +6707 +1586 +2179 +1468 +1214 +5992 +5732 +5813 + +1260 +3272 +11607 +3794 +4599 +2890 + +16930 +16192 + +3140 +6499 +4094 +5617 +4379 +6309 +4400 +4764 +1143 +2004 +4451 +3034 +4209 + +2653 +5514 +3335 +8021 +7656 +7956 +9425 +5902 +7280 + +23692 + +1097 +8621 +2372 +4381 +10625 +6138 +7127 + +1719 +5845 +3170 +4103 +5550 +3430 +2824 + +2489 +13880 +7484 +4617 + +11152 +2300 +2349 +9548 +7018 + +5745 +2571 +5758 +1580 +1411 +3944 +4867 +2541 +1998 +3769 +5598 +5138 +4369 +5419 + +10223 +10283 +2268 + +5604 +4701 +2054 +3920 +4925 +5118 +3707 +1838 +2159 +4192 +5164 +4419 +5630 +3127 +5255 + +3686 +1791 +3543 +6111 +4260 +3612 +4021 +3316 +3100 +5383 +1962 +3323 +5630 + +2391 +6494 +3948 +3811 +2101 +4075 +3030 +4553 +1170 +1604 +6209 +1122 +3951 +3447 + +4687 +1165 +2511 +2316 +4002 +3832 +4968 +1082 +5374 +1960 +2355 +1975 +4569 +2324 + +4285 +3885 +2613 +1102 +4284 +3439 +5074 +1279 +6287 + +3501 +10232 +9878 +10401 +5166 +9221 +2356 +7718 + +17368 +8643 +12092 +3319 + +7510 +4438 +8329 +4973 +6213 +6441 +1801 +7936 +7802 + +6491 +4569 +4130 +3144 +2275 +1831 +2833 +6234 +5260 +5476 +5066 +4356 +1835 + +3842 +19003 +9012 +7301 + +1596 +8020 + +5794 +6031 +4868 +5488 +3633 +5019 +1113 +4435 +1258 +2866 +6007 +4006 +4164 +4748 +1899 + +5388 +7788 +1063 +3566 +3185 +3839 +6396 +6052 +4822 +1345 +4405 + +5048 +8412 +11211 +10874 +11580 +9113 + +2921 +9381 +5501 +5959 +3511 +6107 + +3827 +2400 +1465 +4592 +1070 +5953 +1252 +5820 +4496 +6461 +4105 +5273 + +7867 + +7212 +2869 +4893 +5449 +1790 +4027 +4863 +6804 +4589 +4431 +2978 +5646 + +6820 +1830 +5561 +11648 +2836 + +3711 +7705 +8802 +1093 +10308 +1310 +4998 +9163 + +6599 +6302 +1817 +5460 +1686 +1639 +6831 +2245 +2026 +1250 +1521 +6664 +4326 + +8495 +15655 +1144 +6597 +13967 + +5998 +4313 +5903 +3692 +8234 +2692 +10457 +3100 + +1861 + +14744 +4779 +12847 +5418 + +1755 +11466 +4824 +3036 +2407 +3799 + +3703 +5199 +4767 +3220 +4703 +1618 +2408 +6934 +6244 + +10247 +6489 +6234 +2992 +8650 +2238 + +4281 +13678 +15074 +6788 +6291 + +8999 +10740 +12070 +5488 +1840 +6026 +8971 + +1663 +9127 +3582 +5593 +1469 +7933 +3315 +8614 +8179 + +31510 +20867 + +3135 +4978 +2113 +3443 +2488 +2805 +5385 +2765 +2443 +5948 +4798 +2685 +3580 +5153 +3035 + +7786 +5488 +6868 +6016 +8457 +3381 +1057 +3370 + +5493 +5175 +4669 +3522 +6305 +2560 +5075 +4445 +3881 +6694 +4367 +6287 +3496 + +10356 +13146 +10433 +7922 +5423 +6508 + +17729 +30047 + +1564 +8859 +7596 +10579 +7432 +7320 +4046 + +4402 +4813 +7497 +8596 +8944 + +9946 +3497 +4322 +1990 +6240 +9993 +8309 + +24706 +3277 +22881 + +6766 +1997 +3845 +6791 +5254 +2251 +5959 +5030 +7267 +6440 +3457 +4772 + +8589 +5044 +9480 +10563 +8685 +7787 +9630 +9199 + +9423 +2006 +5708 +4116 +14214 + +18376 +3635 +11243 + +6763 +4005 +1430 +3727 +1574 +4517 +1253 +5880 +4091 +1499 +6714 +6510 +6452 + +5479 +4798 +6197 +3737 +6874 +2965 +5032 +4024 +5051 +8053 + +34588 +18765 + +6659 +7468 +3910 +7243 +5199 +6073 +4412 +7824 +3338 +3599 +7017 + +3490 +2272 +2824 +5088 +6335 +1716 +2386 +3356 +2055 +2013 +2983 +5382 +1507 +4581 + +19218 +16697 +9274 + +22122 +13616 +2703 + +1794 +4376 +2241 +2705 +2104 +1658 +3543 +2607 +3770 +4622 +3370 +2443 +4444 +5476 +3714 + +53258 + +11510 +15672 +12872 +8622 + +5586 +15502 +3056 +3890 +14551 + +1608 +4148 +3884 +4981 +8494 +6494 +6595 +6983 +2298 +1599 + +22767 +5219 +2814 + +1034 +1031 +4757 +7276 +7064 +5309 +7766 +8161 + +9332 + +21322 +13644 +17204 + +52338 + +4741 +11019 +9823 +11376 +12363 +7345 + +13565 +12029 +6517 +4188 +11311 +3153 + +3172 +2579 +2147 +6643 +6720 +1518 +3920 +3744 +4907 +3887 +5811 +2260 +3640 + +2065 +4288 +2840 +3551 +2354 +3243 +5448 +2120 +2476 +3959 +2807 +5822 +1824 +6027 + +13354 +13217 +9371 +10773 +12933 + +4706 +3934 +8085 +3861 +3474 +4037 +4333 +1915 +7439 +4724 +1584 + +5587 +3880 +5972 +1568 +2925 +6189 +5112 +1034 +5146 +4456 +3302 +5930 +6509 +2232 + +10574 +13136 +19197 +12598 + +3319 +5343 +6042 +15163 +7853 + +2549 +9485 +3150 +3717 +4202 +8582 +9314 +1959 + +1651 +3584 +2353 +4100 +4642 +4105 +2675 +3241 +1441 +1093 +1012 +4275 +3727 +4598 +2407 + +9617 +2108 +4265 +5498 +2914 +7770 +5898 +9319 +2295 + +8587 + +2644 +3717 +4921 +2297 +4454 +5287 +2479 +4581 +1824 +3108 +4297 +1055 +4726 +1859 + +2170 +16319 +2974 + +3092 +4627 +5913 +4495 +3009 +4501 +4341 +4668 +4858 +3240 +1347 +3448 +3748 +5811 + +4644 +4571 +2358 +5466 +2255 +5075 +5466 +4229 +2211 +4262 +2900 +1966 +2627 +4728 + +7682 +9016 +4473 +8449 +9257 +2068 +10641 + +1499 +6224 +7304 +5201 +3451 +4984 +7737 +1728 +5302 +1062 +2178 + +30845 +12424 + +3483 +1244 +1700 +8543 +12788 + +2430 +9187 +9178 +3168 +10377 +8889 + +15000 +12965 +10098 +5507 +13346 + +5401 +2056 +7490 +9384 +3312 +7124 +7199 +5571 +6029 + +1218 +10456 +6922 +1815 +12092 +11303 +2461 + +1766 +5195 +4704 +1476 +4579 +1104 +3018 +6172 +3826 +6543 +1323 +6306 +6367 + +17963 +2012 +1664 +15479 + +32869 + +9473 +3761 +6631 +2522 +2878 +2435 +9087 +3261 +6032 + +4461 +1087 +4793 +1273 +1848 +2882 +1662 +4454 +1347 +5600 +2619 + +2300 +8563 +3317 +2462 +1118 +6131 +5801 +4281 +7292 + +3848 +13902 +7899 +10164 +12727 +8578 + +1076 +6192 +3308 +2648 +1919 +6489 +6050 +1639 +6490 +2768 +1169 +4718 +5799 +2658 + +12611 +18417 +13289 +16060 + +1806 +6019 +1058 +13468 +8292 +9682 + +13648 +24310 +6025 + +10030 +7199 +5366 +6080 +8944 +3416 +3746 +3597 + +8809 +10699 +5362 +8302 +3712 +2911 +2598 +5279 + +23190 +15323 +2535 + +2663 +10325 +9513 +2403 +6443 +6731 +8188 +9559 + +15302 + +4544 +6035 +4595 +5512 +7162 +1160 +2866 +5003 +6449 +3936 +2083 +1154 + +16473 + +4333 +2861 +2754 +5775 +5774 +3313 +1763 +3326 +3888 +2639 +3981 +1788 +6272 +2151 + +3830 +11759 +9430 +7412 +5190 +5926 +9828 + +19524 +15948 +5297 +16516 + +8073 +9705 +7872 +5308 +10279 +3645 +7983 +3467 + +12230 +22031 +6843 + +15329 +6540 + +4960 +5485 +1829 +5062 +4777 +4193 +4594 +5705 +1282 +4546 +6063 +4304 +2533 + +51798 + +11965 +12511 +2156 +13850 +10025 +12395 + +3476 +1232 +7227 +2031 +4457 +5152 +3616 +5374 +4576 +2413 + +1045 +24929 + +13068 +14356 +9552 +3897 +4369 + +3172 +3437 +2380 +5542 +4850 +4325 +1065 +1051 +3385 +5905 +1182 +6138 +6487 +2307 + +11847 +9674 +1409 +16351 +3793 + +1567 +6941 +2520 +6617 +4815 +4700 +2297 +2336 +3626 +8035 +1777 + +7380 +6231 +1464 +5680 +4298 +8018 +5861 +5967 +2799 +6888 +1401 + +1944 +3424 +4104 +5697 +2082 +1829 +4128 +3775 +3450 +5312 +3475 +4868 +4857 +1469 +4757 + +22339 +15143 + +4573 +5384 +2968 +6696 +2208 +3068 +3104 +2654 +5539 +7329 +6127 +3874 + +6693 +6878 +3318 +5526 +2042 +4895 +3809 +3718 +5881 +2444 +2448 + +6304 +5014 +1337 +5766 +9098 +4456 +6604 +1722 +4674 + +2403 +5059 +2439 +2113 +3879 +2289 +6524 +3707 +5199 +2908 +4624 +3742 +6077 + +2717 +3042 +1843 +2403 +5750 +2473 +3017 +3407 +4392 +2513 +6913 +6585 + +1996 +1118 +5230 +6283 +2639 +3324 +1236 +3483 +5270 +3399 +3111 +6098 + +6418 +3395 +3771 +5816 +2494 +1049 +5846 +4483 +3137 +4445 +2248 +1216 +2499 +3556 + +20769 +22782 +15068 + +2645 +3388 +2219 +6061 +6664 +4330 +5003 +4035 +6370 +2023 +6309 +5013 + +1222 +6095 +7410 +7957 +4087 +5677 +6829 +7151 +8731 +8168 + +11570 +27420 + +14541 +3035 +10295 +14965 + +4122 +5939 +8715 +1188 +4674 +4654 +7742 +4976 + +5269 +3341 +7796 +8918 + +9598 +2036 +10718 +9696 +8890 +2709 +4114 +1940 + +5054 +3311 +2306 +2633 +1810 +4733 +2133 +2185 +2322 +2396 +2992 +2202 +2671 +1932 +3398 + +4357 +1706 +3417 +2442 +5608 +5032 +6296 +5015 +1874 +5295 +3812 +4698 + +18153 +16982 +6152 + +16245 + +3048 +3827 +3394 +2137 +2364 +5478 +5992 +2396 +6139 +2323 +4458 +2292 +4003 + +1561 +1154 +1545 +1144 +2206 +4454 +5640 +4697 +1908 +3175 +5130 +2386 +6358 +4169 + +5785 +6697 +5246 +3215 +9759 +10601 +5507 + +4892 +7629 +4323 +3881 +4247 +2154 +1352 +3468 +3053 + +6710 +2117 +4776 +3991 +4021 +7543 +4268 +3355 +4701 +4663 +1015 + +13221 +14163 +11213 + +9488 +7173 +3708 +3524 +9290 +3390 +1272 +3325 +4864 + +3098 +6656 +1387 +4710 +1962 +7262 +7442 +2097 +4544 +1976 +6250 +1974 + +5122 +1843 +2929 +4066 +2403 +1020 +2723 +5914 +3821 +2189 +1047 +3334 +5773 +4396 +2777 + +2073 +2094 +4901 +1093 +5029 +5458 +5963 +4011 +3454 +3174 +2086 +1451 +5640 +2311 +2511 + +4243 +7521 +5018 +1914 +6762 +8155 + +19726 +11376 +6504 +4086 + +4150 +7015 +3007 +5002 +5151 +8346 +8024 +6498 +1696 + +5404 +5249 +1474 +2284 +1642 +3323 +4110 +1796 +5132 +1940 +1266 +2679 +4027 +2289 + +10301 +7013 +1666 +7987 +10426 +6423 +10008 +10015 + +6115 +6361 +1902 +8036 +5703 +2771 +7330 +8606 +6447 + +8917 +1183 +8966 +1255 +5988 +5233 +7358 +3806 +9333 diff --git a/01/script.rb b/01/script.rb new file mode 100755 index 0000000..aab4d78 --- /dev/null +++ b/01/script.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +require_relative '../common' + +class Day01 < Day + def part1 + input.each_with_object([0]) do |row, result| + if row == "" + result << 0 + else + result[-1] += row.to_i + end + end.max + end + + def part2 + input.each_with_object([0]) do |row, result| + if row == "" + result << 0 + else + result[-1] += row.to_i + end + end.sort[-3..-1].sum + end +end + +Day01.run