From b60e991f6de4b24db7a6e9c6ea9323054b4cd35c Mon Sep 17 00:00:00 2001 From: Ashhhleyyy Date: Thu, 1 Dec 2022 09:43:59 +0000 Subject: [PATCH] feat: day 1 --- inputs/1.txt | 2244 ++++++++++++++++++++++++++++++++++++++++++++++ src/bin/day_1.rs | 35 + 2 files changed, 2279 insertions(+) create mode 100644 inputs/1.txt create mode 100644 src/bin/day_1.rs diff --git a/inputs/1.txt b/inputs/1.txt new file mode 100644 index 0000000..29d80bf --- /dev/null +++ b/inputs/1.txt @@ -0,0 +1,2244 @@ +5474 +4920 +5381 +8650 +11617 +7193 +8161 + +10747 +5855 +13827 +6294 +13437 +8125 + +6913 +6443 +3431 +5357 +1579 +3590 +4471 +4971 +4055 +4937 +2514 +1679 +2917 + +4203 +4433 +8798 +5838 +2031 +8765 +5107 +6055 +2482 +6266 + +4646 +4705 +5183 +1707 +3676 +2042 +4140 +3321 +1899 +3055 +3327 +3944 +3879 +2981 + +59238 + +11748 +22005 + +6389 +4630 +1443 +14530 +9588 + +10578 +8843 +10344 +6289 +10444 +7615 +9510 + +9351 +3942 +5896 +4692 +10110 +4125 +1161 +8261 + +22239 + +5485 +1528 +1288 +4749 +3742 +5861 +2418 +5901 +5201 +1695 +4640 +4609 +3717 +5597 +4183 + +6675 +4543 +3795 +2873 +6364 +2320 +4087 +5536 +7235 +2206 +6179 +4316 + +2755 +6991 +3129 +7988 +3124 +4657 +6947 +4511 +3345 +4043 +6322 + +8053 +5068 +3647 +8695 +6724 +8679 +6974 +4379 +6785 + +7345 +3825 +3850 +4237 +2168 +5866 +2329 +3006 +2966 +3778 +1635 +4083 + +8997 +7386 +3721 +6526 +9222 +2248 +1079 +4470 +2870 + +3780 +4795 +6084 +3682 +4147 +4840 +1603 +3949 +7023 +3175 + +3438 +2545 +2816 +6367 +6068 +1782 +2026 +5115 +5648 +5239 +3530 +5553 +3809 +1891 + +6970 +4195 +3109 +3953 +9504 +5121 +6159 +3932 + +5045 +22725 + +2633 +6392 +4433 +4789 +4593 +3043 +2935 +6540 +7966 +6176 +7759 + +6551 +7220 +2325 +6230 +2058 +6931 +7107 +3393 +4448 +2157 +7172 +2699 + +43804 + +9649 + +4126 +3911 +4619 +13049 + +4094 +5564 +6038 +1736 +2035 +7064 +5449 +3542 +6245 +5280 +4870 +3181 + +5699 +4317 +2871 +3784 +6855 +5389 +3538 +1374 +7930 +6761 +6756 + +8427 +4122 +1938 +8024 +1572 +4399 +1371 +1945 +1475 +5936 + +4158 +8074 +3978 +12335 +4192 +1983 + +7331 +3052 +5007 +7331 +6303 +3832 +4584 +6628 +4574 +3994 +6504 +7166 + +5045 +1220 +6070 +1942 +2263 +3916 +1936 +1557 +4652 +3224 +2866 +1448 +1261 +5803 + +8695 +10505 +8608 +11934 +9221 +3064 +9944 + +3497 +6215 +4573 +6966 +3312 +7874 +5739 +2775 +7394 +1896 + +8484 +6106 +7125 +10399 +4310 +3978 +8000 +3698 + +2462 +4167 +5607 +2518 +2013 +5458 +5439 +4152 +4061 +2246 +1349 +5429 +4122 +3370 +1401 + +6994 +5598 +4181 +11620 +7973 +2680 + +16039 +23774 + +3915 +1933 +2725 +5159 +5433 +5165 +5447 +1291 +1851 +5476 +3464 +3070 + +3511 +10497 +2941 +9581 +10220 +9369 +3517 +8319 + +11067 +4795 +9788 +6321 +9229 +5678 +3344 + +7639 +7865 +2566 +9034 +1333 +4160 +9017 +5958 + +7565 +5227 +7692 +6780 +2290 +10189 +3257 +6345 + +3910 +8187 +7800 +4521 +1055 +6494 +6879 +6508 +3778 +2576 + +1160 +7168 +7118 +7138 +5054 +2319 +1581 +5235 +6430 +2877 +2511 +2595 + +5449 +1604 +8598 +8992 +5251 +7608 +2606 +2404 + +4494 +1614 +12591 + +4105 +6805 +2299 +1368 +6970 +2029 +2567 +2055 +4073 +3090 +5666 +3796 + +11914 +10997 +7550 +5656 + +18298 +5479 + +4700 +1779 +6303 +4671 +2275 +3101 +1835 +3928 +2480 +3402 +4974 +5518 +1507 +5891 + +17354 +19903 +19827 + +6309 +4879 +4247 +4723 +1826 +3124 +6153 +4359 +5103 +5449 +3834 +4751 +5939 +3534 + +8210 +14642 +3626 +8654 +7933 + +12463 +2202 +9518 +5869 +5003 + +21437 + +1303 +5025 +7398 +2518 +6070 +7001 +8240 +4130 +4486 +2590 + +2211 +4296 +6216 +5870 +6871 +3508 +2504 +2898 +3048 +3381 +3879 +6604 +3057 + +2476 +4145 +8294 +5106 +9531 +5254 +1495 +1765 + +4592 +1366 +5153 +5189 +5896 +5331 +5104 +2438 +1725 +4846 +1744 +2251 +2769 +4181 +1189 + +8345 +13849 +7806 +11279 + +2950 +4805 +1549 +4468 +5550 +5136 +1311 +3073 +3482 +1175 +5151 +2011 +4116 +4405 +3581 + +2616 +6472 +4229 +2306 +1079 +1132 +5062 +6279 +2972 +1437 +5100 +2270 +3377 +1256 + +7703 +4334 +3700 +3586 +2980 +8040 +5481 +6456 +2284 +2481 +7518 + +7767 +3145 +1131 +6374 +2591 +1952 +2915 +6288 + +17556 +1308 +2244 +11329 + +5138 +18453 +24805 + +4253 +2926 +5747 +2324 +5486 +4747 +6081 +3244 +1015 +3443 +2086 +2016 +1409 +5915 +1805 + +5662 +3866 +4336 +3394 +2257 +4012 +2404 +4649 +4156 +3460 +4337 +5928 +2710 + +1811 +4065 +4708 +1579 +1360 +7071 +3771 +4071 +3152 +1427 +4361 +5013 + +52242 + +6035 +2981 +1824 +4305 +1253 +3804 +3713 +5411 +4316 +5945 +1503 +4619 +3873 +1063 + +8966 +2393 +5007 +2992 +8306 +2947 +10127 +6760 + +5101 +6156 +6344 +1093 +6575 +6010 +1179 +2699 +8234 +8433 + +25118 +27329 + +9532 +10745 +11456 +5346 +3371 +8674 +6338 + +11164 +6281 +6275 +3805 +3989 +3109 +10478 + +15795 +14646 + +9248 +4268 +13365 +6711 +5210 +3359 + +4367 +5811 +1444 +2920 +5074 +4213 +5135 +1109 +4701 +2615 +3108 +3748 +4670 +3620 +5180 + +1743 +2512 +4737 +6125 +6136 +2268 +2643 +1225 +6937 +3774 +2550 +1160 + +4159 +10506 +17904 + +1183 +3045 +2677 +3989 +5062 +1507 +5918 +5291 +3473 +3949 +4145 +4949 +4775 +3148 + +6473 +6375 +1013 +6653 +6193 +4437 +2192 +2663 + +3145 +9517 +5339 +7768 +10803 +5365 + +1120 +3384 +5420 +6699 +7252 +1922 +6063 +6993 +7110 +1062 +5206 +3326 + +3235 +3681 +3647 +2771 +1608 +1299 +1037 +2665 +2285 +6054 +3787 +6019 +1867 +2501 + +2116 +2641 +6185 +2165 +5765 +1674 +4516 +3426 +4773 +6586 +1914 +6492 +6193 + +2417 +5222 +2764 +3045 +1511 +3873 +5328 +4941 +4189 +5083 +2969 +2534 +1666 +1733 +5940 + +7351 +4465 +13541 +2200 +12798 +11321 + +32442 + +17392 +2823 +10314 +3495 + +4737 +4570 +3856 +2588 +3135 +3661 +3884 +5635 +5842 +1983 +2290 +5140 +2252 +4826 +5424 + +1666 +8670 +6408 +8258 +2038 +11212 + +7026 +7262 +5520 +7613 +10233 +4683 +9874 +5205 + +6451 +1335 +16980 +1986 + +7472 +10701 +3953 +3512 +9189 +5675 +5285 +1085 + +6673 +4260 +7698 +1171 +5686 +4966 +4824 +2941 +3847 +3968 + +2927 +6876 +6839 +1336 +6843 +5907 +1013 +6284 +2354 +2037 +4355 +4735 +2470 + +11642 +3298 +7526 +8973 +1752 +9609 +9415 + +7862 +24260 + +13115 +12552 +9965 +9011 +4189 +10063 + +4678 +5279 +1173 +4347 +1102 +1067 +7067 +7598 +5114 +3247 + +11741 +9531 +5821 +3624 +1064 +6312 +3099 + +17369 + +2453 +6099 +2945 +5136 +3273 +2295 +4925 +5956 +1280 + +1443 +1787 +2042 +8898 +3387 +2391 +6857 +5622 + +6594 +3937 +1178 +4172 +7356 +7296 +7497 +2169 +1673 +3993 +5546 + +25269 +15637 +21519 + +10437 +4102 +6545 + +2996 +4277 +2063 +2577 +3304 +3240 +5948 +3754 +3940 +4706 +4258 +5636 +2857 +4082 +4082 + +18222 +19780 +10272 + +5915 + +5612 +2789 +2367 +5086 +5148 +5115 +7196 +2378 +1394 +2072 +3440 +4135 + +35104 + +3238 +1135 +1210 +2747 +5793 +7097 +3327 +3438 +6990 +3218 +6635 +2945 + +2247 +5037 +2112 +3768 +1817 +4538 +3236 +1070 +2146 +1813 +1567 +6025 +2533 +1134 +1320 + +2305 +4606 +4812 +3568 +4712 +4459 +4131 +4079 +4008 +3131 +1264 +1684 +5296 +2945 + +1255 +1633 +4774 +5707 +1349 +1660 +1549 +3965 +3511 +1791 +3535 +2568 +6598 + +4756 +7488 +2222 +2964 +4150 +5175 +4198 +8641 +5103 + +2689 +16286 +12088 +10520 + +4714 +21793 +17571 + +4388 +2535 +3284 +3574 +1322 +3532 +3505 +3713 +6261 +6430 +4673 +1695 +1169 + +59355 + +20855 +1036 +20325 + +3231 +2285 +7377 +4182 +9866 +1502 +7341 + +3151 +3745 +15911 +4525 +6796 + +10285 +3489 +6159 +1484 +1735 +5194 +6943 +3763 + +2654 +4389 +3639 +5386 +2078 +3240 +3504 +8137 +2330 +8406 + +13627 +7144 +6062 +11288 + +21671 +15167 +8981 + +1199 +8578 +5102 +4529 +8070 +7573 +6499 +5155 +5134 +3510 + +3364 +6004 +3899 +6417 +3007 +5581 +4427 +5193 +1580 +6498 +4366 +3702 +6294 +3007 + +1086 +8177 +10586 +7787 +6042 + +4367 +1320 +9290 +7230 +9666 +4239 +8803 +6955 + +2626 +1542 +1131 +6190 +6719 +2764 +5729 +3631 +3914 +1309 +6531 +5590 +1387 + +1214 +3796 +4620 +1037 +6851 +2733 +6705 +5377 +5788 +4926 +3923 +1757 +3696 + +5645 +4859 +1827 +6117 +7432 +2787 +7137 +7504 +4120 +1430 +1522 + +3825 +6622 +8375 +8555 +1702 +2360 +4444 +1853 + +20697 +6984 + +5947 +4046 +6449 +1564 +3754 +5339 +4165 +5954 +4398 +3271 +2567 +1454 +6060 +1108 + +17518 +10791 +7556 +1902 + +6547 +1011 +11291 +3886 + +1673 +5267 +6948 +6577 +7606 +8357 +6414 +9057 +5283 + +36117 + +2334 +4192 +2967 +1160 +3335 +5893 +6342 +5954 +2462 +4028 +4035 +3816 +5167 +6094 + +4025 +5106 +3876 +1689 +2168 +3504 +2819 +6809 +5580 +1549 +4401 +5305 +2889 + +4919 +4789 +4604 +1647 +2305 +1223 +1621 +5273 +4101 +1318 +1514 +5766 +5749 +3943 + +18068 +9720 +11242 + +3190 +1497 +3700 +5345 +5117 +4089 +2584 +3740 +2397 +3541 +4534 +4403 +6257 + +4822 +7295 +1000 +4766 +9612 +9061 +3549 +8036 +5254 + +4816 +2187 +7269 +3500 +7150 +2797 +6007 +5651 +4702 +1385 +6393 +5128 + +2347 +3149 +2773 +3877 +5619 +1646 +3363 +1888 +5203 +5155 +5974 +2030 +2149 +3530 +2745 + +4694 +12004 +11089 +13235 + +11269 + +4700 +2437 +6297 +4951 +3798 +6109 +4249 +5262 +3972 +1493 + +3293 +3333 +2306 +1234 +6389 +1929 +1012 +1477 +3691 +1235 +3846 +5286 +1164 +5630 + +17541 +12819 +7368 +11983 + +14008 +7610 +2321 +4581 + +5345 +5511 +2483 +6155 +3052 +5151 +4224 +3992 +5566 +5275 +4539 +4762 +4804 +3673 + +64454 + +22960 +19989 +1512 + +6252 +1835 +9984 +5671 +6357 +8737 +7341 + +5374 +3434 +2008 +4744 +5277 +1394 +4515 +6327 +5656 +2721 +3005 +1197 +5579 +3661 + +5886 +4591 +5003 +2309 +2703 +5984 +2750 +2332 +1005 +2374 +2945 +2250 +3844 +5665 +5016 + +3269 +4501 +7712 +12368 +2929 + +8015 +7817 +9884 +10257 +7097 +1024 +6910 + +5184 +7911 +3112 +4284 +2879 +6177 +3740 +2243 +7722 + +4643 +6279 +5081 +3030 +3991 +2642 +7422 +6341 +3712 +6022 +2953 + +8182 +9540 +18188 + +9292 +10077 +8619 +2367 +9770 +3540 +10220 +2537 + +3230 +5748 +3491 +2382 +4803 +4477 +4706 +5688 +3872 +4854 +6934 +7327 + +16115 +16116 +15926 +6134 +7828 + +7192 +1734 +4498 +4311 +2682 +6019 +5482 +7073 +1602 +6751 +1106 +2314 + +6320 +7703 +9059 +12137 +10057 +4961 + +4306 +2143 +6775 +2805 +3338 +7133 +4619 +1323 +2753 +4504 +4366 +5334 + +11176 +13348 +13834 +10124 +8084 +6286 + +10338 +13150 +2090 +2260 +16428 + +3667 +4251 +5278 +1111 +3667 +6833 +6846 +4346 +2118 +5830 +6642 +3730 +1700 + +1037 +14507 +24258 + +22776 +16783 +22796 + +10555 +1425 +5032 +12069 +1108 +8152 +6623 + +11535 +11922 +4903 +5397 +13421 + +9869 +8664 +15110 +12589 +2301 + +1319 +11885 +12142 +3267 +6484 +1285 +2595 + +5648 +4703 +4074 +8048 +4128 +2197 +2947 +1737 +4032 +6999 +4374 + +6043 +2635 +3457 +6893 +1769 +2808 +4858 +5987 +1193 +6061 +1197 +4169 +4939 + +4043 +5938 +3483 +5056 +5921 +3376 +3972 +1843 +5401 +5469 +2972 +3421 +5129 +2949 + +12561 +1792 +13583 +12678 +11790 +4781 + +1868 +3636 +1727 +3229 +4396 +3926 +1960 +4131 +1766 +3644 +6156 +1321 +4685 +2702 + +6193 +5733 +4709 +2502 +3684 +3363 +5916 +6806 +5483 +3767 +2544 +3000 +5196 + +4345 +1107 +1363 +5707 +4533 +5183 +3248 +6589 +3008 +4193 +6416 +4727 +1464 + +16694 +7689 + +2805 +3717 +5326 +5676 +1663 +1680 +1151 +4131 +1223 +1542 +4191 +2587 +5529 +4681 +3736 + +10132 +10116 +6576 +4908 +16381 + +2310 +7296 + +11429 +16310 + +3801 +6942 +3366 +3915 +3903 +4342 +2289 +5429 +1211 +4237 +5688 +5023 +3319 + +1234 +4811 +2311 +2590 +2857 +5111 +5063 +6350 +1887 +1814 +6092 +3694 +2758 +3712 + +1830 +8120 +18551 +14964 + +7427 +1702 +4265 +3065 +3409 +3845 +9418 +10394 + +5947 +6853 +7006 +5538 +6218 +6167 +4825 +2838 +2073 +8061 +7418 + +3077 +1132 +1171 +3570 +4467 +5666 +3306 +5859 +2191 +2986 +4212 +5046 +3082 +3918 +3539 + +12352 +4933 + +11214 +21828 +18790 + +8150 +8051 +6399 +13321 + +1077 +7138 +9996 +2474 +7483 +5220 +9358 + +2352 +7906 +8887 +6549 +9471 +6563 + +2408 +11061 +2717 +9936 +7232 + +1143 +26201 + +8453 +18884 +14705 + +1102 +4208 +3159 +2913 +2163 +2493 +2202 +4092 +4944 +3844 +4740 +5584 +3073 +2325 +3359 + +5448 +5487 +5685 +2776 +5432 +2527 +3483 +4295 +7162 +7033 +5512 +4802 + +8890 +9904 +6114 +1416 +5791 +10383 +2333 + +5420 +6696 +5120 +3503 +1975 +6025 +1966 +3962 +7988 +3808 +4725 + +3407 +3897 +6234 +2085 +5141 +6526 +1296 +2371 +4846 +3129 +4258 +4951 +2549 + +3491 +1833 +7754 +8425 +5132 +1799 +4950 +1499 +1791 +7778 + +3416 +9251 +6111 +2067 +15697 + +1560 +4056 +4203 +5915 +1118 +3442 +7843 +1986 +2318 +7247 + +3266 +6672 +2491 +6089 +2403 +2038 +1581 +5163 +3657 +6090 +2392 +6109 +2091 + +8674 +5107 +10708 +6044 +5193 +2111 +1706 +5666 + +5933 +3537 +5456 +6595 +9018 +2113 +3778 +3638 + +3741 +1940 +1603 +4061 +3986 +3414 +2327 +2173 +5594 +5598 +3974 +5162 + +4947 +2765 +3017 +2598 +3841 +3663 +4664 +2519 +3969 +3721 +4100 +2463 +4616 +4553 +4986 + +2809 +6051 +1262 +1163 +6129 +1501 +4798 +7401 +3929 +1077 +6108 +3232 + +10252 +3877 +5596 +7696 +2683 +3182 +5335 +10338 + +4390 +7767 +7735 +6771 +2291 +2887 +2884 +6444 +4270 +1721 + +2939 +5140 +4955 +6308 +2891 +5405 +1775 +2275 +3153 +5569 +3769 +1229 +4394 + +1677 +2258 +5447 +4017 +1478 +1334 +2354 +5847 +4433 +2973 +3691 +4900 +5785 +3571 + +3573 +3512 +4014 +5627 +4750 +4273 +1428 +5189 +4971 +6104 +3301 +2558 +4522 +2924 +4828 + +62151 + +9293 +11550 +20431 + +24683 +10913 + +1939 +1487 +8441 +7821 +12802 + +19163 +2462 +17788 + +1390 +8446 +9351 +8697 +2520 +6065 +4574 +9621 + +3357 +3779 +1786 +7387 +4334 +5856 +1186 +2309 +7374 +3244 +6129 + +3096 +3130 +3634 +4227 +4453 +7400 +3889 +2310 +5974 +6357 +6352 +4975 + +4281 +15698 +6045 +16109 + +7835 +10597 +6334 +10543 +10680 +3210 +2302 + +2740 +2418 +3629 +1099 +8802 +6407 +4369 +3978 +8454 +3646 + +2051 +1323 +5425 +1715 +6173 +7524 +5259 +1006 +8445 diff --git a/src/bin/day_1.rs b/src/bin/day_1.rs new file mode 100644 index 0000000..3efa996 --- /dev/null +++ b/src/bin/day_1.rs @@ -0,0 +1,35 @@ +use color_eyre::{eyre::eyre, Result}; + +fn parse(s: String) -> Result> { + let mut elves = vec![]; + + let mut current_elf = 1; + let mut current_sum = 0; + + for line in s.lines() { + if line.is_empty() { + elves.push((current_elf, current_sum)); + current_elf += 1; + current_sum = 0; + } else { + current_sum += line.parse::()?; + } + } + + Ok(elves) +} + +fn main() -> Result<()> { + let mut input = aoc_2022::load_data(1, parse)?; + + input.sort_by_key(|(_, sum)| *sum); + let max = input[input.len() - 1].1; + + println!("The most calories carried by one elf is {max}!"); + + let top_three = input[input.len() - 1].1 + input[input.len() - 2].1 + input[input.len() - 3].1; + + println!("The top three elves are carring {top_three} calories!"); + + Ok(()) +}