diff --git a/2021/01/01.exs b/2021/01/01.exs new file mode 100644 index 0000000..4d02868 --- /dev/null +++ b/2021/01/01.exs @@ -0,0 +1,20 @@ +lines = File.stream!("input.txt") + |> Stream.map(&String.trim/1) + |> Stream.map(&String.to_integer/1) + |> Enum.to_list + +# Part 1 +count = lines + |> Enum.chunk_every(2, 1, :discard) + |> Enum.count(fn [a, b] -> a < b end) + +IO.puts("Part 1: #{count}") + +# Part 2 +count = lines + |> Enum.chunk_every(3, 1, :discard) + |> Enum.map(&Enum.sum/1) + |> Enum.chunk_every(2, 1, :discard) + |> Enum.count(fn [a, b] -> a < b end) + +IO.puts("Part 2: #{count}") diff --git a/2021/01/input.txt b/2021/01/input.txt new file mode 100644 index 0000000..202ce7e --- /dev/null +++ b/2021/01/input.txt @@ -0,0 +1,2000 @@ +122 +129 +116 +122 +135 +148 +151 +158 +161 +179 +197 +198 +187 +210 +211 +206 +207 +210 +211 +216 +222 +224 +222 +234 +237 +238 +239 +245 +276 +262 +268 +266 +293 +291 +293 +296 +298 +291 +292 +295 +297 +298 +297 +300 +297 +309 +315 +319 +320 +319 +323 +338 +349 +351 +352 +354 +348 +366 +365 +388 +385 +379 +381 +385 +391 +392 +405 +407 +415 +427 +433 +436 +439 +444 +450 +449 +453 +457 +459 +460 +467 +471 +474 +473 +477 +487 +489 +498 +512 +516 +507 +526 +544 +560 +570 +569 +580 +590 +591 +593 +596 +597 +598 +604 +599 +608 +603 +616 +649 +636 +649 +648 +653 +654 +655 +656 +664 +666 +669 +663 +661 +682 +681 +685 +693 +701 +727 +706 +704 +705 +706 +711 +716 +711 +721 +728 +724 +734 +733 +737 +736 +742 +743 +742 +744 +745 +749 +750 +760 +767 +787 +788 +787 +789 +785 +798 +796 +797 +798 +800 +807 +817 +829 +828 +830 +831 +863 +865 +867 +868 +893 +891 +881 +889 +890 +914 +918 +919 +925 +938 +941 +927 +928 +900 +901 +899 +901 +911 +919 +918 +922 +942 +928 +947 +945 +950 +956 +979 +989 +990 +1001 +995 +997 +995 +1007 +1001 +998 +999 +1008 +1018 +1019 +1020 +1019 +1012 +1040 +1038 +1029 +1027 +1028 +1029 +993 +995 +994 +980 +990 +991 +990 +1012 +1024 +1037 +1039 +1037 +1053 +1029 +1048 +1050 +1055 +1058 +1059 +1064 +1062 +1087 +1079 +1081 +1088 +1090 +1113 +1110 +1119 +1123 +1126 +1127 +1126 +1131 +1135 +1137 +1140 +1142 +1143 +1145 +1146 +1147 +1139 +1140 +1143 +1136 +1105 +1108 +1109 +1098 +1121 +1126 +1096 +1090 +1058 +1061 +1063 +1068 +1072 +1073 +1104 +1111 +1108 +1110 +1152 +1153 +1157 +1158 +1162 +1167 +1164 +1167 +1168 +1169 +1168 +1166 +1171 +1172 +1175 +1177 +1184 +1187 +1191 +1196 +1197 +1193 +1204 +1209 +1212 +1213 +1234 +1238 +1242 +1257 +1268 +1254 +1237 +1228 +1226 +1222 +1209 +1211 +1212 +1219 +1226 +1227 +1235 +1245 +1258 +1264 +1277 +1276 +1285 +1288 +1287 +1289 +1290 +1291 +1290 +1286 +1290 +1285 +1286 +1290 +1291 +1286 +1297 +1302 +1305 +1304 +1305 +1318 +1324 +1347 +1348 +1353 +1354 +1371 +1370 +1371 +1373 +1369 +1347 +1351 +1352 +1371 +1373 +1379 +1383 +1390 +1391 +1394 +1399 +1398 +1401 +1402 +1406 +1409 +1413 +1412 +1420 +1423 +1424 +1431 +1433 +1420 +1421 +1422 +1423 +1439 +1404 +1416 +1404 +1423 +1424 +1427 +1444 +1420 +1423 +1417 +1418 +1414 +1440 +1441 +1445 +1469 +1476 +1481 +1480 +1484 +1483 +1482 +1458 +1459 +1433 +1431 +1433 +1426 +1436 +1437 +1452 +1454 +1455 +1456 +1474 +1463 +1477 +1479 +1501 +1496 +1494 +1493 +1496 +1505 +1506 +1511 +1516 +1517 +1510 +1514 +1513 +1509 +1512 +1543 +1544 +1526 +1532 +1534 +1538 +1540 +1518 +1519 +1528 +1530 +1531 +1534 +1537 +1551 +1552 +1550 +1548 +1545 +1564 +1585 +1615 +1618 +1617 +1623 +1640 +1638 +1637 +1639 +1641 +1672 +1676 +1679 +1681 +1678 +1689 +1696 +1703 +1704 +1703 +1699 +1700 +1719 +1732 +1692 +1693 +1698 +1712 +1713 +1712 +1705 +1716 +1731 +1748 +1749 +1747 +1749 +1750 +1768 +1783 +1784 +1791 +1793 +1798 +1799 +1800 +1807 +1812 +1822 +1847 +1852 +1843 +1849 +1855 +1870 +1868 +1869 +1873 +1875 +1889 +1878 +1879 +1880 +1886 +1891 +1895 +1891 +1890 +1891 +1892 +1897 +1898 +1899 +1910 +1897 +1898 +1899 +1895 +1892 +1905 +1913 +1920 +1921 +1923 +1941 +1960 +1962 +1971 +1972 +1962 +1965 +1977 +1976 +1993 +1995 +1997 +1992 +1987 +1993 +1977 +1978 +1979 +1974 +1981 +1978 +1973 +1977 +1984 +1979 +1984 +2027 +2054 +2055 +2058 +2060 +2059 +2060 +2066 +2062 +2066 +2074 +2064 +2065 +2064 +2071 +2077 +2078 +2082 +2078 +2092 +2093 +2095 +2100 +2101 +2104 +2110 +2106 +2107 +2113 +2112 +2138 +2143 +2151 +2150 +2151 +2147 +2169 +2171 +2174 +2193 +2196 +2183 +2201 +2198 +2199 +2197 +2194 +2195 +2206 +2220 +2219 +2224 +2242 +2230 +2231 +2237 +2255 +2256 +2252 +2251 +2259 +2256 +2258 +2286 +2291 +2295 +2296 +2267 +2275 +2287 +2288 +2272 +2269 +2270 +2278 +2279 +2282 +2265 +2282 +2284 +2292 +2296 +2301 +2302 +2319 +2320 +2314 +2316 +2317 +2313 +2314 +2319 +2314 +2328 +2334 +2347 +2352 +2353 +2354 +2352 +2354 +2362 +2374 +2383 +2382 +2384 +2383 +2384 +2388 +2390 +2396 +2405 +2406 +2429 +2430 +2427 +2460 +2461 +2474 +2479 +2493 +2494 +2493 +2488 +2489 +2511 +2512 +2504 +2520 +2529 +2524 +2523 +2536 +2567 +2571 +2589 +2594 +2595 +2594 +2583 +2568 +2566 +2557 +2558 +2559 +2557 +2558 +2561 +2582 +2586 +2604 +2603 +2604 +2618 +2630 +2632 +2633 +2644 +2650 +2651 +2666 +2669 +2683 +2691 +2686 +2683 +2687 +2683 +2684 +2707 +2723 +2733 +2739 +2750 +2751 +2750 +2754 +2757 +2756 +2735 +2736 +2743 +2728 +2717 +2689 +2690 +2732 +2743 +2746 +2747 +2750 +2755 +2756 +2770 +2772 +2781 +2789 +2790 +2801 +2802 +2799 +2800 +2816 +2823 +2822 +2839 +2840 +2843 +2852 +2854 +2881 +2890 +2901 +2908 +2906 +2910 +2896 +2898 +2914 +2923 +2936 +2958 +2928 +2929 +2928 +2929 +2930 +2935 +2942 +2930 +2951 +2979 +2992 +2991 +2992 +3016 +2993 +2994 +2999 +3016 +3017 +3022 +3031 +3032 +3033 +3039 +3042 +3040 +3041 +3040 +3049 +3048 +3050 +3054 +3048 +3056 +3061 +3062 +3056 +3049 +3062 +3053 +3050 +3051 +3053 +3056 +3072 +3073 +3068 +3086 +3093 +3107 +3104 +3102 +3103 +3102 +3104 +3093 +3094 +3095 +3097 +3096 +3080 +3087 +3103 +3107 +3142 +3139 +3138 +3141 +3140 +3156 +3161 +3142 +3141 +3152 +3154 +3153 +3152 +3144 +3150 +3148 +3150 +3169 +3151 +3154 +3152 +3154 +3162 +3157 +3158 +3163 +3169 +3176 +3220 +3229 +3224 +3211 +3227 +3231 +3234 +3249 +3250 +3253 +3259 +3251 +3249 +3250 +3251 +3243 +3263 +3267 +3275 +3282 +3292 +3295 +3263 +3262 +3264 +3263 +3262 +3266 +3261 +3272 +3245 +3252 +3250 +3251 +3252 +3254 +3278 +3285 +3292 +3295 +3294 +3293 +3314 +3315 +3323 +3321 +3334 +3335 +3342 +3345 +3346 +3352 +3350 +3355 +3358 +3357 +3360 +3354 +3357 +3366 +3368 +3373 +3374 +3373 +3364 +3374 +3380 +3386 +3385 +3387 +3400 +3401 +3407 +3409 +3426 +3440 +3445 +3442 +3452 +3453 +3460 +3456 +3465 +3459 +3457 +3460 +3459 +3466 +3472 +3475 +3474 +3477 +3473 +3478 +3477 +3472 +3459 +3486 +3494 +3506 +3513 +3514 +3518 +3521 +3516 +3518 +3516 +3521 +3519 +3512 +3513 +3510 +3511 +3512 +3538 +3542 +3545 +3546 +3548 +3546 +3556 +3546 +3549 +3541 +3553 +3556 +3560 +3561 +3567 +3574 +3580 +3596 +3599 +3621 +3620 +3625 +3627 +3623 +3624 +3657 +3665 +3664 +3672 +3671 +3666 +3662 +3655 +3656 +3655 +3656 +3661 +3663 +3666 +3670 +3672 +3673 +3645 +3650 +3644 +3643 +3644 +3646 +3644 +3660 +3685 +3688 +3684 +3696 +3698 +3702 +3707 +3713 +3725 +3726 +3728 +3729 +3733 +3745 +3739 +3742 +3746 +3747 +3748 +3740 +3735 +3740 +3735 +3750 +3752 +3751 +3731 +3732 +3721 +3724 +3725 +3734 +3735 +3748 +3747 +3749 +3756 +3757 +3756 +3757 +3758 +3748 +3730 +3732 +3725 +3722 +3711 +3710 +3714 +3715 +3712 +3713 +3712 +3713 +3714 +3716 +3717 +3718 +3716 +3715 +3705 +3706 +3713 +3714 +3731 +3759 +3757 +3753 +3764 +3781 +3788 +3790 +3805 +3806 +3809 +3804 +3821 +3825 +3826 +3832 +3799 +3806 +3819 +3820 +3825 +3827 +3830 +3837 +3818 +3807 +3811 +3817 +3821 +3832 +3833 +3821 +3816 +3817 +3819 +3818 +3824 +3836 +3837 +3838 +3855 +3848 +3849 +3857 +3856 +3855 +3868 +3872 +3873 +3878 +3896 +3915 +3918 +3921 +3925 +3920 +3926 +3919 +3920 +3916 +3917 +3923 +3936 +3910 +3908 +3914 +3915 +3925 +3928 +3929 +3930 +3932 +3933 +3934 +3946 +3950 +3952 +3939 +3938 +3947 +3951 +3953 +3954 +3955 +3958 +3963 +3972 +3965 +3976 +3978 +3979 +4008 +4003 +4025 +4028 +4041 +4040 +4041 +4044 +4043 +4057 +4054 +4049 +4050 +4028 +4033 +4014 +4015 +4027 +4028 +4036 +4040 +4035 +4036 +4037 +4040 +4032 +4038 +4037 +4030 +4028 +4032 +4031 +4030 +4048 +4046 +4060 +4059 +4035 +4031 +4033 +4034 +4061 +4051 +4052 +4053 +4047 +4048 +4049 +4051 +4052 +4053 +4061 +4050 +4044 +4046 +4049 +4035 +4037 +4031 +4028 +4027 +4026 +4025 +4023 +4034 +4032 +4035 +4036 +4041 +4038 +4039 +4032 +4036 +4035 +4048 +4068 +4069 +4076 +4097 +4098 +4067 +4074 +4051 +4052 +4055 +4053 +4059 +4074 +4080 +4082 +4084 +4085 +4076 +4077 +4079 +4082 +4089 +4092 +4088 +4092 +4094 +4098 +4096 +4093 +4096 +4104 +4106 +4102 +4111 +4114 +4110 +4111 +4112 +4115 +4114 +4116 +4133 +4153 +4146 +4148 +4127 +4129 +4130 +4135 +4138 +4156 +4165 +4182 +4179 +4193 +4209 +4221 +4222 +4227 +4241 +4243 +4288 +4289 +4287 +4290 +4291 +4320 +4321 +4322 +4324 +4347 +4318 +4325 +4326 +4338 +4333 +4335 +4338 +4344 +4346 +4353 +4347 +4338 +4339 +4300 +4299 +4303 +4302 +4300 +4293 +4308 +4302 +4286 +4287 +4284 +4285 +4286 +4288 +4292 +4279 +4280 +4278 +4280 +4282 +4284 +4293 +4322 +4323 +4338 +4336 +4335 +4338 +4344 +4338 +4336 +4359 +4358 +4360 +4361 +4364 +4366 +4367 +4366 +4367 +4369 +4370 +4373 +4377 +4376 +4394 +4395 +4404 +4409 +4406 +4408 +4436 +4439 +4445 +4433 +4423 +4409 +4438 +4443 +4463 +4475 +4472 +4482 +4487 +4513 +4516 +4514 +4527 +4528 +4538 +4548 +4549 +4547 +4551 +4554 +4547 +4549 +4546 +4548 +4532 +4517 +4525 +4549 +4531 +4526 +4523 +4524 +4545 +4532 +4535 +4532 +4537 +4542 +4543 +4545 +4556 +4561 +4558 +4559 +4576 +4583 +4585 +4591 +4587 +4597 +4616 +4627 +4634 +4645 +4632 +4634 +4640 +4671 +4672 +4674 +4684 +4682 +4692 +4704 +4700 +4689 +4690 +4693 +4694 +4703 +4706 +4692 +4702 +4703 +4707 +4722 +4725 +4727 +4728 +4739 +4742 +4755 +4758 +4753 +4756 +4768 +4774 +4781 +4788 +4789 +4788 +4790 +4791 +4780 +4769 +4775 +4769 +4743 +4746 +4760 +4770 +4771 +4780 +4781 +4770 +4767 +4793 +4790 +4792 +4791 +4794 +4790 +4808 +4814 +4811 +4807 +4808 +4810 +4818 +4826 +4832 +4839 +4842 +4835 +4844 +4865 +4881 +4887 +4891 +4874 +4878 +4860 +4865 +4870 +4869 +4875 +4876 +4877 +4885 +4886 +4911 +4912 +4917 +4918 +4927 +4909 +4913 +4915 +4917 +4928 +4929 +4927 +4928 +4929 +4923 +4922 +4956 +4968 +4965 +4967 +4975 +4976 +4978 +4974 +4990 +5021 +5025 +5029 +5030 +5028 +5030 +5035 +5055 +5038 +5052 +5053 +5069 +5046 +5048 +5052 +5076 +5092 +5111 +5118 +5122 +5133 +5153 +5157 +5162 +5165 +5164 +5163 +5164 +5165 +5160 +5159 +5162 +5164 +5169 +5183 +5175 +5207 +5208 +5187 +5192 +5197 +5194 +5204 +5208 +5213 +5223 +5221 +5236 +5237 +5243 +5248 +5253 +5238 +5220 +5221 +5228 +5226 +5229 +5231 +5228 +5230 +5231 +5224 +5234 +5235 +5237 +5239 +5248 +5250 +5251 +5256 +5270 +5271 +5286 +5282 +5284 +5282 +5276 +5278 +5285 +5303 +5306 +5314 +5315 +5317 +5316 +5317 +5318 +5324 +5325 +5331 +5325 +5355 +5356 +5358 +5348 +5341 +5346 +5351 +5353 +5376 +5370 +5375 +5380 +5384 +5391 +5392 +5408 +5415 +5416 +5417 +5406 +5407 +5410 +5411 +5412 +5416 +5414 +5431 +5433 +5434 +5435 +5460 +5463 +5464 +5476 +5477 +5480 +5481 +5480 +5478 +5479 +5470 +5477 +5473 +5468 +5493 +5496 +5497 +5499 +5501 +5529 +5499 +5511 +5542 +5547 +5548 +5550 +5582 +5581 +5563 +5586 +5590 +5585 +5580 +5608 +5614 +5605 +5598 +5613 +5611 +5616 +5646 +5653 +5662 +5660 +5665 +5673 +5675 +5682 +5681 +5683 +5701 +5711 +5710 +5711 +5713 +5715 +5726 +5737 +5733 +5737 +5751 +5752 +5747 +5732 +5736 +5738 +5739 +5735 +5736 +5739 +5741 +5744 +5760 +5763 +5755 +5760 +5765 +5767 +5772 +5776 +5777 +5779 +5760 +5755 +5760 +5777 +5781 +5763 +5750 +5758 +5753 +5765 +5767 +5769 +5802 +5793 +5797 +5794 +5792 +5791 +5792 +5806 +5812 +5813 +5814 +5815 +5814 +5818 +5836 +5841 +5848 +5854 +5857 +5887 +5888 +5885 +5886 +5884 +5883 +5887 +5894 +5895 +5896 +5893 +5892 +5907 +5906 +5940 +5937 +5947 +5949 +5947 +5940 +5939 +5956 +5959 +5961 +5972 +5979 +5981 +5982 +5977 +5978 +5963 +5965 +5966 +5972 +5973 +5974 +5977 +5980 +5986 +5987 +5967 +5979 +5980 +5983 +5987 +5989 +6007 +6018 +6017 +6018 +6019 +6018 +6020 +6021 +6035 +6036 +6042 +6049 +6060 +6056 +6054 +6052 +6051 +6050 +6063 +6064 +6055 +6061 +6063 +6062 +6064 +6077 +6088 +6108 +6129 +6131 +6133 +6137 +6136 +6151 +6153 +6158 +6173 +6176 +6181 +6197 +6200 +6202 +6204 +6209 +6200 +6199 +6186 +6210 +6218 +6219 +6229 +6240 +6252 +6247 +6249 +6250 +6253 +6254 +6280 +6283 +6292 +6293 +6300 +6301 +6302 +6305 +6307 +6321 +6322 +6327 +6326 +6327 +6339 +6342 +6328 +6329 +6327 +6316 +6317 +6323 +6332 +6344 +6374 +6395 +6398 +6396 +6412 +6421 +6424 +6445 +6451 +6453 +6454 +6459 +6460 +6461 +6471 +6467 +6447 +6449 +6458 +6460 +6463 +6464 +6468 +6503 +6504 +6505 +6498 +6499 +6502 +6490 +6495 +6527 +6529 +6533 +6529 +6539 +6547 +6560 +6561 +6551 +6563 +6567 +6563 +6589 +6585 +6588 +6564 +6569 +6563 +6591 +6601 +6632 diff --git a/2021/02/02.exs b/2021/02/02.exs new file mode 100644 index 0000000..a3eaa6d --- /dev/null +++ b/2021/02/02.exs @@ -0,0 +1,35 @@ +lines = File.stream!("input.txt") + |> Stream.map(&String.trim/1) + |> Stream.map(&(String.split(&1, " ", trim: true))) + |> Stream.map(fn [dir, val] -> [dir, String.to_integer(val)] end) + |> Enum.to_list + +# Part 1 +result = lines + |> Enum.reduce( + {0, 0}, + fn line, {position, depth} -> + case line do + ["forward", value] -> {position + value, depth} + ["down", value] -> {position, depth + value} + ["up", value] -> {position, depth - value} + end + end + ) + +IO.puts(elem(result, 0) * elem(result, 1)) + +# Part 2 +result = lines + |> Enum.reduce( + {0, 0, 0}, + fn line, {position, depth, aim} -> + case line do + ["forward", value] -> {position + value, depth + (aim * value), aim} + ["down", value] -> {position, depth, aim + value} + ["up", value] -> {position, depth, aim - value} + end + end + ) + +IO.puts(elem(result, 0) * elem(result, 1)) diff --git a/2021/02/input.txt b/2021/02/input.txt new file mode 100644 index 0000000..b71a00f --- /dev/null +++ b/2021/02/input.txt @@ -0,0 +1,1000 @@ +forward 3 +down 7 +forward 7 +down 4 +down 9 +down 7 +forward 5 +forward 9 +forward 3 +forward 8 +down 4 +down 6 +down 3 +forward 7 +forward 1 +forward 4 +down 1 +forward 7 +forward 9 +down 3 +down 1 +down 5 +forward 8 +down 2 +down 9 +forward 3 +down 9 +down 7 +down 6 +down 1 +forward 4 +forward 9 +forward 8 +down 3 +down 9 +down 5 +forward 5 +down 7 +down 7 +up 1 +down 2 +up 1 +down 7 +up 1 +up 1 +down 8 +down 8 +forward 2 +down 5 +forward 9 +forward 8 +forward 4 +up 2 +down 9 +down 7 +forward 4 +up 7 +up 4 +down 4 +down 3 +forward 8 +down 8 +up 2 +up 1 +forward 3 +up 6 +up 8 +down 5 +down 4 +down 4 +forward 1 +down 8 +forward 3 +forward 5 +forward 4 +forward 2 +forward 7 +up 5 +up 2 +forward 2 +forward 5 +down 4 +up 6 +forward 3 +forward 1 +forward 1 +forward 6 +forward 7 +forward 1 +forward 8 +forward 4 +forward 4 +forward 8 +down 6 +down 8 +forward 4 +forward 1 +down 8 +forward 3 +forward 3 +forward 9 +forward 9 +forward 3 +up 1 +down 2 +down 5 +forward 4 +forward 5 +forward 7 +forward 4 +forward 4 +up 5 +forward 1 +down 9 +down 9 +down 1 +up 7 +down 8 +up 6 +down 4 +forward 7 +down 8 +down 1 +forward 4 +forward 5 +forward 9 +down 2 +forward 7 +forward 7 +up 2 +up 1 +forward 9 +forward 1 +forward 7 +up 3 +forward 8 +forward 1 +down 6 +down 6 +down 4 +forward 2 +forward 1 +down 3 +down 4 +down 2 +forward 9 +up 8 +down 4 +down 3 +down 1 +down 1 +forward 6 +forward 6 +down 7 +forward 1 +forward 5 +forward 9 +forward 5 +forward 1 +up 8 +forward 7 +up 3 +forward 6 +down 5 +up 8 +down 4 +down 8 +forward 2 +up 7 +forward 9 +down 9 +forward 1 +down 5 +forward 8 +down 7 +forward 8 +forward 1 +forward 5 +down 4 +down 1 +forward 4 +up 6 +down 3 +down 1 +forward 1 +forward 1 +up 8 +down 9 +forward 8 +forward 5 +down 5 +forward 1 +up 9 +down 6 +down 4 +up 2 +forward 5 +down 7 +up 1 +forward 3 +up 5 +forward 9 +up 6 +down 4 +forward 6 +down 8 +down 2 +forward 3 +forward 4 +down 5 +down 7 +down 4 +up 3 +up 8 +down 8 +up 8 +down 8 +forward 8 +down 3 +up 3 +forward 8 +down 6 +forward 2 +down 8 +down 5 +up 2 +forward 1 +forward 4 +down 1 +forward 5 +forward 5 +forward 2 +forward 2 +forward 4 +down 7 +forward 6 +up 6 +down 8 +forward 4 +forward 6 +forward 2 +down 8 +down 2 +up 1 +down 8 +forward 9 +up 5 +forward 8 +up 9 +down 1 +down 2 +forward 6 +down 9 +forward 3 +up 8 +up 4 +down 8 +forward 2 +down 1 +forward 6 +forward 4 +down 4 +forward 4 +up 8 +down 6 +forward 3 +up 2 +up 6 +down 1 +down 3 +down 1 +up 6 +down 9 +up 6 +forward 9 +down 4 +forward 3 +forward 1 +up 7 +down 1 +forward 5 +up 1 +up 8 +forward 5 +down 5 +forward 2 +up 8 +up 7 +forward 4 +up 7 +up 4 +forward 5 +forward 3 +down 9 +forward 1 +down 8 +forward 3 +up 3 +down 7 +forward 4 +down 7 +down 5 +down 8 +down 8 +forward 6 +forward 5 +up 4 +down 6 +forward 4 +up 2 +up 4 +down 4 +down 9 +forward 7 +down 8 +forward 6 +forward 5 +up 8 +down 6 +forward 1 +up 2 +forward 5 +forward 7 +down 4 +down 6 +forward 9 +forward 2 +up 6 +up 6 +forward 1 +up 6 +forward 8 +down 7 +forward 1 +down 1 +up 9 +up 1 +forward 1 +forward 7 +forward 5 +down 4 +forward 6 +forward 4 +down 8 +up 6 +up 8 +forward 6 +forward 3 +up 6 +forward 6 +down 8 +down 5 +down 5 +down 2 +down 6 +forward 1 +forward 4 +forward 5 +down 5 +forward 6 +forward 2 +forward 2 +up 7 +up 6 +up 7 +forward 7 +forward 6 +down 7 +down 7 +up 4 +forward 5 +forward 2 +down 6 +up 4 +forward 8 +down 1 +down 5 +up 6 +down 4 +down 3 +down 8 +forward 8 +down 9 +forward 8 +forward 6 +down 4 +down 3 +forward 6 +up 4 +up 9 +forward 3 +down 3 +down 9 +forward 1 +down 7 +forward 2 +up 7 +down 6 +forward 5 +down 8 +down 1 +forward 8 +down 4 +up 3 +down 5 +forward 6 +down 7 +forward 3 +forward 6 +forward 8 +forward 6 +down 4 +down 6 +forward 9 +up 8 +forward 2 +forward 8 +forward 1 +forward 1 +forward 3 +forward 8 +forward 6 +forward 8 +down 5 +down 2 +down 6 +up 4 +forward 5 +forward 9 +forward 1 +down 3 +down 6 +down 7 +forward 5 +forward 8 +up 1 +forward 4 +up 3 +forward 6 +down 3 +down 7 +down 1 +down 1 +forward 8 +forward 3 +forward 2 +forward 1 +forward 3 +forward 7 +up 6 +down 8 +forward 3 +forward 8 +forward 1 +forward 4 +up 3 +down 7 +up 9 +up 6 +forward 1 +forward 6 +forward 5 +down 5 +down 2 +forward 8 +up 8 +down 4 +forward 6 +down 2 +forward 1 +down 8 +forward 2 +forward 9 +forward 1 +down 9 +down 1 +down 9 +down 1 +up 9 +forward 3 +forward 7 +forward 3 +down 5 +up 3 +forward 4 +up 1 +forward 2 +down 8 +forward 8 +down 1 +up 9 +down 7 +forward 9 +up 6 +down 3 +forward 9 +down 2 +down 3 +up 5 +up 5 +forward 8 +down 2 +forward 2 +up 3 +down 8 +down 1 +down 9 +forward 5 +down 5 +down 5 +down 4 +down 8 +forward 7 +up 3 +up 4 +up 4 +up 7 +down 2 +down 6 +up 3 +down 9 +up 2 +forward 6 +forward 1 +down 7 +down 5 +forward 6 +down 6 +up 4 +down 4 +down 8 +up 5 +forward 9 +down 8 +forward 1 +forward 2 +forward 8 +forward 2 +forward 3 +up 9 +up 8 +up 9 +up 6 +down 5 +forward 7 +up 8 +forward 1 +down 3 +down 8 +forward 3 +up 6 +down 2 +forward 2 +up 4 +up 4 +forward 6 +forward 1 +forward 4 +down 3 +down 1 +up 7 +down 9 +up 1 +down 9 +down 4 +up 2 +forward 8 +down 3 +forward 7 +up 6 +forward 7 +up 2 +forward 5 +down 3 +up 2 +down 3 +down 8 +forward 5 +down 8 +forward 7 +up 6 +down 4 +forward 4 +down 1 +up 3 +forward 6 +down 1 +down 2 +down 2 +forward 7 +down 6 +down 2 +forward 9 +down 2 +forward 2 +down 2 +forward 6 +down 9 +up 4 +up 7 +up 6 +down 3 +forward 3 +down 7 +down 6 +forward 8 +down 4 +up 3 +down 1 +forward 8 +down 4 +forward 5 +forward 1 +down 7 +forward 5 +up 3 +down 7 +forward 3 +down 4 +up 1 +down 5 +forward 8 +down 2 +forward 9 +forward 3 +up 2 +down 9 +forward 5 +up 7 +down 7 +down 1 +down 7 +down 8 +forward 1 +down 9 +down 7 +forward 4 +down 5 +forward 9 +down 6 +down 1 +forward 2 +up 4 +up 3 +down 1 +forward 4 +up 3 +forward 4 +up 2 +forward 6 +down 6 +up 8 +down 3 +forward 5 +down 2 +forward 9 +down 3 +down 7 +forward 4 +down 5 +up 9 +up 9 +down 4 +up 5 +forward 1 +down 8 +up 8 +up 4 +up 2 +up 8 +forward 5 +down 5 +up 1 +down 6 +down 3 +up 4 +forward 3 +forward 1 +forward 1 +up 4 +forward 1 +down 6 +forward 7 +forward 4 +forward 4 +forward 9 +forward 6 +down 6 +forward 4 +up 7 +down 5 +down 2 +forward 3 +down 7 +forward 8 +down 7 +forward 4 +up 9 +down 1 +forward 3 +forward 1 +forward 4 +down 2 +up 2 +down 1 +down 4 +down 7 +forward 5 +forward 3 +up 5 +forward 1 +down 4 +down 8 +up 4 +up 1 +down 1 +down 4 +down 2 +down 4 +up 8 +down 3 +forward 8 +up 5 +down 4 +forward 9 +forward 7 +down 4 +forward 7 +forward 9 +forward 6 +forward 9 +up 9 +down 3 +up 4 +down 8 +forward 9 +up 2 +up 3 +forward 8 +forward 3 +forward 1 +forward 7 +forward 8 +forward 9 +down 7 +forward 3 +forward 3 +forward 4 +up 8 +forward 1 +forward 5 +up 9 +down 2 +down 7 +forward 5 +up 4 +forward 9 +down 9 +up 2 +forward 7 +down 9 +up 8 +up 1 +up 1 +up 5 +forward 4 +down 2 +forward 7 +down 1 +down 8 +down 8 +forward 3 +forward 8 +up 9 +forward 7 +forward 6 +forward 3 +forward 7 +up 3 +up 6 +forward 5 +forward 5 +down 2 +down 7 +down 7 +up 7 +forward 6 +forward 1 +forward 7 +up 6 +down 9 +forward 7 +forward 1 +up 7 +forward 4 +forward 9 +up 2 +down 5 +down 6 +down 4 +forward 1 +forward 7 +forward 4 +forward 5 +down 2 +forward 5 +down 9 +forward 7 +forward 4 +up 5 +down 6 +forward 2 +forward 4 +forward 8 +up 1 +down 2 +up 9 +forward 6 +down 1 +forward 6 +forward 4 +down 6 +forward 6 +up 4 +down 5 +forward 8 +down 3 +up 4 +forward 3 +down 6 +up 7 +down 8 +down 5 +down 7 +forward 4 +down 1 +forward 5 +up 9 +up 3 +down 4 +forward 9 +forward 6 +forward 1 +up 5 +down 5 +forward 1 +forward 6 +down 4 +up 7 +forward 5 +down 5 +forward 1 +forward 5 +down 4 +forward 6 +down 6 +down 5 +down 5 +forward 4 +down 5 +forward 2 +down 9 +down 6 +down 5 +forward 5 +down 9 +down 7 +up 8 +down 3 +forward 6 +down 4 +forward 8 +forward 9 +down 1 +up 3 +forward 4 +up 3 +forward 7 +down 5 +up 8 +forward 1 +up 1 +down 2 +forward 1 +up 9 +down 4 +forward 1 +up 3 +down 9 +up 8 +down 2 +up 4 +forward 2 +forward 8 +up 8 +forward 9 +forward 2 +down 4 +forward 8 +down 4 +forward 9 +down 1 +up 8 +forward 6 +down 4 +down 8 +forward 1 +forward 1 +forward 5 +forward 9 +up 4 +down 7 +forward 4 +down 5 +forward 1 +down 4 +up 8 +up 4 +forward 2 +forward 9 +down 8 +down 3 +down 2 +up 3 +down 1 +down 8 +forward 5 +down 6 +down 5 +forward 8 +down 8 +down 1 +forward 1 +forward 3 +forward 7 +forward 1 +up 2 +up 3 +forward 9 +down 2 +forward 5 +down 8 +forward 7 +forward 3 +up 5 +forward 1 +forward 1 +up 8 +down 1 +down 2 +down 7 +down 1 +down 9 +forward 7 +down 8 +down 4 +up 8 +forward 1 +down 6 +forward 9 +forward 7 +up 2 +forward 3 +forward 2 +up 3 +up 6 +up 1 +down 1 +up 9 +forward 8 +forward 6 +down 6 +up 8 +down 8 +forward 5 +forward 7 +down 7 +forward 3 +forward 9 +down 8 +down 8 +forward 2 +up 7 +down 4 +down 7 +up 6 +down 3 +forward 1 +forward 8 +down 5 +down 6 +up 5 +forward 8 +forward 6 +up 8 +forward 8 +up 3 +up 6 +up 3 +forward 1 diff --git a/2021/03/03.exs b/2021/03/03.exs new file mode 100644 index 0000000..c1033a6 --- /dev/null +++ b/2021/03/03.exs @@ -0,0 +1,114 @@ +use Bitwise + +lines = File.stream!("input.txt") + |> Stream.map(&String.trim/1) + |> Enum.to_list + +# Utilities +defmodule Utils do + def more_frequent(frequencies) do + cond do + frequencies[0] == nil -> + "1" + frequencies[1] == nil -> + "0" + frequencies[0] > frequencies[1] -> + "0" + true -> + "1" + end + end + + def less_frequent(frequencies) do + cond do + frequencies[0] == nil -> + "1" + frequencies[1] == nil -> + "0" + frequencies[0] > frequencies[1] -> + "1" + true -> + "0" + end + end + + def most_frequent_at(data, position) do + data + |> Enum.map(fn line -> String.at(line, position) end) + |> Enum.map(fn char -> String.to_integer(char) end) + |> Enum.frequencies + |> Utils.more_frequent + end + + def least_frequent_at(data, position) do + data + |> Enum.map(fn line -> String.at(line, position) end) + |> Enum.map(fn char -> String.to_integer(char) end) + |> Enum.frequencies + |> Utils.less_frequent + end + + def filter_by_char(data, char, position) do + data + |> Enum.filter(fn line -> String.at(line, position) == char end) + end + + def filter_by_freq(data, position, line_length, comparison_fn) do + if position > line_length do + data + else + char = comparison_fn.(data, position) + + data + |> Utils.filter_by_char(char, position) + |> Utils.filter_by_freq(position + 1, line_length, comparison_fn) + end + end +end + +# Part 1 +line_length = List.first(lines) + |> String.length + +binary_frequencies = + for i <- 0..(line_length - 1) do + lines + |> Enum.map(fn line -> String.at(line, i) end) + |> Enum.map(fn char -> String.to_integer(char) end) + |> Enum.frequencies + end + +gamma_rate = binary_frequencies + |> Enum.map(fn tuple -> Utils.more_frequent(tuple) end) + |> Enum.join + |> String.to_integer(2) + +epsilon = binary_frequencies + |> Enum.map(fn tuple -> Utils.less_frequent(tuple) end) + |> Enum.join + |> String.to_integer(2) + +power_consumption = gamma_rate * epsilon + +IO.puts("---- PART 1 ----") +IO.puts("Gamma rate: #{gamma_rate}") +IO.puts("Epsilon: #{epsilon}") +IO.puts("Power consumption: #{power_consumption}") + +# Part 2 +oxygen_rating = Utils.filter_by_freq(lines, 0, line_length - 1, &Utils.most_frequent_at/2) + |> List.first + |> String.to_integer(2) + +co2_subscriber_rating = Utils.filter_by_freq(lines, 0, line_length - 1, &Utils.least_frequent_at/2) + |> List.first + |> String.to_integer(2) + +life_support_rating = oxygen_rating * co2_subscriber_rating + +IO.puts("\n---- PART 2 ----") +IO.puts("O2 rating: #{oxygen_rating}") +IO.puts("C02 rating: #{co2_subscriber_rating}") +IO.puts("Life support rating: #{life_support_rating}") + + diff --git a/2021/03/input.txt b/2021/03/input.txt new file mode 100644 index 0000000..f398604 --- /dev/null +++ b/2021/03/input.txt @@ -0,0 +1,1000 @@ +010111111011 +010010101110 +011001001100 +001000001010 +111100101000 +111010101100 +000111101111 +010011010011 +100010111011 +101011000111 +100111101010 +101101101101 +110010110110 +100110011100 +001110011000 +011000101010 +001100111101 +100011101111 +100111011001 +011100101101 +111101000111 +111000101011 +001001000101 +010110011000 +110100100001 +010010010011 +100100100100 +011011001000 +111101011101 +101011110011 +110011101101 +001001000100 +100111101110 +101101101010 +111110101000 +111011011001 +111110101101 +110101010100 +011100110000 +000010111110 +111011111111 +010111111110 +101001110101 +001111010100 +001111110001 +000010000000 +010001101000 +100001001111 +101111000010 +000011110001 +110111101110 +000000100111 +010100000111 +011111100001 +100011110001 +101000001111 +101010111001 +001101100100 +001100111001 +001000011010 +001001111100 +011001011001 +101011001010 +100101101101 +000101011110 +101100110111 +011000010110 +110101000110 +011010100101 +110011100110 +111101000010 +111110101011 +110101100101 +101110101010 +100110001011 +000110101100 +010100001001 +010011001110 +101010010101 +101010000101 +100100001011 +010010100101 +011000111111 +001010000001 +000001100111 +010101101111 +101110000110 +100101001001 +010000101001 +001101011001 +011101111110 +011110011100 +110100110111 +000101011010 +100000010011 +011100111000 +001110101000 +001001001000 +110101011101 +000011001111 +101000011010 +100011110010 +100100010111 +110001010100 +111010100110 +101001010100 +110100111101 +111000010111 +010001111000 +000101010110 +010100000100 +001000110010 +100111001100 +111001000100 +011100001011 +100110001010 +000010100111 +001010111110 +101100110001 +010100100001 +011001110010 +010011100101 +011111010110 +111000010010 +011110110101 +110101101100 +101010110110 +000111000001 +001111111101 +110011101010 +011000110010 +101110101011 +110100001100 +001000011000 +110110110010 +101111000111 +000111111001 +111100110100 +010010011010 +010010111010 +000001101000 +000101010101 +110111110101 +111001110110 +110011001100 +011110011001 +000010110101 +011011000111 +010101010110 +001011010100 +100001111001 +011000111010 +011100010000 +110001011010 +110010110111 +001101010101 +000110011000 +000010011110 +101100111001 +100011001110 +100010000000 +001111010001 +011100010011 +010001000010 +110010010111 +011011111101 +010011010100 +100001101001 +101100110110 +000000101011 +111000110111 +111101010110 +111110000000 +101010000111 +011010110110 +100110100111 +001011001011 +110011111000 +010111100110 +001100101010 +110001001000 +000100000111 +000001011100 +000100000000 +100010100000 +110001011011 +110110111101 +100110010001 +001101001110 +011111011000 +110010000100 +100011010110 +011001100000 +010101001110 +111100000001 +110100010111 +000001000011 +101100010011 +000100011111 +111000001001 +101100011100 +010110010001 +000110000010 +110000101111 +011010011100 +111000011110 +100110110001 +100000011100 +101010001011 +010111001100 +100111110111 +111100001011 +010100100100 +100111100101 +111100000111 +101001001101 +111001111000 +001110010100 +111010011001 +010100111111 +110111010011 +100100000001 +001101111111 +111101001100 +000111101010 +000100101001 +111011011101 +010001110111 +111010100001 +001101010100 +101010011100 +000011100100 +100101101010 +011111100000 +011011001110 +000101000111 +010010111111 +001100111011 +000001101001 +001110110001 +010011011110 +001011011000 +100000111010 +001000100101 +010001100011 +011001000111 +010110101010 +101000001001 +110101011000 +001100000101 +100110011001 +000011001001 +100110111001 +111101101001 +011011001001 +010001100111 +001100011100 +011111101111 +100100111010 +101111110011 +110111001110 +000111100000 +011110000101 +111110100010 +001011001101 +110100101011 +011100001101 +111001111100 +111110100110 +000010010100 +010111110010 +001110001101 +011111010011 +110110111010 +101001110000 +011110110011 +000111011000 +010111000110 +001011100010 +001110000010 +010111000011 +010011111110 +011000010000 +101111011110 +101010000110 +011100011101 +011101101100 +100110101001 +000000011001 +100101010010 +110011010101 +010100100111 +011101011100 +011001111001 +000001001000 +001000101011 +010110111101 +100110010010 +010010010110 +000000111001 +011111110101 +011111001000 +100100011111 +000001111000 +111101010010 +101010100100 +011010111101 +000001011011 +101111100001 +100011000000 +110011001010 +000100010111 +100000010000 +101111010110 +010010010001 +101011100001 +101001011100 +001111000011 +111000100010 +001101110110 +001110111011 +100001110010 +000001110001 +111100001000 +100010011101 +000011000110 +111100100110 +000111110111 +000100111001 +011001110001 +111101010001 +110110101100 +010001011001 +001101111110 +000101111010 +110100100110 +111011001110 +110011010100 +010000100011 +011000111001 +110001110001 +101000000001 +101011000101 +011010000110 +000010111000 +010011100011 +111101101110 +001111010010 +100011011100 +111110111010 +000010110010 +101000011100 +010011101011 +110001011000 +000000010011 +001101010010 +110111111011 +111101011100 +111001010011 +110111100101 +111000111001 +001110010010 +001011101101 +110100100111 +101011100000 +011000100101 +110101010010 +000110000111 +111111001000 +000011100110 +101101110011 +001110011111 +110000101110 +110011100101 +101110100101 +001000111000 +101111000011 +100111111011 +011010101111 +101101001000 +000101101110 +111101000011 +000011000010 +000101010010 +101001011101 +110011010011 +111010010001 +110100010001 +010100001010 +110111101010 +100111000101 +101001100010 +011010011011 +101011101101 +011001100001 +001000110111 +000100101000 +010000000111 +111111110000 +001011110110 +100010010001 +100110101111 +110110010000 +100110011011 +001100110101 +100011101100 +000011011001 +010110100001 +011110101111 +101011011000 +101110111001 +111000010000 +011100000010 +100110100101 +010101011111 +100000111001 +011000111100 +101100100111 +101011111000 +111101111101 +101000100011 +101000010101 +111001010010 +101110000111 +101010000001 +000100100111 +100001011101 +110010101010 +000000100100 +011101000101 +110010001101 +111011101110 +111111111110 +011100000111 +101111110010 +000101100110 +000110001011 +100100011000 +010001101111 +011110010000 +100011011111 +010101101010 +000011100000 +000101001110 +001001110001 +111110011001 +101110000000 +010001010010 +110001000110 +101011001110 +010001101001 +000000011011 +101001010011 +011010000100 +001100001100 +100010001001 +100000111111 +001000000000 +100110110100 +100111110000 +101001110001 +000110101101 +000111001010 +101100011011 +110001101000 +000111101110 +110110010011 +100010001000 +001010001100 +001011111110 +001110000111 +110010100000 +100001110101 +000110111101 +110010011000 +111110111011 +101000000011 +011010011110 +110000001111 +011000110100 +111111001101 +000010110100 +101100001100 +110000101011 +010000001110 +101001101000 +011000000100 +101101011000 +100111111100 +110001001010 +001010101100 +111010001110 +101110100110 +011110010001 +111011111010 +000001100110 +010001100101 +100101001111 +111001001011 +111101101010 +011011000001 +010111010101 +110001111110 +110100101110 +111101011011 +011000101011 +010100111100 +011000000111 +101000101001 +111000110001 +101000110001 +001111010011 +100000010100 +001001101101 +010101110001 +100110000101 +011000101101 +001110110010 +100111000001 +011001000001 +000101101000 +101000101110 +000100001110 +111110101111 +011110110001 +101001110010 +000000111010 +101111010010 +011110011010 +101000011111 +000100001100 +110001111001 +110000110101 +111010011100 +001000111011 +111110001111 +011011011000 +000110110001 +101001010010 +111010100011 +000001111100 +110010000001 +110101111011 +100011001001 +010011100001 +101101011111 +100000001010 +001011001000 +000011100010 +011110111000 +000110111011 +010111001011 +011100011000 +101010011011 +001001011110 +000110001010 +111011010101 +010101110010 +011100101001 +100000110010 +111100111001 +001011011101 +110101101001 +001000111110 +101011000011 +001110111111 +100101010110 +111011011110 +010111111001 +011001010001 +110101111111 +110100100101 +111111110001 +010011000101 +011101101010 +101111000100 +011101000100 +001110110110 +010011011000 +000011011010 +110000000110 +001100001101 +111001111001 +100001100101 +100100010011 +111011111000 +001001111110 +101101000000 +000001100001 +001100001011 +110011011111 +010101111110 +001110011100 +111111000100 +010011000010 +101100010000 +000010110111 +110100000101 +110100010010 +111001100101 +010000010001 +101100100110 +001111101100 +011100110110 +000000111101 +001000000100 +010101101101 +100101101000 +001001010101 +000000001111 +110111110100 +000010110110 +001000000010 +011000101000 +100101001101 +010110101110 +100010110001 +010111010000 +001111011001 +000011110100 +100100111000 +011011100110 +100100010110 +000001111101 +010111011011 +110001000101 +111100010001 +101001000111 +110100010000 +001010000111 +101001110111 +010010010010 +100010111100 +001101000011 +011001110011 +000100101111 +010110011101 +001001011010 +111011101001 +111111000000 +111110000111 +110000001011 +010000110010 +011100011001 +011001100011 +001101000110 +011001011111 +100111100000 +110111010100 +101101000001 +110011101000 +001010110101 +100101010001 +101000101100 +010110001000 +111011111011 +000010010001 +010111011010 +011101101011 +001000101110 +101010100111 +001011000111 +011011010110 +110111101111 +100001110001 +100100101111 +110000010011 +011110111011 +000110000100 +110000111111 +100110101100 +001101110101 +011100000100 +001100011110 +010111010010 +001110101101 +100110001110 +100100010000 +001000001101 +011101110011 +011001100110 +110101000011 +100101001010 +111111101111 +010011000100 +100111000111 +101100101100 +010110000100 +111100000100 +000000101001 +000011110010 +011011110111 +011101110001 +111110000001 +011000011001 +100001101111 +110000011010 +110110101010 +110100110000 +111111000011 +100011100010 +100100010010 +110100011000 +000110000110 +001101001000 +101011110111 +000011110111 +001001100100 +100010110011 +100111111000 +000001111010 +110001111101 +100011111111 +111001001101 +011111101011 +101111110111 +100111000011 +010010001010 +010101101011 +011011110000 +110111000000 +010011101111 +010001010101 +111110101010 +001010101010 +001100101101 +111011000111 +101001000001 +000101000100 +010011110010 +001110100010 +110111001000 +111011001101 +111110001010 +110000100001 +000000010101 +000010011001 +011100100111 +001101111010 +000001100100 +011111101100 +110100011111 +010110000000 +001010101001 +000010010011 +111100000110 +110101000101 +010110001011 +111001001000 +010110101111 +001000000001 +111100001101 +001000110110 +110001101001 +001110001011 +111101101011 +011101111100 +100011001011 +001000001001 +000001001100 +100100110111 +111111101101 +001110100000 +001001001001 +001111001100 +101100101111 +101100110010 +101000100001 +101000010110 +100000010101 +011010011000 +101101101110 +011101001100 +101011111100 +101110101000 +110010100100 +011111011110 +110010011101 +110100100011 +111111100100 +011011011101 +011100100001 +101011110000 +001100100011 +000111111000 +110010001010 +100001001001 +110010001000 +111010001001 +010110111111 +101011001101 +101010011110 +011011110001 +101010100011 +100000110111 +100011101001 +101110010011 +101011011011 +110010010000 +011110100011 +010010110110 +100110010111 +110100000110 +101011101011 +001100010100 +101101010000 +110110001001 +010010001101 +111011010110 +111100001110 +000101111001 +100001000001 +101111101001 +100101101110 +000011001101 +000001000110 +111110001011 +000010101111 +011101101101 +000000000110 +111111101010 +101001110110 +111011000100 +001011101111 +110010111010 +110011110001 +111100011111 +110110010001 +100101110000 +010001001011 +101100010100 +110100001010 +001011101001 +110110000001 +001101001001 +100000111100 +001101101010 +010000110011 +011111101110 +110001110011 +011110011000 +000010001010 +001110000100 +000110101111 +100011111000 +100101100010 +111111110010 +101100011001 +011100100000 +100001100011 +001010011110 +111100011010 +010110100010 +101110010010 +001011110010 +100010111000 +001100110010 +001001101001 +011111101101 +101100111100 +011010011101 +101011100100 +111000001000 +010111011100 +001010000000 +011110000110 +110101101110 +000111000101 +101001011010 +110010100010 +100101110010 +000101100100 +010100110010 +011001000010 +110010011010 +010100001011 +011001111110 +011000101001 +011101011011 +010010000111 +000001110111 +100010101001 +111100011101 +100010001011 +111100101100 +011111010101 +111100101110 +111101001110 +111000010110 +000000110110 +011110000001 +000111011110 +111010111010 +101010001101 +111110101100 +000111110010 +110000111101 +111101110101 +101010101100 +101110110010 +110110011010 +111110110001 +011101111011 +101011111011 +100111101101 +000110011001 +100101101011 +110101101101 +010111110100 +001111110010 +101010101000 +011001100100 +101011111111 +001001000001 +010100100110 +111100011100 +011100011010 +000011011110 +001011101010 +010010001110 +101101101111 +000101000010 +010111100010 +010010010000 +111000000101 +010001100010 +101100001111 +011110111100 +100011000010 +010100001111 +011100101110 +011000111110 +111101010000 +110100111000 +001010001111 +111100011011 +101000111110 +100000011011 +010110000001 +001111100111 +001111101111 +011001011100 +111001000011 +110011101111 +001101100011 +101100111111 +011111101010 +010000011110 +001111111111 +010001001001 +111010101000 +110100001001 +111111010111 +000101110100 +101101100000 +001101100001 +001111111000 +100111101001 +000110010001 +100011101011 +000010000101 +101010001100 +000111110011 +001010110001 +111110001110 +010011100010 +100011010000 +100001010010 +100011000101 +110011000100 +010000010000 +110100110011 +100011000111 +010111101010 +101011000010 +110000101100 +111100001111 +000110100001 +010010110001 +111000100110 +000110111110 +100101000000 +011101001010 +101111011011 +111011101111 +000000010100 +110011101110 +111001110111 +011111000111 +111111011100 +110010011111 +111111110111 +001110110011 +000010010010 +100100100001 +111010000101 +001001110011 +101001101111 +101110101110 +101000101111 diff --git a/2021/03/test.txt b/2021/03/test.txt new file mode 100644 index 0000000..665fd57 --- /dev/null +++ b/2021/03/test.txt @@ -0,0 +1,12 @@ +00100 +11110 +10110 +10111 +10101 +01111 +00111 +11100 +10000 +11001 +00010 +01010 \ No newline at end of file diff --git a/README.md b/README.md index 037187e..07c692f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Some editions were finished later, or even done in a different time (for example | [2015](2015) | [Go][lang-go] | Day 12 part 2 done using JavaScript. | | [2016](2016) | [C#][lang-c#] | | | [2017](2017) | [Python][lang-python] | | +| [2021](2021) | [Elixir][lang-elixir] | Why have i chosen Elixir... | | [2022](2022) | [TypeScript][lang-ts] | With some help from [Radash][lib-radash] and [Ramda][lib-ramda] | | [2023](2023) | [TypeScript][lang-ts] | With some help from [Radash][lib-radash] and [Ramda][lib-ramda] |