diff --git a/2021/day01/day01.hs b/2021/day01/day01.hs new file mode 100644 index 0000000..4d5c182 --- /dev/null +++ b/2021/day01/day01.hs @@ -0,0 +1,9 @@ +main :: IO () +main = do + input <- map read . lines <$> readFile "input" + print $ day1 input + print $ day1 $ zipWith3 (\x y z->x+y+z) input (tail input) (tail $ tail input) + + +day1 :: [Int] -> Int +day1 a = sum $ map fromEnum $ zipWith (<) a (tail a) diff --git a/2021/day01/input b/2021/day01/input new file mode 100644 index 0000000..a3eedc0 --- /dev/null +++ b/2021/day01/input @@ -0,0 +1,2000 @@ +131 +140 +136 +135 +155 +175 +178 +186 +187 +189 +194 +195 +203 +193 +178 +179 +180 +188 +204 +214 +215 +252 +253 +261 +281 +294 +293 +299 +300 +301 +307 +333 +324 +322 +323 +335 +319 +312 +313 +312 +320 +323 +324 +336 +341 +347 +357 +358 +363 +357 +334 +348 +364 +365 +367 +370 +369 +373 +344 +328 +330 +327 +339 +340 +341 +335 +342 +347 +349 +355 +348 +359 +360 +341 +342 +322 +321 +324 +323 +322 +324 +327 +340 +341 +353 +383 +387 +391 +422 +424 +422 +426 +429 +427 +428 +445 +421 +423 +429 +414 +411 +407 +409 +402 +422 +425 +423 +427 +424 +430 +428 +432 +433 +434 +429 +430 +406 +407 +411 +420 +412 +419 +422 +424 +425 +426 +428 +430 +432 +431 +432 +433 +449 +450 +453 +457 +459 +462 +482 +470 +471 +488 +495 +496 +499 +503 +516 +526 +531 +532 +541 +555 +554 +567 +558 +557 +560 +561 +566 +580 +581 +582 +594 +595 +598 +599 +582 +589 +593 +589 +592 +593 +590 +606 +615 +623 +627 +628 +630 +636 +641 +657 +658 +693 +695 +698 +707 +713 +714 +720 +721 +723 +721 +720 +707 +679 +699 +676 +667 +663 +664 +666 +660 +663 +673 +677 +662 +660 +663 +683 +681 +674 +689 +698 +699 +704 +705 +696 +697 +702 +693 +694 +700 +699 +681 +684 +690 +669 +673 +688 +691 +692 +691 +688 +685 +656 +638 +634 +651 +665 +670 +672 +685 +689 +709 +711 +714 +715 +735 +734 +738 +737 +738 +744 +765 +769 +776 +809 +819 +812 +814 +821 +794 +793 +796 +794 +815 +827 +831 +834 +840 +850 +846 +849 +842 +847 +846 +849 +850 +857 +885 +887 +888 +887 +883 +894 +895 +913 +917 +913 +915 +917 +918 +920 +929 +959 +961 +958 +954 +956 +962 +966 +959 +966 +967 +969 +972 +978 +993 +998 +1006 +1007 +1010 +1011 +1015 +1037 +1047 +1051 +1029 +1050 +1052 +1054 +1033 +1040 +1036 +1021 +1031 +1033 +1058 +1070 +1066 +1064 +1052 +1051 +1057 +1058 +1059 +1060 +1071 +1080 +1081 +1083 +1086 +1075 +1083 +1092 +1095 +1101 +1113 +1078 +1080 +1075 +1077 +1080 +1083 +1090 +1092 +1091 +1092 +1093 +1097 +1099 +1103 +1104 +1105 +1109 +1084 +1101 +1103 +1109 +1101 +1099 +1096 +1099 +1103 +1104 +1105 +1119 +1123 +1095 +1096 +1095 +1132 +1149 +1164 +1165 +1182 +1180 +1198 +1207 +1210 +1213 +1218 +1239 +1235 +1236 +1242 +1243 +1276 +1279 +1282 +1283 +1299 +1301 +1294 +1298 +1304 +1301 +1303 +1313 +1312 +1316 +1317 +1319 +1320 +1315 +1318 +1326 +1330 +1332 +1331 +1334 +1319 +1316 +1308 +1306 +1309 +1312 +1310 +1329 +1318 +1321 +1335 +1310 +1311 +1313 +1329 +1331 +1335 +1341 +1355 +1356 +1357 +1360 +1378 +1373 +1374 +1373 +1377 +1378 +1383 +1379 +1380 +1376 +1370 +1369 +1380 +1381 +1382 +1381 +1383 +1377 +1401 +1403 +1408 +1417 +1406 +1407 +1409 +1411 +1414 +1420 +1419 +1426 +1456 +1452 +1453 +1454 +1453 +1450 +1442 +1430 +1434 +1435 +1439 +1440 +1441 +1442 +1463 +1464 +1471 +1469 +1471 +1472 +1433 +1436 +1434 +1440 +1446 +1447 +1452 +1454 +1441 +1434 +1420 +1404 +1396 +1412 +1423 +1424 +1437 +1450 +1452 +1457 +1458 +1422 +1423 +1433 +1436 +1453 +1484 +1485 +1460 +1457 +1458 +1464 +1465 +1467 +1468 +1475 +1476 +1471 +1470 +1471 +1473 +1470 +1473 +1474 +1490 +1482 +1484 +1508 +1515 +1522 +1521 +1514 +1518 +1520 +1522 +1530 +1528 +1523 +1535 +1537 +1539 +1541 +1533 +1528 +1531 +1538 +1539 +1541 +1547 +1551 +1550 +1545 +1546 +1548 +1551 +1566 +1577 +1586 +1587 +1588 +1613 +1615 +1631 +1638 +1639 +1640 +1645 +1648 +1642 +1640 +1643 +1673 +1679 +1669 +1673 +1666 +1669 +1674 +1682 +1683 +1700 +1698 +1709 +1717 +1729 +1743 +1745 +1746 +1744 +1714 +1722 +1727 +1734 +1735 +1745 +1752 +1751 +1772 +1788 +1794 +1798 +1804 +1798 +1793 +1796 +1806 +1809 +1815 +1816 +1815 +1813 +1812 +1817 +1818 +1821 +1825 +1821 +1853 +1827 +1822 +1825 +1834 +1833 +1830 +1836 +1837 +1838 +1840 +1841 +1846 +1841 +1842 +1845 +1862 +1863 +1896 +1898 +1884 +1885 +1893 +1892 +1895 +1896 +1894 +1903 +1902 +1907 +1915 +1919 +1922 +1923 +1921 +1924 +1925 +1927 +1931 +1932 +1939 +1940 +1939 +1959 +1965 +1975 +1973 +1974 +1982 +1983 +1988 +1992 +1995 +1994 +1995 +1994 +2000 +2001 +2029 +2030 +2005 +2006 +2009 +2013 +2017 +2014 +2041 +2042 +2052 +2047 +2048 +2052 +2051 +2053 +2052 +2069 +2058 +2059 +2060 +2061 +2063 +2062 +2065 +2066 +2070 +2072 +2075 +2061 +2038 +2037 +2024 +2022 +2023 +2011 +2032 +2037 +2026 +2027 +2028 +2034 +2038 +2039 +2029 +2042 +2031 +2033 +2046 +2048 +2041 +2049 +2050 +2052 +2063 +2064 +2065 +2067 +2086 +2070 +2078 +2087 +2086 +2089 +2075 +2076 +2101 +2103 +2115 +2095 +2109 +2112 +2115 +2126 +2152 +2129 +2132 +2117 +2116 +2119 +2128 +2127 +2139 +2140 +2141 +2145 +2146 +2125 +2136 +2132 +2121 +2125 +2126 +2134 +2135 +2142 +2148 +2149 +2133 +2137 +2156 +2160 +2161 +2162 +2164 +2176 +2177 +2179 +2183 +2184 +2186 +2187 +2190 +2195 +2216 +2210 +2209 +2206 +2214 +2211 +2216 +2223 +2224 +2225 +2230 +2242 +2246 +2248 +2268 +2272 +2273 +2278 +2279 +2280 +2281 +2275 +2276 +2282 +2283 +2278 +2285 +2288 +2289 +2286 +2290 +2285 +2291 +2294 +2287 +2293 +2315 +2314 +2315 +2325 +2323 +2328 +2308 +2312 +2322 +2361 +2364 +2366 +2364 +2369 +2368 +2384 +2387 +2390 +2396 +2370 +2371 +2377 +2378 +2377 +2379 +2395 +2384 +2381 +2395 +2401 +2412 +2411 +2412 +2414 +2420 +2422 +2408 +2425 +2427 +2428 +2438 +2442 +2445 +2456 +2462 +2461 +2469 +2467 +2472 +2471 +2469 +2449 +2448 +2442 +2459 +2460 +2474 +2477 +2478 +2480 +2483 +2468 +2444 +2442 +2444 +2460 +2456 +2445 +2437 +2430 +2432 +2457 +2463 +2467 +2474 +2477 +2475 +2478 +2477 +2478 +2480 +2485 +2471 +2495 +2509 +2514 +2522 +2523 +2533 +2515 +2518 +2539 +2535 +2543 +2580 +2586 +2601 +2602 +2600 +2602 +2598 +2597 +2598 +2605 +2597 +2596 +2600 +2602 +2599 +2605 +2613 +2614 +2611 +2603 +2602 +2601 +2607 +2608 +2606 +2598 +2599 +2602 +2597 +2605 +2611 +2612 +2613 +2645 +2657 +2662 +2668 +2669 +2652 +2655 +2661 +2663 +2662 +2664 +2677 +2695 +2702 +2738 +2739 +2738 +2740 +2728 +2720 +2714 +2720 +2712 +2724 +2725 +2736 +2745 +2742 +2747 +2749 +2744 +2746 +2750 +2753 +2759 +2760 +2761 +2731 +2733 +2735 +2736 +2737 +2741 +2739 +2740 +2744 +2745 +2755 +2744 +2746 +2748 +2752 +2750 +2755 +2736 +2740 +2742 +2753 +2752 +2755 +2780 +2781 +2783 +2786 +2788 +2786 +2796 +2790 +2789 +2798 +2816 +2817 +2815 +2817 +2819 +2820 +2825 +2823 +2827 +2853 +2856 +2861 +2862 +2854 +2873 +2887 +2884 +2888 +2884 +2885 +2893 +2902 +2901 +2902 +2904 +2908 +2909 +2911 +2914 +2929 +2931 +2935 +2934 +2935 +2934 +2917 +2918 +2921 +2926 +2932 +2937 +2947 +2928 +2946 +2971 +2973 +2972 +2969 +2972 +2973 +2978 +2977 +2968 +2961 +2962 +2982 +2987 +2989 +2990 +2993 +2995 +2987 +2991 +2992 +3002 +3003 +3004 +3005 +3011 +3012 +3031 +3029 +3036 +3041 +3069 +3070 +3087 +3077 +3090 +3087 +3066 +3078 +3080 +3081 +3071 +3074 +3075 +3074 +3069 +3070 +3078 +3086 +3080 +3086 +3088 +3096 +3098 +3103 +3117 +3114 +3143 +3148 +3149 +3150 +3149 +3151 +3165 +3169 +3172 +3183 +3184 +3185 +3190 +3204 +3218 +3230 +3231 +3248 +3249 +3252 +3249 +3246 +3268 +3273 +3274 +3277 +3289 +3257 +3269 +3279 +3267 +3284 +3312 +3315 +3314 +3317 +3310 +3315 +3314 +3304 +3305 +3308 +3322 +3326 +3331 +3336 +3339 +3345 +3348 +3349 +3348 +3350 +3348 +3350 +3362 +3363 +3373 +3368 +3349 +3347 +3344 +3362 +3364 +3365 +3374 +3380 +3390 +3387 +3389 +3391 +3392 +3390 +3388 +3389 +3395 +3415 +3416 +3414 +3415 +3416 +3417 +3420 +3418 +3422 +3421 +3428 +3421 +3422 +3424 +3421 +3422 +3419 +3416 +3392 +3396 +3408 +3399 +3400 +3403 +3392 +3398 +3393 +3415 +3436 +3458 +3459 +3467 +3469 +3472 +3480 +3489 +3491 +3490 +3521 +3518 +3517 +3518 +3502 +3510 +3505 +3506 +3508 +3509 +3510 +3506 +3504 +3505 +3522 +3525 +3531 +3524 +3522 +3517 +3523 +3526 +3512 +3516 +3521 +3535 +3544 +3539 +3514 +3519 +3525 +3523 +3530 +3529 +3534 +3526 +3523 +3525 +3522 +3509 +3510 +3523 +3522 +3516 +3518 +3522 +3539 +3540 +3546 +3551 +3556 +3566 +3545 +3573 +3574 +3576 +3581 +3582 +3602 +3604 +3606 +3590 +3596 +3598 +3599 +3607 +3573 +3592 +3599 +3607 +3609 +3617 +3621 +3606 +3602 +3599 +3609 +3602 +3598 +3607 +3612 +3613 +3630 +3632 +3634 +3636 +3642 +3651 +3655 +3662 +3687 +3688 +3689 +3684 +3664 +3663 +3667 +3645 +3647 +3649 +3660 +3673 +3665 +3663 +3633 +3656 +3658 +3669 +3672 +3673 +3675 +3683 +3684 +3685 +3683 +3687 +3699 +3703 +3707 +3717 +3749 +3763 +3767 +3771 +3774 +3790 +3801 +3808 +3813 +3814 +3819 +3835 +3834 +3835 +3836 +3837 +3836 +3837 +3839 +3844 +3845 +3831 +3830 +3828 +3829 +3830 +3846 +3844 +3825 +3811 +3806 +3809 +3807 +3826 +3836 +3847 +3848 +3849 +3850 +3863 +3869 +3868 +3869 +3870 +3871 +3867 +3868 +3872 +3871 +3874 +3875 +3874 +3876 +3879 +3884 +3901 +3904 +3901 +3915 +3905 +3904 +3889 +3914 +3917 +3931 +3932 +3930 +3932 +3937 +3943 +3939 +3941 +3943 +3930 +3929 +3945 +3954 +3972 +3996 +3997 +4000 +4001 +3995 +4025 +4027 +4034 +4035 +4050 +4074 +4071 +4077 +4078 +4085 +4087 +4088 +4091 +4090 +4091 +4092 +4089 +4091 +4096 +4094 +4095 +4107 +4109 +4130 +4131 +4124 +4136 +4139 +4153 +4161 +4173 +4149 +4154 +4148 +4150 +4128 +4160 +4164 +4168 +4169 +4158 +4165 +4174 +4171 +4195 +4200 +4201 +4195 +4198 +4201 +4202 +4196 +4203 +4211 +4209 +4210 +4217 +4220 +4203 +4193 +4194 +4197 +4193 +4195 +4196 +4195 +4197 +4218 +4222 +4236 +4223 +4225 +4242 +4262 +4265 +4256 +4260 +4270 +4271 +4276 +4272 +4275 +4297 +4304 +4297 +4299 +4302 +4303 +4301 +4306 +4337 +4341 +4342 +4343 +4345 +4346 +4351 +4350 +4338 +4331 +4337 +4331 +4345 +4309 +4311 +4327 +4328 +4335 +4360 +4362 +4364 +4360 +4357 +4359 +4367 +4368 +4352 +4351 +4347 +4360 +4356 +4357 +4362 +4363 +4357 +4362 +4367 +4385 +4388 +4392 +4395 +4397 +4398 +4387 +4395 +4399 +4402 +4403 +4424 +4434 +4443 +4444 +4445 +4456 +4457 +4466 +4470 +4469 +4470 +4471 +4505 +4499 +4500 +4476 +4483 +4475 +4476 +4486 +4496 +4495 +4504 +4503 +4516 +4518 +4517 +4525 +4527 +4530 +4532 +4533 +4535 +4537 +4541 +4544 +4546 +4549 +4551 +4552 +4555 +4556 +4563 +4580 +4583 +4600 +4589 +4581 +4585 +4583 +4585 +4592 +4585 +4595 +4605 +4598 +4601 +4600 +4603 +4598 +4628 +4630 +4626 +4630 +4632 +4631 +4632 +4619 +4633 +4643 +4630 +4640 +4660 +4671 +4675 +4682 +4697 +4695 +4700 +4704 +4705 +4710 +4721 +4727 +4732 +4728 +4729 +4735 +4743 +4744 +4754 +4760 +4766 +4758 +4762 +4760 +4763 +4782 +4786 +4787 +4789 +4801 +4804 +4782 +4752 +4755 +4757 +4758 +4757 +4766 +4778 +4779 +4769 +4781 +4777 +4785 +4786 +4788 +4796 +4795 +4796 +4797 +4805 +4804 +4814 +4812 +4815 +4806 +4805 +4807 +4805 +4806 +4807 +4810 +4845 +4846 +4855 +4853 +4859 +4862 +4867 +4873 +4879 +4881 +4880 +4883 +4880 +4886 +4892 +4898 +4903 +4902 +4905 +4909 +4914 +4915 +4917 +4939 +4941 +4933 +4932 +4940 +4945 +4961 +4966 +4955 +4960 +4979 +4980 +4981 +4970 +4968 +4970 +4989 +4996 +5003 +4983 +4984 +5006 +5014 +5018 +5023 +5042 +5043 +5050 +5051 +5076 +5052 +5055 +5068 +5059 +5058 +5035 +5059 +5060 +5061 +5068 +5044 +5043 +5044 +5045 +5047 +5048 +5051 +5044 +5045 +5049 +5072 +5080 +5078 +5101 +5100 +5092 +5112 +5111 +5107 +5113 +5116 +5123 +5129 +5127 +5151 +5176 +5188 +5189 +5202 +5204 +5197 +5199 +5196 +5201 +5200 +5203 +5207 +5209 +5217 +5218 +5204 +5206 +5207 +5208 +5195 +5201 +5202 +5199 +5229 +5228 +5229 +5233 +5232 +5227 +5228 +5229 +5238 +5236 +5238 +5243 +5245 +5244 +5245 +5230 +5244 +5258 +5259 +5268 +5271 +5274 +5271 +5272 +5277 +5300 +5327 +5358 +5359 +5360 +5361 +5364 +5370 +5375 +5376 +5384 +5383 +5384 +5385 +5389 +5390 +5395 +5397 +5413 +5418 +5434 +5433 +5449 +5445 +5447 +5453 +5454 +5458 +5460 +5448 +5452 +5464 +5469 +5480 +5481 +5482 +5486 +5496 +5499 +5500 +5527 +5501 +5476 +5474 +5475 +5463 +5462 +5458 +5459 +5470 +5473 +5481 +5493 +5494 +5495 +5496 +5497 +5498 +5495 +5498 +5496 +5490 +5491 +5493 +5495 +5489 +5514 +5533 +5541 +5531 +5537 +5513 +5531 +5532 +5533 +5532 +5526 +5535 +5553 +5551 +5554 +5553 +5555 +5551 +5557 +5556 +5558 +5555 +5554 +5552 +5566 +5574 +5577 +5583 +5584 +5588 +5590 +5603 +5610 +5617 +5619 +5618 +5619 +5618 +5630 +5635 +5638 +5650 +5659 +5660 +5672 +5670 +5676 +5673 +5675 +5680 +5682 +5685 +5688 +5682 +5683 +5696 +5700 +5722 +5714 +5713 +5710 +5712 +5740 +5741 +5739 +5740 +5746 +5756 +5769 +5770 +5757 +5748 +5766 +5770