From df9a94841da7facba625175940cffae62cf57424 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Wed, 7 Dec 2022 20:33:13 +0000 Subject: [PATCH] Start aoc 2022 --- 1_1.c | 39 + 1_1.in | 2234 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1_1.py | 16 + 1_2.c | 44 + 1_2.py | 15 + 2.c | 62 ++ 2.in | 2500 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2_1.py | 21 + 2_2.py | 27 + 3.in | 300 +++++++ 3_1.py | 18 + 3_2.py | 23 + 4.in | 1000 +++++++++++++++++++++++ 4_1.py | 32 + 4_2.py | 30 + 5.in | 512 ++++++++++++ 5.py | 75 ++ 6.in | 1 + 6_1.py | 18 + 19 files changed, 6967 insertions(+) create mode 100644 1_1.c create mode 100644 1_1.in create mode 100644 1_1.py create mode 100644 1_2.c create mode 100644 1_2.py create mode 100644 2.c create mode 100644 2.in create mode 100644 2_1.py create mode 100644 2_2.py create mode 100644 3.in create mode 100644 3_1.py create mode 100644 3_2.py create mode 100644 4.in create mode 100644 4_1.py create mode 100644 4_2.py create mode 100644 5.in create mode 100644 5.py create mode 100644 6.in create mode 100644 6_1.py diff --git a/1_1.c b/1_1.c new file mode 100644 index 0000000..12fba99 --- /dev/null +++ b/1_1.c @@ -0,0 +1,39 @@ +#include +#include + +void set_calories(int* current, int* highest) { + if (*current > *highest) { + *highest = *current; + } + + *current = 0; +} + + +int main() +{ + char *buffer; + size_t bufsize; + size_t characters; + + int current_calories = 0; + int highest_calories = 0; + + + while ((characters = getline(&buffer, &bufsize, stdin)) != -1) { + --characters; + + buffer[characters] = 0; + + if (characters == 0) { + set_calories(¤t_calories, &highest_calories); + } + + current_calories += atoi(buffer); + } + + set_calories(¤t_calories, &highest_calories); + printf("The elf with the highest calories has %d calories", highest_calories); +} + + diff --git a/1_1.in b/1_1.in new file mode 100644 index 0000000..f229b54 --- /dev/null +++ b/1_1.in @@ -0,0 +1,2234 @@ +6750 +6538 +5292 +4635 +6855 +4137 +3840 +4691 +1633 +6008 +2447 +1448 +4061 + +4261 +6778 +1531 +2914 +2102 +4098 +2451 +1219 +6488 +3941 +2158 + +9058 +3441 +9318 +1976 +6115 +9451 +10090 +5850 + +4921 +3202 +3193 +4170 +1079 +1757 +5828 +1757 +2849 +1586 +5661 +2607 +2047 +5385 + +7272 +20573 +13163 + +10682 +5428 +3751 +9040 +1556 +1778 +8657 +9901 + +4889 +6751 +5090 + +12074 +19421 +3745 +10856 + +15209 +13798 +15398 +15838 +4569 + +2572 +4413 +3683 +12331 +6840 + +8924 +7301 +1912 +7526 +4090 +6867 +3223 +1083 +2215 + +1728 +12054 +13145 +4353 +12434 +3579 + +24525 +23626 + +4395 +11502 +14008 +10243 +1463 + +4565 +5888 +3039 +5295 +1034 +3440 +2668 +7161 +5646 + +6367 +8398 +5485 +8919 +6618 +2850 +6855 +5865 + +6788 +7063 +6797 +3168 +7176 +1193 +1846 +1873 +5291 +1712 +2802 + +3991 +4976 +2611 +3576 +3919 +3522 +3877 +2822 +3726 +5944 +4658 +6066 +4618 + +6675 +12989 +2094 +2264 +13116 +11464 + +6322 +2429 +4887 + +6282 +11135 +3600 +3977 +6564 +1687 +3041 + +48760 + +3670 +16233 +6513 +15868 +12383 + +10008 +9791 +3299 +4085 +5778 +10435 +7349 + +5393 +1162 +4273 +3179 +3259 +1892 +8713 +7147 +8921 + +7793 +5170 +3658 +6938 +5040 +6680 +1682 +1411 +4675 +2435 + +19306 +33764 + +5046 +5534 +5683 +4581 +5515 +4866 +1520 +1469 +3747 +3969 +4070 +3201 +4376 +3453 +5877 + +13009 +23239 +20343 + +11867 +14880 + +2716 +1627 +2914 +2171 +3475 +4131 +2816 +2237 +1538 +3209 +4589 +4920 +2222 +3873 +5492 + +4059 +3824 +2008 +1651 +5992 +5777 +6401 +5129 +1919 +2921 +1897 +5831 +5123 + +5504 +6492 +3528 +5206 +5682 +5635 +6720 +3617 +1625 +5082 +1140 + +3202 +4433 +8085 +6145 +1788 +5332 +5737 +2561 +1502 +5880 + +19360 +15037 +9234 +1425 + +6289 +2249 +6150 +5228 +4380 +4528 +4320 +1979 +3716 +2908 +4012 +7181 + +2027 +5508 +3895 +8700 + +6981 +5136 +2006 +2955 +7964 +8445 +1394 +4874 +5100 +6794 + +5929 +7003 +3703 +7981 +7682 +4386 +8325 +7086 + +6000 +8868 +12326 +3747 +2003 +6186 + +5770 +5634 +1784 +9951 +8578 +13924 + +2935 +24789 +21603 + +8239 +10654 +12558 +5657 +14398 + +1306 +7030 +4126 +3092 +7155 +3949 +5040 +5951 +6263 +5587 +1561 +6046 + +34556 + +5474 +3194 +1962 +7296 +8065 +2107 +7355 +4748 +4752 +7983 +7051 + +19407 + +7778 +1987 +7642 +1268 +5019 +3694 +2161 +6285 +1600 +5145 + +8850 +14656 +2486 +10361 +2067 + +6012 +4885 +4612 +1807 +7657 +6930 +1790 +6035 +5725 + +6047 +2033 +6994 +2344 +5801 +1207 +5190 +3118 +3153 +1869 +6065 +3754 + +4721 +1639 +2235 +3834 +4052 +4763 +1649 +2470 +4294 +2716 +5381 +6453 + +2751 +7038 +1463 +2756 +2256 +3708 +1921 +4682 + +7439 +1232 +3630 +7889 +2564 +7272 +5764 +5655 +7827 +6832 + +7254 +6038 +3702 +6855 +4473 +1957 +1597 +7394 +2850 +3529 +6832 +6855 + +3486 +3877 +6424 +5280 +5080 +4055 +1830 +1737 +4379 +1980 +5148 +5972 + +10069 +4487 +14451 +7309 +8744 + +8751 +4856 +4594 +3986 +4709 +4361 +4205 +1401 +5873 +5059 + +2548 +6623 +3418 +6848 +2165 +6466 +4259 +2792 +1663 +5537 +1343 + +15745 +5468 +8877 +18074 + +6055 +14504 +12291 +8253 +5828 + +25661 + +7301 +9470 +9040 +1483 +2974 +7741 +8556 +7457 + +1465 +4805 +2485 +2431 +6956 +2712 +7434 +1079 +2500 +1670 + +2537 +5815 +5604 +2453 +3919 +2488 +2866 +5500 +4009 +1219 +6109 +3118 +4932 +4514 +1732 + +2589 +6885 +7099 +8389 +4576 +4904 +3223 +4645 +1076 +1453 + +6236 +9825 +7747 +4682 + +2958 +4351 +3057 +2951 +6734 +1766 +4026 +2957 +8567 +7559 + +5472 +5402 +4469 +4762 +3408 +5000 +3805 +3535 +4942 +3180 +3477 +1599 +5597 +1030 + +2651 +4374 +6259 +3969 +6953 +5116 +3336 +4486 +5499 +3027 +1109 +6419 +4552 + +2876 +6394 +5562 +5153 +2408 +6503 +1909 +3958 +2908 +1817 +5627 + +1662 +7210 +5719 +4019 +3414 +9539 +7163 +5050 +7793 + +1003 +4450 +5580 +2140 +3531 +4093 +4189 +2347 +4990 +2177 +5204 +3731 +1673 +2567 +2206 + +5589 +3205 +6409 +7776 +4005 +1250 +7219 +6491 + +22563 +24898 +3671 + +1628 +4812 +6709 +1969 +1128 +2526 +5606 +3184 +3590 +5067 +7267 + +6073 +4594 +2346 +1819 +2383 +5765 +1530 +3850 +2453 +2015 +4712 +5945 +3990 + +5700 +2022 +4971 +2569 +2226 +5599 +2661 +3097 +4126 +6015 +1328 +4067 +6088 +4550 +3083 + +5833 +2291 +1397 +6032 +2359 +4478 +2480 +2217 +3012 +2212 +2551 +3894 +1144 +2494 +5242 + +10165 +5568 +5967 +10286 +5835 +6187 +6443 + +2460 +2361 +5067 +2008 +6812 +6381 +4005 +6778 +5942 +4981 +3141 +5420 +1137 + +8977 +11981 +4701 +4392 +7377 + +6702 +1053 +5682 +2280 +4750 +5451 +5425 +5739 +3052 +1884 +5115 +3447 +1355 + +15207 + +23476 +24176 + +4357 +6421 +4897 +6452 +5591 +3745 +4225 +3902 +4382 +6200 +3521 +1158 +6742 + +7327 +4654 +4242 +4063 +2551 +2845 +5636 +1645 +6300 +3800 +3324 +5186 + +2671 +4674 +5368 +10396 +7250 +8983 +10080 + +5132 +9545 +4031 +2698 +2741 +3072 +1542 +1419 +3958 + +1736 +6254 +7696 +5803 +4724 +2811 +7429 +3568 +8717 +1015 + +3616 +3437 +1285 +2201 +3597 +2818 +1859 +4828 +2644 +4907 +5468 +3424 +6160 +4025 + +7153 +1979 +3198 +2506 +1838 +5274 +2904 +5671 +1300 +3064 +2447 +2756 + +8583 +8107 +14984 +10437 +9655 + +4628 +1643 +2052 +4833 +3918 +6200 +6348 +1551 +7568 +7647 +5621 + +4470 +4926 +1971 +6085 +2990 +4674 +1927 +2155 +6489 +6878 +3445 +6810 +1998 + +3804 +5867 +3159 +3385 +3765 +3175 +1265 +3572 +3718 +4562 +5117 +3938 +1977 +3606 +2281 + +3352 +15576 +7744 +3992 +1217 + +4426 +12388 +12828 +5208 +2784 +12502 + +1762 +4751 +3595 +4360 +1064 +4224 +3268 +5411 +3390 +2589 +1513 +3075 +5845 +1738 +4082 + +13785 +6062 +7074 +3574 +11195 +8335 + +8519 +22618 +10403 + +12822 +12248 +9591 +13299 +10619 + +7025 +6943 +5930 +3343 +3430 +7089 +6784 +7879 +9007 + +3920 +7809 +7363 +6740 +1326 +2578 +2518 +7446 +7417 + +3603 +10150 +8180 +5872 +7075 + +3118 +10518 +8824 +2675 +8445 +9206 +3724 +4329 + +9885 +10933 +1372 +3905 +12731 +6330 + +3884 +3392 +3455 +3560 +3093 +2778 +4630 +4742 +4959 +2883 +4820 + +5796 +1645 +14987 +6986 +15074 + +3281 +1335 +3725 +5414 +6439 +1619 +4557 +4583 +1522 +1009 +1835 +2371 +5955 +2289 + +43920 + +2477 +1999 +4809 +5084 +3606 +4850 +5977 +3763 +1108 +4160 +2322 +6356 +5461 + +5000 +3267 +5171 +7136 +9932 +1281 +11676 + +3689 +3319 +3508 +7243 +7766 +1685 +3809 +4093 +2539 +7137 +3167 + +8322 +11802 +6949 +15451 + +2806 +6035 +4881 +1152 +5328 +4693 +5930 +1610 +5849 +4853 +2049 +1263 +5736 +5234 +1525 + +1616 +2945 +23855 + +2062 +8376 +10728 +9744 +2777 +4101 +5612 +5133 + +13599 +14149 +8082 +12680 + +5143 +6807 +6474 +7390 +2308 +3201 +7265 +4492 +6646 +1664 +6422 +7428 + +15425 +4319 +15222 +7365 + +5186 +4698 +4556 +6355 +1879 +5436 +3440 +4223 +6103 +1027 + +6897 +5842 +1932 +3726 +3608 +3011 +6812 +2384 +2285 +1388 +3211 +6414 + +37328 +20417 + +1127 +2001 +6357 +1978 +5528 +4675 +7215 +1097 + +4258 +3189 +4748 +3973 +3492 +4496 +1123 +6485 +4969 +3947 +4079 +2657 +4920 +1940 + +5593 +3590 +7069 +6526 +3404 +8501 +5189 +9022 +3399 + +4146 +4305 +3820 +2260 +3144 +1288 +3812 +2815 +1553 +2301 +5655 +1298 +2531 +4350 + +1200 +2871 +7637 +2279 +7747 +5740 +2103 +2373 +2471 +3658 + +3108 +4947 +2258 +1073 +9635 +7326 +7712 +9458 +1008 + +6679 +16292 +11474 +10212 +11418 + +4018 +6049 +1942 +5851 +3480 +1108 +1769 +4176 +1911 +2497 +2904 +5108 +4018 +4839 + +9257 +5081 +3816 +1487 +8582 +5317 +8506 +2749 +7187 + +10033 +12757 +9353 +6820 +2459 +12843 + +17725 +16704 +1919 +14770 + +11941 +8538 +2984 +6435 +1242 +2782 +11283 + +4787 +1630 +2456 +4425 +5434 +1684 +2066 +4657 +3419 +6536 +1132 +4288 +4319 + +7364 +6179 +5832 +4077 +4003 +8781 +6022 +5672 +5784 + +4582 +8233 +9135 +8448 +7295 +3450 +5941 +5678 +8945 + +3673 +11877 +8079 +5830 +13123 +8819 + +2464 +4267 +1275 +4036 +3019 +7571 +6808 +2291 +4975 +4857 +7037 + +4663 +5328 +2021 +1593 +5605 +2423 +6565 +1077 +3076 +2521 + +2712 +10855 +10943 +6416 +2654 +11960 +9471 + +5053 +2896 +2868 +2508 +3712 +2086 +1028 +5985 +1312 +2486 +3561 +3789 +1747 +4241 + +1244 +3146 +3768 +5090 +4881 +1565 +4007 +5283 +8189 +2266 + +11599 +6170 +7253 + +1596 +2215 +6018 +5848 +3357 +5971 +1395 +5412 +4413 +2907 +3398 +6191 +1502 + +5562 +1955 +3203 +4835 +5426 +5409 +4020 +3987 +4922 +1332 +1355 +2244 +4977 +1559 +5507 + +8879 +3197 +11212 +4477 +8238 +1800 +3684 + +15121 +7384 +14501 +12667 +9620 + +1767 +4997 +6039 +1889 +3620 +2880 +4305 +1292 +6176 +3125 +5876 +6515 + +3829 +5030 +2670 +6937 +7747 +1587 +3837 +3222 +3607 +3325 +5323 + +27071 +32218 + +5593 +3592 +2311 + +2628 +2562 +1322 +5307 +4337 +4761 +4451 +2981 +4279 +4828 +2008 +3109 +3016 +1927 +5636 + +1218 +1205 +2913 +1892 +4268 +5360 +5622 +4694 +1721 +3315 +1886 +1798 +2418 +2954 +2479 + +2125 +7128 +2112 +5163 +6536 +7023 +7026 +2662 +7967 +3376 +4663 + +11505 +9288 + +4193 +5100 +1922 +3258 +1133 +3906 +6049 +1211 +3743 +3952 +1546 +2818 +1795 +3697 + +13660 +13843 + +10925 +4229 +10107 +10541 +3950 +6892 +7594 + +3726 +4753 +3245 +2459 +5362 +4514 +1635 +1875 +2196 +3379 +4391 +3278 +3942 +5488 + +6838 +7367 +5133 +4229 +8382 +5748 +4408 +1149 +2712 + +5790 +7280 +1537 +6596 +4167 +7905 +4829 +1875 +5374 +3432 + +18774 +12470 +2680 + +1481 +4005 +8336 +9616 +9360 +9601 +8805 +1857 +7736 + +2372 +16287 +11904 +4931 + +6023 +3192 +2630 +2712 +5403 +7077 +3310 +2386 +3072 +6322 +6850 + +20799 +2284 +9823 + +4705 +5625 +1830 +1374 +1770 +1125 +2395 +5050 +1311 +4818 +3497 +2829 +6509 +2301 + +3318 +10761 +10053 +11006 +4726 + +3055 +8238 +8388 +10499 +16116 + +4145 +1135 +6326 +3248 +3734 +2661 +4180 +1240 +6488 +5394 +4859 +6312 +2128 +2689 + +31894 +27468 + +7845 +2959 +2719 +2650 +3442 +2128 +2702 +3306 +2590 +2887 +2655 + +4595 +6230 +11249 +2158 +3494 +7055 +5763 + +4473 +6469 +6779 +3344 +5325 +7869 +1481 +6709 +5553 +8648 + +5459 +12649 +10227 +19725 + +4389 +4566 +2761 +5106 +4064 +4118 +1923 +3564 +2935 +1084 +5351 +6416 +6170 +1642 + +63220 + +3978 +7803 +9714 +6796 +5812 +7324 + +6757 +3868 +18800 +1352 + +2034 +1060 +4800 +5866 +2625 +3222 +2281 +2911 +3698 +2632 +2504 +2993 +5809 +1805 +4196 + +5613 +2702 +1140 +2398 +2584 +3877 +2934 +1496 +4237 +4305 +2103 +5801 +2201 +1100 +4737 + +4454 +24314 +4677 + +6100 +1297 +4199 +6261 +5518 +1942 +1875 +3137 +5217 +2370 +4628 +4854 +6484 + +2790 +5473 +6457 +4180 +1133 +6134 +3019 +3479 +5472 +3336 +5414 +4040 +6459 +5327 + +24399 +21223 +12711 + +7774 +10176 +10388 +2864 +2575 +8018 +3420 +6435 + +9838 +14038 +11004 +7468 +1242 + +6915 +5378 +5586 +7725 +5101 +1569 +3073 +4346 +1253 + +2633 +4195 +6287 +4192 +8015 +9520 +6870 +9894 + +7014 +2252 +3296 +2288 +5613 +2615 +1903 +7348 +5555 +1460 +2770 +4373 + +8013 +8256 +3029 +8246 +2830 +6447 +8885 +9633 +9081 + +6296 +6768 +4904 +3649 +2623 +1577 +7764 +1959 +6686 +7329 +3986 + +13311 +5670 +6954 +7407 +12264 + +1832 +6503 +7209 +7871 +5590 +1952 +4496 +4698 +3591 +5818 +1756 + +3584 +6327 +6639 +7100 +3409 +1023 +4365 +5607 +6419 +7887 +5419 + +23730 +7283 +7943 + +5497 +4917 +1514 +1399 +6628 +3835 +5718 +2071 +6030 +2238 +2187 +4433 +6289 + +6897 +2972 +3174 +2134 +6927 +3165 +2072 +6086 +5119 +4199 +3256 +3257 +6808 + +23297 +8152 +1449 + +4807 +4900 +7997 +13646 +10133 + +60078 + +1764 +4796 +7749 +1069 +5594 +2802 +3850 +1878 +3212 + +8476 +1982 +3141 +2647 +10087 +1170 +5975 +3683 + +4310 +5495 +1374 +1462 +1852 +5149 +5976 +3397 +1280 +3545 +3021 +2969 +5261 +3474 +4938 + +14240 +36288 + +3977 +6268 +1396 +2707 +6344 +5279 +3026 +1237 +4671 +1545 +3049 +1235 +3322 +1226 + +7877 +10542 +10800 +11760 +7013 +11468 +10914 + +1883 +6346 +8428 +2097 +12309 +1747 + +6919 +4606 +4133 +6376 +6127 +3131 +5530 +1041 +6161 +4321 +6201 +7080 + +9683 +19478 +7509 +7186 + +15598 +23816 +9973 + +1740 +5245 +7924 +2086 +3354 +5989 +1788 +7710 +5233 +4330 +6087 + +5063 +3096 +7629 +6728 +5995 +6789 +5294 +8760 +5424 +6981 + +3548 +2507 +2274 +1434 +4003 +3988 +2009 +5501 +3583 +4751 +3335 +1793 +3450 +4458 +5667 + +9998 +12172 +10851 +13296 +12712 +5534 + +3552 +2877 +3870 +4505 +5234 +4130 +5405 +5460 +5840 +4405 +1839 +3764 +2418 +4602 + +11031 +11643 +9905 +8111 +10798 +12365 + +38360 + +3952 +19297 +16495 +16016 + +9608 +2121 +5670 +3593 +8530 +2474 +9402 +1305 + +2152 +6691 +5395 +7779 +5215 +6785 +1282 +7910 +3591 +1320 + +6767 +5293 +5630 +5654 +9330 +2438 +5614 +8125 +5418 + +8336 +6170 +1224 +3646 +4163 +8049 +9345 +6148 + +2815 +2907 +4811 +1271 +2410 +3790 +4602 +3684 +2711 +2756 +3535 +1877 +3902 + +3492 +4651 +2158 +6059 +2071 +8046 +3863 +4920 +2427 +5702 + +4846 +14976 +16005 +17415 + +4171 +3820 +1051 +3655 +1972 +1510 +6213 +2666 +5479 +3776 +2680 +4844 +3361 + +68996 + +1046 +3913 +6469 +3566 +5521 +2615 +5167 +1535 +1842 +4028 +2505 +6146 +5646 + +30144 +31365 + +2582 +5925 +1480 +3378 +7508 +6960 +5834 +4230 +4839 +5744 +5675 + +32883 + +13628 +14364 +15147 + +3863 +1397 +8149 +3836 +6434 +1847 +6078 +5762 +4318 +2934 + +4426 +1851 +4825 +5352 +5998 +4412 +2592 +5786 +3582 +3180 +2682 +3928 +2112 + +6674 +1167 +4238 +4532 +4175 +2308 +4963 +5452 +7397 +7163 +4460 diff --git a/1_1.py b/1_1.py new file mode 100644 index 0000000..a66fdb4 --- /dev/null +++ b/1_1.py @@ -0,0 +1,16 @@ +largest = 0 +current = 0 + +with open("1_1.in") as fh: + for line in fh: + line = line.strip() + if not line: + if current > largest: + largest = current + + current = 0 + continue + + current += float(line) + +print(largest) diff --git a/1_2.c b/1_2.c new file mode 100644 index 0000000..0ebc8c3 --- /dev/null +++ b/1_2.c @@ -0,0 +1,44 @@ +#include +#include + +void set_calories(int* current, int* highest) { + if (*current > highest[2]) { + highest[0] = highest[1]; + highest[1] = highest[2]; + highest[2] = *current; + } else if (*current > highest[1]) { + highest[0] = highest[1]; + highest[1] = *current; + } else if (*current > highest[0]) { + highest[0] = *current; + } + + *current = 0; +} + + +int main() +{ + char *buffer; + size_t bufsize; + size_t characters; + + int current_calories = 0; + int highest_calories[3] = {0, 0, 0}; + + while ((characters = getline(&buffer, &bufsize, stdin)) != -1) { + --characters; + + buffer[characters] = 0; + + if (characters == 0) { + set_calories(¤t_calories, highest_calories); + } + + current_calories += atoi(buffer); + } + + set_calories(¤t_calories, highest_calories); + printf("The 3 elves with the highest calories have %d calories", + highest_calories[0] + highest_calories[1] + highest_calories[2]); +} diff --git a/1_2.py b/1_2.py new file mode 100644 index 0000000..d0bf525 --- /dev/null +++ b/1_2.py @@ -0,0 +1,15 @@ +all_of_them = [] +current = 0 + +with open("1_1.in") as fh: + for line in fh: + line = line.strip() + if not line: + all_of_them.append(current) + current = 0 + continue + + current += float(line) + +all_of_them.sort(reverse=True) +print(sum(all_of_them[:3])) diff --git a/2.c b/2.c new file mode 100644 index 0000000..e9ad569 --- /dev/null +++ b/2.c @@ -0,0 +1,62 @@ +#include +#include +#include + + +int main() +{ + char *buffer; + size_t bufsize; + size_t characters; + int score = 0; + + while ((characters = getline(&buffer, &bufsize, stdin)) != -1) { + --characters; + + buffer[characters] = 0; + + switch (buffer[0]) { + case 'A': + switch (buffer[2]) { + case 'X': + score += 3 + 1; + break; + case 'Y': + score += 6 + 2; + break; + case 'Z': + score += 0 + 3; + break; + } + break; + case 'B': + switch (buffer[2]) { + case 'X': + score += 0 + 1; + break; + case 'Y': + score += 3 + 2; + break; + case 'Z': + score += 6 + 3; + break; + } + break; + case 'C': + switch (buffer[2]) { + case 'X': + score += 6 + 1; + break; + case 'Y': + score += 0 + 2; + break; + case 'Z': + score += 3 + 3; + break; + } + break; + } + + } + printf("%d", score); +} diff --git a/2.in b/2.in new file mode 100644 index 0000000..cb4efdf --- /dev/null +++ b/2.in @@ -0,0 +1,2500 @@ +B Z +A X +B Z +B Z +C Z +B Z +A Z +B X +C Y +C Y +A X +A X +A Z +B Z +A X +A Z +B X +C Y +A Y +A Y +C Y +B Y +C X +C Y +B Z +A X +A Y +B Y +A X +A Z +B X +B Y +B Z +B Z +B Z +C Y +B X +A X +C Y +B Z +B Z +C X +A Z +B Z +B Z +C X +C X +B X +B X +A X +B X +C Z +C Y +C Y +C Y +C X +B Z +B Y +C X +A X +C X +C Y +C Y +C Y +B X +B Y +A Z +B Z +A X +B Z +C Y +B Y +B Z +B X +C Y +B Y +A Y +A X +B Z +B Z +B Z +B Z +C X +A X +B Y +C Y +C Y +B Z +B Z +A Z +B Y +A X +A Z +B Z +A X +B X +B X +B X +B X +A X +A Z +B X +B Z +B X +B Z +B X +C Y +C Y +C X +B X +A Z +C Y +B Z +C Z +B X +B Z +B Z +C Z +C Y +B X +B X +C Y +A Y +A X +C Z +B X +B X +C X +C X +C Y +C X +C Y +C Y +C Y +B Z +B Z +A X +C Y +C Y +A Y +C Y +A Z +B Z +A Y +C Y +C Y +A X +B X +B Z +C Y +C Y +B Z +B X +C Y +B Y +A Z +A Z +C Y +B X +C Y +B Z +C Y +B Z +B Z +B X +C Y +C X +B Z +C Z +A Y +C Y +C Y +A Y +C X +A Y +B Z +B Y +C X +A Y +C Y +C X +C Y +C Y +B Z +A Y +B Z +A Y +B Z +B Z +B Z +C Y +A Y +A X +B Z +C Y +C Y +C Y +B X +B Z +C Y +C Y +C Y +B X +C X +B X +A X +B Z +B X +C Z +A X +A X +A X +C Y +C Y +B Z +A Z +C X +B X +C Y +A Y +A Z +A Z +A X +A X +C Y +B Z +A Z +B Z +B X +C Z +B X +B X +B Y +A Z +B Z +C Y +B X +C X +C X +A X +B Z +B X +A Y +B Z +A X +B X +B Z +A X +B Z +C Y +B Y +C Y +A Z +B X +B X +B X +B Z +B Z +B Z +A X +B X +B Z +B Z +A X +B X +C Z +B X +A Z +A Z +C Z +A Y +C Y +B X +B Z +A X +B Z +B X +C Y +C Y +B X +C Y +C X +C Y +B Z +A Z +C Y +A Z +B X +B Z +B Z +A X +A Y +A X +B Z +B Z +B Y +A Z +C Y +B Z +B X +B Z +A Y +C X +B Z +C Y +A Y +A X +A Z +C Y +C Z +A Y +B X +A X +B X +C Y +C Z +B Y +B Z +B Z +C Y +B Z +C Z +B Y +A Z +A Z +B Z +B X +B X +A Z +C Y +B X +B Z +A Y +C Y +B Z +C Y +B X +C Y +C Y +C Y +A Y +C Y +C X +A X +C Y +C Y +A X +C Y +C Z +B X +B X +C Y +A X +A Y +C Y +A X +C X +A Y +A Z +A X +B Z +B Z +C X +C Y +B X +A X +A Z +B X +B Z +A X +B Z +B Z +B Z +B X +B Z +B Z +A Y +C X +A X +B X +B Z +C Y +C Y +C Y +C Y +B Z +C Y +B Y +C Y +A Z +C Y +B Z +B X +B Z +B Z +B X +C Y +A Z +B X +B Z +B Z +B X +C Y +B X +C X +C X +A X +C Y +A X +B Y +C Y +B Z +B X +C Y +B Y +B X +B X +B Y +B X +A Z +B X +B X +B X +B Z +B Y +A X +B X +C Y +C Y +B Y +B X +A Y +C Z +B X +C Y +B X +C Y +A Z +B Y +A Z +B Z +A Y +A X +C Y +B X +B X +A X +B Y +A Z +B X +B Z +A X +C Z +B Y +A X +A X +A X +A X +B Y +C Z +C Y +B Y +C Y +B X +B Z +A X +C Y +A Y +A X +C Y +C Y +B X +B Y +A X +C Y +A Y +A Z +A X +A Y +C Y +A X +C Z +C Y +B Z +B Y +C Y +C Z +A X +A X +C X +B X +C X +B X +A Z +B Z +C Y +C Y +A Z +C Y +A X +C X +B Z +C X +C Z +B X +B X +C Y +B X +A Y +B X +B Z +C X +C Y +B X +B X +B Z +B X +C Y +B Z +C Y +C Y +A Z +C Y +C Y +C Y +B X +B X +A X +C Y +B X +B X +C Y +B Z +A X +B X +C Y +B Z +B Y +B Z +A X +B Y +B Z +C X +C Y +B Z +B Z +B Z +B Z +B Z +C X +B Z +C Y +C X +B Y +B X +B X +C Y +B X +B X +C Y +C Y +A X +C Y +C Z +A Z +C Y +C Y +C Z +A X +C Y +A Y +B X +C X +C Y +C Z +C Y +C Y +B X +A X +B Z +A Y +B Z +B Z +B X +B Z +A Z +B Y +B Y +C Y +A Y +C Y +B X +A X +C Z +B Z +B X +A Z +C Y +C Y +C X +A Z +C Y +C Y +A Y +B Y +B Y +B Z +B Z +B X +B X +B Z +B X +B X +B Z +A Y +A Y +C Y +C Y +B X +A Y +A X +C Y +A Z +C X +B Y +B Y +B Y +A Z +C Y +B Z +B Z +A Y +B Z +B Z +C Z +C X +C X +B X +C Y +B X +B X +C Y +A X +A Z +C X +B X +A X +B Z +A X +B X +A Y +B X +B Z +B X +B X +C Z +A Z +B Z +C Z +B X +B X +A X +B Z +B Z +B Z +B Z +B Z +B Z +B X +C Y +B Z +B X +B X +C Y +C Y +B Z +B Z +B X +A Y +A X +A Z +C Z +A X +B Z +B X +B Z +B X +C Y +A X +A Y +C Y +C Y +B X +B X +B X +B Z +B X +B Z +A Y +A X +C Y +A Z +C Y +A X +C Y +B Z +A Y +C Y +C Y +C Y +B Z +B Z +A Z +A X +B X +C Y +A X +B Y +C Y +B X +B Z +B Z +A Z +B Z +C Y +B Z +A X +C X +B Z +B X +A X +C Y +C Y +A Z +C Y +C Z +A Z +A Z +B X +B X +B Z +C Y +B Z +B Z +C Y +B X +B Y +B Z +C Y +A X +C Y +A Y +C Y +C Y +C Y +B X +B X +B Z +B Y +C Y +B Y +A Z +A Z +B X +A Z +C X +C Y +B Z +B X +B Z +B X +B Z +B Z +B X +B Z +B Z +C X +C Y +A Z +C Y +B Y +A X +B Z +B Y +A Z +A X +B X +C Y +B Z +C Y +B X +C Y +B Z +B Y +B X +A Z +B Y +C Y +B X +C Y +A X +B Y +B X +C Y +C X +B X +B X +C Y +C Y +B Z +A X +B X +B Z +A X +B X +A X +B X +B X +B Y +C Y +A X +C X +C Y +C X +B Y +A Z +A X +C Y +B X +B X +B Z +C Y +B Z +B X +B Z +B Y +B Y +B Z +B X +C Y +B Y +A X +C Y +B Z +B Z +C Y +A Z +C Y +B Y +C Y +B Y +B X +B Z +B X +C Y +B X +C Y +B Z +C Y +B Z +B X +B X +B Z +A X +C Y +A X +B X +C Y +B X +C Z +C Y +B Z +A Y +A Y +C Y +B Z +A Z +B Z +C Y +A Z +B X +A X +B X +C Y +B Z +A X +B X +A Y +B X +B Z +A Z +C Y +A Z +C X +A Z +B X +C Y +B Z +B Z +A X +B Y +C Z +B Z +A Z +C Y +B X +C Y +B X +C Y +B Y +B Z +C Y +B Z +C Y +C Y +B Y +B Y +C Y +C Y +A Y +B Y +B X +C Y +C Y +C X +C Y +C Y +B Z +B X +B X +C Y +C Y +A X +C Y +C Y +B X +A Y +B X +A X +B Y +B X +B Z +B X +C Y +B Z +A Z +B Z +C X +B Z +B Y +B Z +B Z +C Y +B X +B X +C Y +B Z +B Z +B Z +B Z +A X +C Y +A Z +A X +C X +B Z +B Y +A Y +B X +C Y +B X +C Y +C Z +A Z +C Y +C Y +C Y +B Z +B Y +A X +C Y +B X +B X +B Z +B X +C Y +C Y +A X +B Z +B Z +C Y +B Y +B Y +B Z +A X +B Z +A X +B Y +C X +A Z +B Z +B Z +B X +C Y +B Y +B Y +B X +C Y +B X +B Z +C Y +B Z +A X +A Z +B Y +C Y +B X +B Z +C Y +B X +B X +B Z +B Y +C X +B X +A X +B X +B Z +B Z +B Z +A Z +A Z +B X +C X +B X +B Y +C Z +C Y +B Y +A X +A Z +B Z +B X +B Z +B Z +A Y +A Z +C Y +C Y +C Y +A Y +B Z +C X +C Y +C Y +A Z +B Z +C Y +B Z +C Y +A X +C Y +C Y +B X +A X +B X +A X +A Z +A X +B Y +B X +A X +B Z +B Z +B X +A Z +B X +A X +B Z +B Z +B Z +A X +B X +C Y +C Y +B Z +A X +A X +B Z +C X +B Z +C Y +C Y +C Y +A Y +B X +C Z +C Y +B X +A Y +A Z +C X +B Y +B Z +C Y +B X +A Z +C Z +C Y +C Y +B Z +B X +B Z +A Z +C Y +B X +A X +C Y +C Y +B X +B Y +B X +B X +C Y +B Y +C Y +B Z +B X +A Y +A X +B Z +A Z +B Z +B Z +A Y +C Y +A X +B X +B X +A X +C Y +B Z +B Y +B Z +B Z +B X +C Y +C Y +C Z +B Y +B Y +B Z +B X +B Z +C Y +B X +A Z +C Y +B Z +B X +C Y +C Y +C Y +B Z +C Y +B Z +C Y +B Z +B Z +B Z +C Y +C Y +B Z +C Z +A Y +A Z +A Z +C Y +C Y +A Z +B X +B X +A X +B Z +B Z +A X +A Z +C Y +B X +A Z +B X +C Y +A Z +C Y +B Z +B X +B X +B Z +B X +C Y +C Z +C Z +B X +A X +A Y +B Y +B X +B X +A Y +A X +B X +C Y +C Y +B Z +B Z +A X +C Y +B Z +B X +B Z +C Y +B X +C Y +B Z +B Y +B Z +B X +B X +C Y +B Z +B Z +B Z +A X +B Z +B Z +B Z +A Y +A X +C Y +B Z +B X +A X +B Z +C Y +B X +B Z +C Z +C Y +C Y +B Y +B Y +C Y +A Y +B Y +A Y +C Y +A Z +B X +B Y +C Y +A X +B Z +C Y +A X +B X +C Y +B X +A Y +C Z +C X +C Z +B Z +C X +A Z +C X +B Z +B Z +B Z +A X +C Y +B X +A Y +C Y +B Z +A Y +A Z +B X +A Z +C Y +C Y +C Y +B Z +B Y +A X +C Y +C X +A Y +B Z +A X +A Z +C Y +A Z +B Z +B Z +C X +B X +C Y +A X +C Y +A Z +B Z +B Z +B X +C Y +C Y +C X +C Z +C Y +C X +C X +C Y +B X +C X +C Z +C Y +B Y +C X +A X +C Y +A X +C Z +C X +C Y +B X +A Z +B Z +B X +B Z +B X +C Y +B Y +B Z +B X +B Z +C Y +C Z +B X +B Y +C Y +C Y +C Y +C X +A Y +B X +C X +B X +B Y +B Z +C X +B Z +B Z +A X +A X +B Z +B Z +A Y +A Z +B Y +A X +B X +B X +C Y +A X +A Y +B X +B Z +C Z +B Z +B X +C Y +C Y +B Z +A Z +B X +A Y +A Y +C Y +B Z +B X +A X +B Y +A Y +B Z +B Z +B Z +B Y +C Z +A X +C X +B Y +A Y +B Z +C Y +A X +B Z +C Y +A X +B X +B Z +B X +B Z +B Z +C Y +A Z +B X +C Y +B Z +A Y +B X +C X +B X +B X +B Z +B X +B Z +B X +B Z +B Z +C Y +B Z +C Y +B X +B Z +B X +B Z +C Y +B X +C Y +A Z +A Z +B Z +B X +B Z +B X +C Y +A Y +A X +B Z +B X +B X +A Z +A X +C Z +A X +A X +C Z +C Y +B X +B X +B Z +A Z +B X +C Y +B X +B Z +C X +C Y +C Y +A Z +B X +B X +C Z +C Y +B X +A X +C X +B Z +B Z +B X +C Y +B Z +A X +B X +B Z +A Z +B X +A Y +B Z +B X +C Y +B Y +C Y +A Z +A X +C Y +A Z +A X +C Y +C Y +C Y +C Y +C Y +B X +C X +B Y +A Z +B Z +C Y +A X +B Z +C X +C Y +B X +A Y +B X +B Z +C Y +B X +A Y +B Z +C Y +B Z +A X +B X +C Y +A Y +B Z +B X +A Z +C Y +B Y +A Y +A Z +B Y +C Y +B Z +B Z +B Z +C X +C X +B Y +B Z +A X +C Y +C Y +A Y +A X +A X +C Y +A Y +B Z +B Z +B Z +B X +A X +B X +C Y +A Z +B X +A Y +A X +A X +B Z +B Z +C Y +B X +B Z +C Y +B Z +A Z +C Y +B X +B Z +C X +C Y +C Y +C Z +B Z +B X +A X +B Z +C Z +C Y +C Y +C Y +B Z +A Y +C Y +B X +C Y +C Y +B X +B X +C Y +C Y +B Z +B X +A Z +C Z +B Z +A X +B Y +B Z +A X +C Y +C Y +B Z +A Y +C Y +B Y +B Z +C Y +A X +C Y +C X +C Y +C Y +A Y +B Z +C Y +C Y +B X +C Y +B Z +B Z +C Z +B Z +C Y +B Z +B Z +C Y +A X +C Y +A Z +B X +C X +B X +C X +A Z +C Y +A X +A X +B Z +C Y +B Z +B X +A Y +B Z +C X +B Z +A Y +C Y +B X +A Z +B Z +B Z +B Z +B Z +B Z +C Y +C Y +C Y +B X +A Y +A Z +B Z +C Y +B Y +C X +B X +B Z +B X +C Y +A X +C Z +C Y +A X +B X +C Y +B X +A X +C Z +C Y +C Y +C Z +C Y +C Y +B X +C Y +A Y +B X +B Z +B Z +C Y +A X +B Z +B Z +C Y +B X +B Z +B Z +C Y +C X +B Z +B Z +A Z +B X +B Z +B Z +B X +B X +B X +A X +A Z +B Z +B Z +B X +B X +C Y +C Y +B X +A Y +C Y +B Z +C Z +B Y +B Z +C X +A X +B X +C Y +C Y +A Y +C X +B Z +B Z +B Z +B Z +A Z +A Y +A X +A Y +B Y +A Y +B Z +C Y +C X +C X +B Z +C Y +A X +B Y +B X +B X +B X +A Y +B Z +B X +B Z +B Z +B Z +A Z +C Y +C Y +C Y +B Z +C X +B Z +A X +A Y +B Z +C Z +B Z +A X +B Z +A X +B Z +A Z +A X +B Z +B Z +B Z +B X +A Z +B X +C Y +B Y +B X +A X +B Z +A Z +B Z +B Z +B Y +C X +B X +B Z +A X +B X +B Z +B X +C Y +C Z +A Y +B Y +A X +B Z +B Y +A Z +C X +C Y +B Z +A X +C Y +A Y +C Y +C X +A Y +B X +B X +B Z +C Y +B Y +A X +B Z +B X +A X +A X +B X +A X +B Z +B X +B Y +C Y +B Z +C Y +C X +B Z +B Z +B Z +C Y +A X +B Z +A Y +A X +C Y +B Z +C Y +C X +C Y +C Y +A X +B Z +A X +A X +B X +B Y +C Y +C Y +A X +B Z +C Y +C X +B Z +B Z +B Z +B X +A Y +B X +C Y +A X +C Y +B Z +C Y +C Y +A X +B Y +B Z +B Y +A Y +B Z +B Y +B Z +A Y +C Y +A Y +A X +A Z +A X +B X +C Y +C Y +B X +A Z +B X +B Z +B X +B X +B Z +C Y +B Z +B Z +B X +A Z +A Y +C Y +B Y +C Y +C Y +B Z +C Y +C Y +B Y +B Z +B X +C Y +B Z +B Z +A Y +A Y +B X +B X +C Y +B Z +B Z +B X +B X +C Y +A Z +B X +B X +A Z +B X +B Z +B X +B X +A X +C Y +C Y +C Y +B X +A Z +C Y +C Y +B Z +B X +B Z +B Z +B Z +B Y +A X +A Z +C Y +C Y +B X +B Y +C X +A Z +C X +C Y +C X +C Y +C Y +C X +A X +B Z +B X +B Z +C Y +A Y +B X +B Z +C X +B X +B Y +B Z +B Z +A Z +C X +B X +B X +B Y +B Z +C Y +C Y +C Y +A Z +B Z +A Z +B Z +B X +C Y +B X +B X +A Y +C Y +A X +B Z +C Y +B Z +B Z +B Z +B Y +C Y +A Z +B X +C Y +B Z +C X +B X +A X +B Z +B X +A Y +B Z +B Z +C X +B X +B X +B Z +B Z +B X +C Y +B Z +A Y +B X +C X +C Y +B Y +B Z +B X +C X +C Y +B X +B Z +B Z +B X +C Z +B Z +B X +C X +C X +B Z +B Z +C Y +B X +C Y +A Z +A Z +B Z +B X +A Z +B X +B Z +B Y +B Z +C Y +B Z +A Z +C X +B Z +B Z +C Y +A Z +C Y +C Y +C Y +A X +A Z +A Z +B Z +C X +A X +C Y +B X +B X +C Y +C X +A Z +B X +B Z +B X +B Y +C Y +A X +C Y +C Y +A X +C Y +B Z +B X +C Y +C Y +B X +C Y +C Y +C Y +A X +B Z +B X +B Z +B Y +A Z +B Z +C Y +B Z +A X +A Z +A Y +B Y +B Z +B Z +A X +B Y +A Z +B Z +B Z +A Y +C Y +B X +B Z +A X +B Z +B Z +A X +B Z +B Z +B X +A Z +B X +B Z +A Y +A Y +A X +C Y +B Z +A X +B Z +C Y +B Z +B X +C Y +C Y +C Y +B X +A Z +C Y +B Y +B Z +B Z +B Z +B X +C Y +C X +A X +B Z +A X +C Y +C Y +B X +B X +B Z +C Z +C Y +C Y +A Y +C Y +B Z +B X +B X +B Z +C Y +B Z +B X +B X +C Z +B X +C X +C Y +C Y +C X +C Y +C Y +B Z +B X +B X +C Y +C Y +C Y +B Y +A X +B Z +B Y +A Z +B Z +C X +B Y +B X +B Z +B X +A Z +A Z +C Y +C X +C Y +A Z +B Y +A Y +C Y +B Z +A Z +A Z +C Y +B Z +B X +B Z +C Z +C Y +C X +B Z +B X +A X +A Y +B Z +B X +A Y +B X +B X +C Y +B X +B Z +A Z +C Y +C Y +A Y +B Z +C Y +B Y +C Y +C Y +C Y +B Z +A Y +B Z +A X +B X +B Z +B Z +B Z +A X +C X +B X +C X +A Z +C Y +B X +B Z +B Y +C Y +C Y +B Y +B Y +C Y +C Y +A X +C Y +B Y +B X +B X +A Z +B X +C Y +B Z +A Z +C Y +C X +A Z +B Z +A Z +C Y +B Z +B X +C Y +B Z +B Z +B X +C Z +B X +B Z +B Y +B Y +B X +B Z +C Y +B Z +B Z +B X +B Z +B Z +B Z +C X +B X +C Y +B Z +C X +C Y +C X +C X +B Y +B Z +A X +C X +B Z +A Z +A X +B Z +B Z +B Z +C Y +B X +B X +C Y +B X +C Y +B Z +B Y +B X +B Y +A X +B Z +A X +C X +C X +B Z +C Y +A Y +B X +B X +C Y +C Y +C Y +C Y +B Z +B Z +C Y +B Z +B X +B X +B Z +B X +B X +B Z +B Y +C Z +C X +C Y +B X +B X +A X +B X +C Y +A Z +B Z +B X +C Y +B Z +B Z +B Z +B Z +B Z +B Z +A Y +C Y +C X +C Y +C Y +A X +B X +B Z +B Y +B Z +C Y +B Y +A Y +A Z +B Z +B Y +C Z +B Z +C Y +B Z +C Y +B Z +B Z +C Y +C Z +A X +C Y +C Y +A Z +A X +C Y +B Z +C X +C Y +B Z +B Z +B Z +C Z +B Y +B Z +B Z +C Y +C Y +A Y +B Y +B X +B X +B Z +B Y +A Z +A X +A Y +C Y +B Z +C Z +A Y +B X +B Y +C Y +C X +C Y +B X +B X +C X +C Y +B Z +C Y +C Y +C Z +B Z +B X +A X +C X +C Y +B Z +B X +B Z +B Z +B Z +C Y +A X +C X +B Y +B X +A X +A Y +B X +C Y +B X +C Z +C X +B X +A Z +B Z +B X +B Z +A Y +C X +A Z +B Y +B Z +C X +C Z +B X +B Z +B X +B Z +B Z +C X +B X +B X +A Z +C Y +B X +C Y +B Z +B Z +C X +C Y +B Z +A X +B Z +C Y +B X +A X +C Y +A X +A X +C Y diff --git a/2_1.py b/2_1.py new file mode 100644 index 0000000..2414b74 --- /dev/null +++ b/2_1.py @@ -0,0 +1,21 @@ +scores = { + "A X": 3 + 1, + "A Y": 6 + 2, + "A Z": 0 + 3, + "B X": 0 + 1, + "B Y": 3 + 2, + "B Z": 6 + 3, + "C X": 6 + 1, + "C Y": 0 + 2, + "C Z": 3 + 3, +} + +score = 0 + +with open("2.in") as fh: + for line in fh: + line = line.strip() + + score += scores[line] + +print(score) diff --git a/2_2.py b/2_2.py new file mode 100644 index 0000000..92a3688 --- /dev/null +++ b/2_2.py @@ -0,0 +1,27 @@ +""" +X = Loss +Y = Draw +Z = Win +""" + +scores = { + "A X": 0 + 3, + "A Y": 3 + 1, + "A Z": 6 + 2, + "B X": 0 + 1, + "B Y": 3 + 2, + "B Z": 6 + 3, + "C X": 0 + 2, + "C Y": 3 + 3, + "C Z": 6 + 1, +} + +score = 0 + +with open("2.in") as fh: + for line in fh: + line = line.strip() + + score += scores[line] + +print(score) diff --git a/3.in b/3.in new file mode 100644 index 0000000..d0ad78f --- /dev/null +++ b/3.in @@ -0,0 +1,300 @@ +PcPlnShmrLmBnmcwBhrmcmbHNGFGpwdFFwGNjNbGqNHH +tzQfRJfWZZztWzVtCTfRzFZjpFjNZjGLHbdHLDdjpb +CCQTzRLzvQVVfRzJfMPsnBlglgPmBgPmvSrl +RMfvbbszHTsssFPzDQPggpQJPQ +NSNcqVtLVGgDlpQBClVB +hmStGNNLhjNrpWLGSjWrZssbZTMMvTfMnThb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WdvlrcWddggrDBDDdDMmWzRJqfVQZqmsfZsRQzZfZzQJ +TldWrMrDdlDCDdMTcwSLVCSShLNSwHjhGF +JGsWWWQsJmPwQWbBPmccbcbqFfMMpFDVCDFVFVCDqqfFwD +ZtLnlvLnNtvLndnCmfMVSmVCClfpVp +zTzZtjnZNLNmZvdtznntHHZJbBRGBRQWcJGbGsbsJRPQWT +MLmlMTPtQtMNlhbqbbqhflBB +rcrvjpSvScbRbBvbDBPG +ZZJzSHpzPrJzHFmMVMFmHCLNtV diff --git a/3_1.py b/3_1.py new file mode 100644 index 0000000..2c5546b --- /dev/null +++ b/3_1.py @@ -0,0 +1,18 @@ +from string import ascii_letters + +sum_of_priorities = 0 + +with open("3.in") as fh: + for backpack in fh: + backpack = backpack.strip() + + comp_size = len(backpack)//2 + + comp_a = set(backpack[comp_size:]) + comp_b = set(backpack[:comp_size]) + + item_in_both = list(comp_a.intersection(comp_b))[0] + priority = ascii_letters.find(item_in_both) + 1 + sum_of_priorities += priority + +print(sum_of_priorities) diff --git a/3_2.py b/3_2.py new file mode 100644 index 0000000..050683b --- /dev/null +++ b/3_2.py @@ -0,0 +1,23 @@ +from string import ascii_letters + +sum_of_priorities = 0 + +def get_3_rucksacks(fh): + return [next(fh).strip() for _ in range(3)] + + +with open("3.in") as fh: + while True: + try: + rucksacks = get_3_rucksacks(fh) + except StopIteration: + break + + a, b, c = rucksacks + + item_in_all = list(set(a).intersection(set(b)).intersection(set(c)))[0] + + priority = ascii_letters.find(item_in_all) + 1 + sum_of_priorities += priority + +print(sum_of_priorities) diff --git a/4.in b/4.in new file mode 100644 index 0000000..9c78281 --- /dev/null +++ b/4.in @@ -0,0 +1,1000 @@ +33-62,26-62 +49-89,49-88 +2-4,3-92 +7-98,7-98 +6-74,6-73 +78-79,13-78 +90-95,95-95 +62-66,56-67 +2-93,4-92 +12-64,11-11 +7-83,5-91 +20-87,20-88 +29-93,26-92 +19-20,20-31 +62-62,7-63 +9-83,9-84 +8-27,28-95 +6-49,6-48 +7-71,65-71 +90-96,19-89 +13-97,98-99 +17-75,75-76 +90-91,44-90 +5-62,24-92 +45-76,46-76 +9-22,23-23 +93-94,35-93 +32-34,33-48 +43-44,6-44 +79-86,80-86 +7-7,6-93 +77-82,83-91 +59-60,32-59 +7-27,7-7 +2-23,22-23 +35-35,6-36 +32-34,11-33 +24-35,28-34 +37-62,62-64 +9-18,18-18 +8-53,2-7 +2-99,1-99 +15-95,65-94 +17-71,6-18 +38-71,13-63 +6-77,4-9 +1-99,2-98 +13-67,13-66 +45-87,45-86 +13-59,12-82 +18-79,17-19 +83-83,36-83 +38-77,38-76 +17-17,16-41 +78-94,79-94 +36-87,6-91 +30-38,29-29 +54-56,22-55 +43-43,37-43 +2-99,1-1 +16-88,15-17 +13-14,2-14 +26-57,26-58 +19-86,19-86 +97-98,67-97 +1-92,2-92 +1-3,3-77 +25-54,54-54 +44-53,46-60 +16-74,74-74 +4-7,8-28 +96-99,95-99 +37-70,36-80 +59-68,60-60 +47-95,29-87 +91-91,68-91 +18-91,19-90 +16-27,5-28 +94-96,63-95 +3-20,19-73 +18-74,8-80 +6-71,3-72 +52-71,53-93 +6-8,7-97 +68-77,22-78 +29-76,30-30 +13-98,13-99 +7-73,3-74 +64-98,16-74 +20-78,9-21 +17-65,18-18 +71-96,27-96 +55-91,46-56 +93-96,5-92 +15-15,14-77 +18-49,17-49 +77-78,70-77 +31-88,31-87 +38-85,57-86 +39-87,87-87 +26-77,76-77 +1-1,3-47 +5-96,95-96 +25-78,15-60 +11-84,84-84 +22-30,22-30 +6-85,83-86 +32-40,32-39 +4-97,4-97 +34-90,26-91 +23-68,23-67 +41-51,30-33 +21-83,22-82 +21-85,1-74 +72-74,6-73 +6-6,5-94 +10-83,10-83 +11-85,5-12 +81-82,82-82 +4-82,82-82 +25-89,25-25 +70-79,74-78 +17-51,26-50 +7-70,6-70 +21-81,21-80 +72-88,71-71 +68-72,21-73 +74-95,73-75 +15-94,12-13 +47-96,48-96 +58-70,10-58 +69-69,63-69 +7-95,7-94 +13-66,13-65 +1-18,2-18 +4-90,4-89 +24-84,23-23 +89-90,14-89 +8-10,7-16 +16-18,21-96 +19-30,1-29 +78-99,9-97 +2-9,6-19 +58-82,53-85 +51-96,51-97 +11-70,69-70 +1-2,2-95 +93-95,41-94 +95-95,10-96 +18-18,17-48 +1-99,2-2 +66-68,67-98 +5-7,6-90 +49-94,50-66 +12-41,2-91 +10-93,93-94 +27-51,27-52 +9-15,15-99 +16-47,15-48 +11-89,25-85 +39-77,7-64 +9-91,91-92 +65-66,22-66 +9-83,9-31 +8-78,8-77 +2-98,2-99 +33-53,25-50 +11-91,9-97 +46-90,2-91 +69-70,70-95 +39-53,15-39 +63-85,64-85 +15-82,13-13 +38-55,56-56 +14-34,14-33 +28-47,24-46 +8-98,7-98 +24-35,27-98 +44-67,45-64 +65-90,65-91 +23-89,21-24 +1-2,4-48 +12-97,13-89 +11-91,41-90 +72-72,11-72 +5-61,6-75 +25-77,25-78 +1-98,5-96 +22-57,22-56 +69-92,25-69 +6-85,5-85 +46-48,19-47 +19-25,24-94 +6-96,3-12 +18-67,67-68 +42-43,42-96 +95-95,74-95 +20-38,37-68 +2-72,2-73 +21-23,25-71 +4-29,4-29 +87-88,41-88 +59-66,66-92 +54-95,54-96 +5-88,88-88 +73-74,46-74 +12-13,12-41 +5-11,7-12 +62-64,18-63 +98-98,2-98 +69-77,28-70 +7-62,29-61 +7-7,6-98 +35-94,9-35 +77-78,77-90 +10-10,9-86 +26-32,4-26 +79-92,27-85 +40-88,41-82 +20-58,15-59 +64-97,63-65 +6-23,2-24 +11-15,13-14 +16-88,15-26 +35-77,36-77 +47-94,25-48 +17-54,5-53 +97-98,98-98 +9-87,35-86 +46-89,2-46 +11-49,33-48 +41-80,40-98 +11-95,10-10 +22-71,11-71 +14-63,64-64 +49-51,50-97 +1-81,82-82 +36-93,1-93 +38-80,38-39 +41-66,10-65 +20-44,19-21 +42-98,41-98 +65-78,66-77 +2-5,4-96 +15-62,62-63 +7-85,6-8 +46-82,45-81 +45-47,46-85 +18-39,37-44 +40-64,63-64 +24-49,24-48 +64-94,63-63 +22-23,5-23 +13-96,12-12 +43-75,43-75 +15-96,70-95 +42-43,42-53 +64-66,42-77 +86-94,88-93 +35-94,9-93 +5-98,6-6 +21-97,20-20 +7-99,8-8 +12-12,11-88 +6-48,7-48 +60-73,61-73 +28-56,27-79 +39-61,2-64 +78-78,28-79 +35-97,13-96 +8-97,9-90 +6-96,4-4 +23-98,22-97 +11-78,11-79 +37-92,37-92 +33-66,32-67 +27-88,87-88 +32-89,90-90 +7-96,7-97 +10-98,10-10 +2-83,82-84 +2-13,13-82 +23-27,22-24 +46-85,47-89 +16-71,70-71 +4-79,3-76 +96-96,1-96 +15-89,15-88 +22-32,26-82 +21-21,20-21 +5-67,6-68 +46-60,25-61 +56-95,34-99 +11-74,11-75 +2-14,14-97 +4-97,11-92 +19-34,18-18 +4-20,5-33 +91-91,68-91 +2-99,1-2 +68-87,68-86 +3-98,3-3 +91-99,9-90 +21-58,26-56 +33-70,34-64 +81-81,82-83 +49-66,48-50 +10-11,11-62 +7-92,29-83 +19-89,88-89 +7-42,42-90 +60-76,76-99 +51-53,52-91 +33-56,34-57 +5-88,46-87 +15-96,15-95 +8-27,27-95 +96-98,38-96 +9-40,41-43 +68-83,68-82 +5-11,7-93 +50-50,8-50 +26-69,68-70 +23-44,13-82 +90-94,93-95 +1-95,1-96 +29-31,30-83 +49-81,48-50 +41-70,42-70 +10-73,11-72 +9-10,16-18 +72-73,1-73 +47-71,47-48 +4-97,23-96 +10-96,10-96 +15-43,43-80 +57-82,18-57 +4-19,2-2 +46-81,38-82 +55-72,24-55 +63-64,60-64 +12-99,22-97 +31-62,53-67 +41-87,67-86 +30-30,31-82 +20-34,19-35 +76-77,43-77 +25-52,32-53 +50-95,51-98 +50-50,49-75 +4-91,90-90 +61-89,60-89 +4-93,4-94 +22-93,22-94 +50-66,49-58 +22-89,23-88 +20-94,33-93 +12-30,11-71 +11-54,11-75 +6-60,5-6 +36-45,3-46 +84-96,31-83 +25-25,25-29 +17-18,17-30 +45-69,45-70 +64-98,65-65 +5-60,16-59 +81-81,25-81 +23-69,66-70 +34-97,35-96 +7-90,6-97 +76-79,75-75 +27-97,27-96 +14-34,23-32 +28-95,94-96 +36-68,36-67 +25-27,26-96 +93-95,67-94 +29-91,30-30 +57-58,29-58 +44-65,43-45 +2-16,16-34 +15-99,16-43 +33-62,33-62 +1-79,1-80 +60-96,60-97 +28-28,28-50 +90-94,33-89 +14-51,13-15 +3-76,3-77 +21-48,25-87 +23-25,24-97 +74-76,74-75 +34-36,35-74 +78-96,79-96 +3-94,5-90 +81-95,81-94 +62-70,61-73 +55-55,20-55 +88-90,6-89 +88-88,3-89 +14-99,13-15 +6-78,29-77 +63-73,72-73 +38-38,38-87 +5-93,5-94 +66-90,45-94 +42-68,41-43 +62-90,86-90 +16-50,15-31 +80-81,63-81 +49-62,38-50 +70-90,53-96 +19-19,20-81 +7-16,15-75 +9-98,92-97 +29-95,28-95 +99-99,1-97 +39-96,40-40 +1-1,2-99 +24-28,7-23 +9-57,8-74 +27-31,26-27 +6-93,5-93 +39-89,38-40 +43-84,84-85 +3-69,2-2 +24-88,87-88 +6-97,2-96 +5-93,4-5 +43-43,44-86 +17-73,17-72 +85-86,28-85 +9-35,35-36 +14-93,13-22 +62-64,30-63 +71-71,48-71 +48-88,49-78 +13-57,58-96 +21-81,10-19 +37-39,36-37 +14-17,10-15 +23-74,73-75 +4-29,1-5 +2-96,95-99 +13-82,12-13 +51-98,51-97 +21-21,20-37 +17-68,17-69 +32-49,68-74 +55-73,49-74 +11-53,10-12 +2-4,3-99 +55-56,53-56 +14-24,13-25 +19-58,18-58 +62-87,62-86 +11-93,93-94 +44-64,43-80 +2-82,3-82 +37-38,33-38 +97-98,18-98 +12-47,46-47 +5-95,4-96 +22-98,16-21 +1-70,69-70 +8-93,8-92 +36-89,36-90 +84-96,82-86 +38-38,37-89 +77-96,96-96 +80-82,23-81 +48-92,14-49 +80-80,5-80 +49-80,20-81 +77-85,76-78 +6-6,5-90 +42-97,42-96 +98-99,45-99 +25-95,94-96 +1-66,7-66 +43-44,44-65 +14-71,3-82 +4-11,4-49 +31-43,33-42 +65-99,9-66 +48-98,98-98 +4-78,5-77 +21-38,22-22 +5-99,99-99 +1-1,3-17 +53-97,17-54 +8-57,7-7 +83-95,25-96 +43-49,42-42 +80-90,81-90 +33-65,34-60 +48-65,11-66 +4-99,6-92 +7-60,6-60 +3-47,47-85 +27-59,26-28 +57-76,73-77 +52-60,51-72 +2-99,98-99 +37-70,70-70 +19-95,5-12 +1-98,1-2 +84-89,39-85 +24-89,89-98 +15-16,15-24 +10-10,9-77 +9-39,8-58 +13-73,13-74 +32-60,13-61 +55-70,57-65 +54-56,42-55 +2-27,11-26 +9-83,8-85 +39-40,12-39 +50-52,15-51 +97-97,4-97 +58-59,2-58 +36-37,37-85 +32-77,31-33 +73-96,6-94 +84-86,52-85 +24-26,25-75 +2-79,1-2 +36-36,35-68 +6-50,5-50 +6-94,94-95 +6-28,3-29 +53-53,33-53 +5-98,95-97 +33-91,34-34 +18-83,84-98 +41-41,3-41 +34-90,89-90 +73-73,4-73 +56-57,57-78 +2-4,4-94 +61-70,53-71 +73-74,74-74 +3-99,5-98 +7-66,66-73 +4-13,12-13 +71-79,70-80 +58-93,57-59 +7-90,8-90 +53-94,22-53 +9-47,10-47 +19-99,37-98 +55-55,55-55 +48-84,28-85 +57-90,57-88 +70-70,3-71 +6-68,6-68 +1-4,5-97 +12-42,13-13 +2-78,2-77 +29-61,7-86 +71-71,43-71 +63-74,42-75 +83-83,58-83 +4-20,3-4 +30-92,31-31 +2-15,8-40 +13-69,12-14 +81-82,21-81 +33-45,33-44 +87-92,18-88 +52-96,95-96 +10-53,11-52 +81-95,81-96 +8-8,4-7 +4-99,3-5 +51-77,52-76 +17-89,16-16 +19-21,20-80 +1-3,2-94 +96-97,3-97 +50-58,57-86 +38-98,38-39 +8-97,5-9 +11-96,95-97 +28-43,27-44 +21-26,20-25 +58-97,12-92 +1-3,3-88 +11-47,10-72 +1-71,3-85 +40-40,39-97 +3-89,3-90 +7-92,37-91 +73-89,61-90 +61-80,28-92 +61-62,11-61 +19-80,19-80 +4-6,5-78 +6-54,16-81 +92-97,20-91 +61-62,5-62 +40-65,39-39 +57-66,54-67 +2-98,3-76 +13-99,12-88 +96-97,2-97 +46-56,56-57 +7-94,11-94 +5-78,4-5 +31-71,31-79 +47-47,48-83 +72-91,72-92 +36-37,37-70 +57-98,98-98 +7-99,7-98 +2-99,2-98 +27-96,95-96 +19-27,28-93 +1-9,8-52 +92-92,1-92 +38-84,84-85 +94-97,22-95 +19-37,32-36 +4-17,17-96 +27-80,28-99 +40-60,59-60 +8-96,8-97 +16-75,15-36 +33-73,34-73 +54-76,75-76 +49-87,86-87 +11-38,38-91 +40-69,68-69 +39-41,40-40 +90-90,64-90 +11-82,12-56 +28-90,89-90 +90-95,8-91 +9-92,10-91 +10-98,28-97 +29-30,30-91 +26-91,26-27 +7-91,69-92 +21-93,22-63 +6-8,7-35 +71-71,63-71 +39-47,13-48 +15-79,15-15 +9-73,9-73 +46-69,17-88 +16-97,18-86 +8-65,64-65 +1-44,2-43 +33-78,32-32 +23-97,40-97 +21-22,21-74 +93-93,10-93 +21-22,21-42 +2-5,5-18 +21-51,18-37 +38-92,47-77 +83-84,3-83 +16-94,15-95 +1-92,92-93 +1-98,98-98 +48-89,34-47 +9-44,10-45 +88-90,43-89 +3-16,17-29 +39-44,1-40 +41-67,38-75 +2-6,1-7 +8-67,9-55 +42-60,42-61 +18-52,31-51 +46-47,47-74 +24-69,23-24 +30-30,30-31 +1-84,83-84 +2-87,1-87 +9-50,9-51 +28-83,20-34 +19-47,40-51 +3-86,4-4 +17-79,1-2 +26-75,25-75 +8-16,17-54 +35-90,42-97 +1-18,23-62 +2-12,1-39 +13-90,12-96 +71-91,71-91 +23-60,12-24 +26-84,54-83 +18-24,18-25 +18-56,23-55 +32-59,31-33 +35-52,34-81 +22-72,22-71 +8-38,7-37 +34-69,69-69 +10-79,15-68 +16-87,24-28 +20-50,8-51 +6-52,52-84 +86-86,21-87 +26-94,26-93 +63-82,63-81 +5-18,17-91 +7-18,7-28 +10-36,10-95 +44-96,9-84 +48-51,49-62 +90-98,89-98 +31-31,32-56 +75-75,74-75 +28-80,79-92 +7-63,26-62 +4-5,5-18 +40-84,21-85 +43-51,42-44 +4-91,35-95 +51-73,51-52 +4-51,51-51 +80-80,52-80 +46-85,19-84 +9-11,10-36 +32-33,33-90 +3-92,4-92 +6-96,5-99 +77-78,66-78 +7-31,9-87 +11-70,32-69 +46-57,25-74 +4-42,41-42 +28-92,91-92 +7-23,21-22 +7-97,17-97 +12-94,6-13 +59-84,59-83 +46-46,47-78 +10-99,9-99 +1-73,13-72 +1-73,2-2 +15-91,16-84 +4-84,1-85 +3-98,2-98 +89-89,2-90 +16-96,16-96 +30-69,31-70 +16-68,73-89 +13-30,12-29 +27-97,98-99 +58-95,8-94 +18-18,17-83 +1-55,3-55 +37-43,42-89 +1-89,1-90 +51-53,23-52 +50-57,58-91 +95-96,25-96 +41-41,27-41 +26-76,59-77 +85-87,25-86 +14-62,15-63 +98-98,51-98 +81-98,50-97 +1-72,2-73 +1-4,3-64 +12-82,11-97 +6-24,24-24 +55-85,54-65 +6-68,67-69 +2-3,3-73 +4-91,4-86 +36-99,35-99 +10-79,21-78 +20-39,39-97 +7-82,6-8 +58-91,38-58 +13-63,14-39 +42-44,43-96 +84-95,82-84 +29-65,30-65 +44-58,57-58 +8-34,34-35 +11-36,11-35 +26-94,72-93 +12-26,14-88 +3-91,4-89 +6-6,5-99 +96-97,95-96 +38-51,30-45 +20-98,21-77 +16-98,16-97 +5-97,12-12 +14-25,25-92 +30-65,30-31 +52-53,35-53 +71-73,22-94 +6-96,3-99 +8-42,7-7 +28-96,29-97 +67-91,90-92 +3-95,12-95 +8-98,9-9 +27-27,26-87 +7-79,78-79 +36-90,36-89 +84-85,21-84 +69-69,68-92 +19-98,61-99 +16-98,98-99 +1-96,95-96 +16-84,16-85 +18-87,87-88 +92-97,85-95 +13-83,83-84 +20-67,3-21 +23-71,55-72 +62-97,61-61 +82-91,51-81 +24-25,25-93 +58-58,59-99 +39-93,38-93 +7-64,14-63 +35-99,36-98 +89-89,29-90 +77-78,67-78 +3-90,89-90 +26-90,26-89 +22-38,22-37 +66-66,65-94 +71-75,68-74 +47-93,7-93 +9-90,73-87 +39-39,38-82 +27-40,33-39 +66-93,67-92 +9-86,86-87 +13-95,34-94 +47-78,14-46 +2-96,2-96 +4-30,23-29 +9-88,21-89 +2-61,2-60 +15-69,15-68 +20-91,20-90 +38-77,70-76 +8-65,9-9 +96-97,14-97 +55-67,67-67 +12-78,26-83 +1-95,1-1 +56-99,64-98 +1-56,13-57 +14-84,8-96 +37-38,38-76 +4-99,5-5 +46-87,27-86 +80-80,4-80 +9-25,25-78 +33-85,34-35 +26-77,70-76 +68-98,67-98 +8-12,17-66 +2-41,2-42 +8-46,47-47 +8-92,5-8 +1-5,5-98 +6-94,7-7 +96-97,73-96 +19-51,50-51 +30-95,31-85 +16-91,17-91 +11-13,12-62 +2-99,3-99 +44-91,58-90 +28-63,1-18 +46-92,19-52 +37-54,3-55 +67-68,68-82 +2-99,98-99 +8-40,40-40 +7-58,6-58 +9-75,9-75 +4-39,39-39 +16-70,16-71 +27-82,81-82 +38-83,38-82 +4-76,75-97 +5-42,6-41 +43-82,82-82 +27-27,26-77 +14-14,13-74 +17-87,87-94 +14-78,13-62 +54-85,53-86 +1-15,1-95 +69-79,70-74 +5-86,10-85 +29-39,49-78 +41-99,41-42 +15-95,14-15 +32-78,33-78 +16-94,21-93 +5-5,4-94 +1-65,8-64 +2-99,5-98 +34-59,38-58 +36-43,7-36 +5-21,20-62 +11-92,7-7 +23-91,24-91 +6-90,5-91 +18-60,15-64 +40-87,39-41 +58-81,57-58 +3-88,4-88 +49-50,32-49 +28-34,27-90 +30-38,5-31 +8-91,7-92 +43-81,44-81 +10-97,9-99 +3-86,2-3 +80-98,4-92 +2-2,1-99 +15-41,15-42 +27-28,27-83 +9-83,4-10 +48-90,47-90 +31-67,2-32 +80-80,5-80 +10-85,10-84 +30-84,29-29 +16-45,17-45 +34-35,34-41 +28-30,29-68 +9-25,25-69 +65-66,56-66 +19-36,20-20 +53-53,53-98 +6-22,10-60 +29-29,28-93 +20-56,54-55 +8-83,8-83 +13-87,87-88 +40-81,24-66 +82-83,30-82 +68-70,1-69 +88-89,20-88 +1-99,2-99 +4-73,5-55 +71-72,18-72 +47-47,28-47 +53-69,52-69 +14-29,28-29 +53-82,83-87 +3-4,10-19 +59-93,1-92 +23-94,23-95 +27-56,26-26 +58-94,57-59 +87-87,49-88 +75-78,69-89 +18-96,19-87 +3-98,90-99 +29-45,45-58 +2-66,58-65 +15-76,14-88 +2-92,92-92 +31-79,32-79 +9-98,9-99 +7-90,6-99 +19-19,18-72 +86-86,85-98 +10-13,12-93 +2-47,48-51 +9-62,1-9 +6-95,6-94 +4-98,7-97 +80-99,99-99 +34-71,50-57 +48-67,31-66 +53-88,53-53 +5-55,5-54 +56-60,55-55 +13-45,12-45 +4-78,5-45 +52-84,84-84 +52-98,52-97 +7-8,9-92 +1-98,2-17 +42-79,9-80 +57-64,38-59 +31-37,37-72 +21-99,1-25 diff --git a/4_1.py b/4_1.py new file mode 100644 index 0000000..047b923 --- /dev/null +++ b/4_1.py @@ -0,0 +1,32 @@ +""" +Calculate the number of assignment pairs, where +one range fully contains the other. +""" + +contained = 0 + +with open("4.in") as fh: + for line in fh: + line = line.strip() + + elves = [] + for elf in line.split(","): + elf_s, elf_e = [int(x) for x in elf.split("-")] + elves.append({ + "start": elf_s, + "end": elf_e + }) + + elf0_contains_elf1 = ( + elves[0]["start"] <= elves[1]["start"] + and elves[0]["end"] >= elves[1]["end"] + ) + elf1_contains_elf0 = ( + elves[1]["start"] <= elves[0]["start"] + and elves[1]["end"] >= elves[0]["end"] + ) + + if elf0_contains_elf1 or elf1_contains_elf0: + contained += 1 + +print(contained) diff --git a/4_2.py b/4_2.py new file mode 100644 index 0000000..55b394a --- /dev/null +++ b/4_2.py @@ -0,0 +1,30 @@ +""" +Calculate the number of assignment pairs, where +one range fully contains the other. +""" + +overlaps = 0 + +def compare(elf0, elf1): + return elf1["start"] <= elf0["start"] <= elf1["end"] + + +with open("4.in") as fh: + for line in fh: + line = line.strip() + + elves = [] + for elf in line.split(","): + elf_s, elf_e = [int(x) for x in elf.split("-")] + elves.append({ + "start": elf_s, + "end": elf_e + }) + + elf0_overlaps = compare(elves[0], elves[1]) + elf1_overlaps = compare(elves[1], elves[0]) + + if elf0_overlaps or elf1_overlaps: + overlaps += 1 + +print(overlaps) diff --git a/5.in b/5.in new file mode 100644 index 0000000..6b8d095 --- /dev/null +++ b/5.in @@ -0,0 +1,512 @@ + [V] [G] [H] +[Z] [H] [Z] [T] [S] +[P] [D] [F] [B] [V] [Q] +[B] [M] [V] [N] [F] [D] [N] +[Q] [Q] [D] [F] [Z] [Z] [P] [M] +[M] [Z] [R] [D] [Q] [V] [T] [F] [R] +[D] [L] [H] [G] [F] [Q] [M] [G] [W] +[N] [C] [Q] [H] [N] [D] [Q] [M] [B] + 1 2 3 4 5 6 7 8 9 + +move 3 from 2 to 5 +move 2 from 9 to 6 +move 4 from 7 to 1 +move 7 from 3 to 4 +move 2 from 9 to 8 +move 8 from 8 to 6 +move 1 from 7 to 4 +move 8 from 6 to 4 +move 4 from 5 to 7 +move 3 from 4 to 9 +move 2 from 6 to 3 +move 11 from 4 to 1 +move 1 from 3 to 4 +move 2 from 3 to 1 +move 1 from 7 to 6 +move 14 from 1 to 6 +move 7 from 4 to 3 +move 2 from 5 to 9 +move 5 from 6 to 4 +move 9 from 6 to 1 +move 3 from 4 to 8 +move 1 from 7 to 6 +move 3 from 4 to 1 +move 7 from 3 to 8 +move 5 from 9 to 5 +move 4 from 1 to 4 +move 3 from 7 to 2 +move 5 from 6 to 2 +move 3 from 4 to 1 +move 7 from 8 to 5 +move 3 from 6 to 8 +move 11 from 2 to 1 +move 1 from 4 to 3 +move 1 from 3 to 9 +move 2 from 2 to 9 +move 8 from 5 to 4 +move 1 from 1 to 7 +move 1 from 9 to 5 +move 8 from 4 to 1 +move 1 from 6 to 8 +move 2 from 9 to 1 +move 4 from 5 to 3 +move 2 from 7 to 3 +move 40 from 1 to 2 +move 24 from 2 to 9 +move 1 from 5 to 6 +move 11 from 2 to 3 +move 9 from 3 to 5 +move 12 from 9 to 4 +move 6 from 5 to 7 +move 4 from 7 to 4 +move 2 from 5 to 1 +move 2 from 1 to 9 +move 1 from 6 to 8 +move 9 from 4 to 8 +move 6 from 4 to 9 +move 17 from 9 to 6 +move 1 from 4 to 6 +move 17 from 6 to 5 +move 1 from 1 to 4 +move 2 from 7 to 9 +move 1 from 6 to 7 +move 2 from 2 to 9 +move 2 from 7 to 2 +move 6 from 3 to 8 +move 3 from 5 to 9 +move 1 from 4 to 9 +move 2 from 3 to 7 +move 4 from 5 to 6 +move 1 from 7 to 4 +move 1 from 4 to 2 +move 1 from 7 to 5 +move 9 from 8 to 1 +move 1 from 1 to 2 +move 2 from 9 to 3 +move 7 from 2 to 7 +move 1 from 9 to 5 +move 12 from 8 to 7 +move 3 from 1 to 9 +move 2 from 6 to 4 +move 9 from 9 to 3 +move 1 from 6 to 7 +move 1 from 9 to 5 +move 1 from 6 to 1 +move 9 from 7 to 1 +move 7 from 1 to 8 +move 4 from 3 to 9 +move 5 from 7 to 1 +move 3 from 9 to 1 +move 4 from 7 to 2 +move 12 from 1 to 5 +move 2 from 9 to 4 +move 7 from 8 to 2 +move 7 from 5 to 7 +move 4 from 3 to 4 +move 1 from 8 to 1 +move 2 from 2 to 1 +move 2 from 3 to 1 +move 3 from 2 to 7 +move 13 from 5 to 4 +move 1 from 8 to 3 +move 1 from 3 to 8 +move 1 from 3 to 5 +move 1 from 8 to 7 +move 17 from 4 to 8 +move 5 from 2 to 6 +move 2 from 1 to 6 +move 5 from 6 to 3 +move 9 from 7 to 1 +move 4 from 4 to 3 +move 1 from 6 to 2 +move 4 from 7 to 4 +move 1 from 6 to 5 +move 2 from 3 to 2 +move 15 from 1 to 4 +move 6 from 5 to 4 +move 4 from 3 to 5 +move 4 from 5 to 2 +move 2 from 2 to 4 +move 11 from 8 to 1 +move 2 from 8 to 3 +move 5 from 3 to 7 +move 4 from 2 to 8 +move 2 from 2 to 9 +move 4 from 7 to 8 +move 11 from 4 to 6 +move 2 from 5 to 4 +move 3 from 6 to 9 +move 4 from 1 to 4 +move 15 from 4 to 9 +move 1 from 7 to 3 +move 2 from 1 to 2 +move 6 from 4 to 5 +move 11 from 8 to 2 +move 16 from 9 to 4 +move 2 from 9 to 1 +move 4 from 2 to 3 +move 8 from 4 to 9 +move 1 from 8 to 7 +move 5 from 4 to 7 +move 6 from 7 to 3 +move 10 from 9 to 5 +move 5 from 3 to 1 +move 1 from 1 to 4 +move 5 from 1 to 9 +move 5 from 1 to 7 +move 5 from 4 to 1 +move 4 from 1 to 6 +move 3 from 1 to 9 +move 10 from 5 to 9 +move 2 from 7 to 1 +move 5 from 3 to 6 +move 4 from 5 to 7 +move 4 from 2 to 6 +move 2 from 5 to 6 +move 5 from 2 to 7 +move 18 from 6 to 1 +move 5 from 9 to 2 +move 7 from 9 to 6 +move 16 from 1 to 7 +move 4 from 6 to 1 +move 1 from 2 to 6 +move 2 from 2 to 6 +move 1 from 2 to 4 +move 4 from 9 to 3 +move 1 from 2 to 8 +move 5 from 7 to 5 +move 2 from 9 to 3 +move 1 from 5 to 9 +move 7 from 3 to 4 +move 1 from 9 to 7 +move 8 from 1 to 9 +move 1 from 8 to 9 +move 3 from 6 to 9 +move 17 from 7 to 5 +move 3 from 4 to 8 +move 3 from 4 to 2 +move 3 from 8 to 3 +move 3 from 3 to 7 +move 7 from 9 to 3 +move 6 from 5 to 9 +move 4 from 9 to 3 +move 10 from 7 to 2 +move 15 from 5 to 2 +move 4 from 6 to 3 +move 1 from 3 to 2 +move 23 from 2 to 5 +move 2 from 4 to 6 +move 2 from 6 to 7 +move 1 from 7 to 2 +move 1 from 6 to 9 +move 5 from 9 to 8 +move 3 from 8 to 7 +move 5 from 2 to 6 +move 2 from 2 to 3 +move 2 from 6 to 3 +move 3 from 6 to 2 +move 3 from 6 to 8 +move 10 from 5 to 9 +move 2 from 7 to 5 +move 1 from 5 to 8 +move 13 from 9 to 5 +move 6 from 5 to 6 +move 1 from 6 to 1 +move 1 from 7 to 3 +move 1 from 7 to 3 +move 13 from 5 to 6 +move 3 from 3 to 5 +move 1 from 2 to 1 +move 4 from 8 to 9 +move 2 from 2 to 6 +move 2 from 5 to 3 +move 2 from 3 to 6 +move 5 from 6 to 4 +move 9 from 5 to 9 +move 10 from 6 to 9 +move 1 from 1 to 7 +move 3 from 3 to 9 +move 1 from 8 to 1 +move 3 from 6 to 3 +move 1 from 7 to 6 +move 1 from 8 to 7 +move 2 from 6 to 1 +move 2 from 6 to 4 +move 3 from 4 to 6 +move 2 from 1 to 4 +move 10 from 9 to 6 +move 6 from 4 to 9 +move 17 from 9 to 1 +move 4 from 9 to 5 +move 19 from 1 to 7 +move 4 from 5 to 6 +move 1 from 9 to 3 +move 5 from 3 to 4 +move 5 from 4 to 8 +move 17 from 6 to 9 +move 17 from 9 to 2 +move 1 from 6 to 1 +move 1 from 1 to 2 +move 1 from 8 to 3 +move 2 from 3 to 2 +move 5 from 7 to 1 +move 1 from 7 to 3 +move 5 from 2 to 9 +move 4 from 8 to 2 +move 2 from 7 to 8 +move 3 from 9 to 3 +move 7 from 3 to 9 +move 2 from 8 to 7 +move 8 from 2 to 9 +move 5 from 9 to 6 +move 4 from 3 to 9 +move 11 from 2 to 3 +move 2 from 6 to 5 +move 1 from 9 to 4 +move 10 from 7 to 3 +move 3 from 1 to 8 +move 2 from 6 to 7 +move 15 from 3 to 8 +move 2 from 3 to 2 +move 2 from 1 to 3 +move 14 from 9 to 6 +move 1 from 4 to 9 +move 14 from 6 to 3 +move 5 from 7 to 2 +move 2 from 9 to 2 +move 1 from 5 to 3 +move 1 from 5 to 8 +move 12 from 3 to 7 +move 13 from 7 to 8 +move 1 from 6 to 7 +move 5 from 2 to 6 +move 1 from 6 to 2 +move 1 from 7 to 6 +move 4 from 6 to 8 +move 31 from 8 to 7 +move 15 from 7 to 8 +move 7 from 7 to 5 +move 4 from 2 to 3 +move 1 from 6 to 2 +move 3 from 5 to 8 +move 9 from 7 to 4 +move 2 from 2 to 9 +move 4 from 5 to 6 +move 13 from 3 to 9 +move 3 from 3 to 5 +move 13 from 9 to 1 +move 1 from 3 to 2 +move 2 from 6 to 5 +move 1 from 3 to 4 +move 2 from 6 to 5 +move 1 from 9 to 1 +move 6 from 8 to 9 +move 5 from 5 to 2 +move 2 from 9 to 8 +move 2 from 1 to 6 +move 1 from 9 to 4 +move 12 from 8 to 4 +move 2 from 6 to 9 +move 11 from 4 to 3 +move 9 from 4 to 2 +move 4 from 9 to 7 +move 2 from 5 to 6 +move 8 from 3 to 4 +move 2 from 3 to 9 +move 2 from 8 to 9 +move 4 from 4 to 9 +move 2 from 6 to 7 +move 1 from 3 to 7 +move 2 from 9 to 1 +move 5 from 4 to 2 +move 9 from 1 to 8 +move 1 from 4 to 9 +move 4 from 9 to 3 +move 1 from 3 to 6 +move 4 from 8 to 7 +move 1 from 3 to 6 +move 4 from 1 to 7 +move 1 from 3 to 8 +move 1 from 1 to 8 +move 2 from 6 to 7 +move 2 from 9 to 1 +move 1 from 4 to 5 +move 1 from 1 to 5 +move 11 from 8 to 4 +move 12 from 2 to 8 +move 1 from 9 to 8 +move 2 from 4 to 5 +move 1 from 1 to 8 +move 5 from 2 to 1 +move 1 from 3 to 2 +move 9 from 7 to 3 +move 6 from 7 to 5 +move 1 from 3 to 4 +move 1 from 5 to 1 +move 4 from 2 to 5 +move 4 from 4 to 1 +move 2 from 7 to 3 +move 3 from 4 to 1 +move 6 from 3 to 7 +move 9 from 8 to 7 +move 3 from 8 to 7 +move 11 from 5 to 9 +move 2 from 4 to 8 +move 5 from 8 to 7 +move 1 from 9 to 8 +move 12 from 9 to 5 +move 1 from 4 to 5 +move 5 from 1 to 8 +move 6 from 8 to 3 +move 1 from 3 to 8 +move 3 from 7 to 9 +move 4 from 7 to 6 +move 3 from 1 to 3 +move 3 from 1 to 6 +move 1 from 8 to 1 +move 7 from 6 to 2 +move 3 from 1 to 8 +move 7 from 3 to 4 +move 3 from 4 to 1 +move 1 from 4 to 2 +move 3 from 1 to 2 +move 1 from 7 to 6 +move 1 from 8 to 5 +move 9 from 5 to 3 +move 1 from 6 to 9 +move 11 from 3 to 6 +move 1 from 4 to 1 +move 1 from 3 to 4 +move 8 from 6 to 9 +move 1 from 3 to 1 +move 1 from 9 to 1 +move 2 from 6 to 2 +move 5 from 5 to 7 +move 5 from 9 to 3 +move 2 from 8 to 5 +move 1 from 1 to 2 +move 1 from 9 to 1 +move 15 from 7 to 4 +move 1 from 1 to 6 +move 1 from 6 to 9 +move 3 from 9 to 3 +move 1 from 3 to 5 +move 5 from 5 to 3 +move 9 from 2 to 9 +move 5 from 4 to 1 +move 1 from 6 to 7 +move 7 from 9 to 3 +move 1 from 4 to 7 +move 1 from 9 to 6 +move 1 from 6 to 5 +move 2 from 1 to 4 +move 3 from 9 to 3 +move 1 from 5 to 6 +move 7 from 4 to 3 +move 1 from 9 to 3 +move 16 from 3 to 1 +move 9 from 1 to 3 +move 5 from 4 to 2 +move 1 from 6 to 9 +move 12 from 1 to 9 +move 3 from 2 to 9 +move 5 from 7 to 3 +move 2 from 4 to 8 +move 2 from 7 to 2 +move 12 from 3 to 5 +move 6 from 2 to 9 +move 12 from 3 to 1 +move 2 from 8 to 6 +move 1 from 6 to 1 +move 6 from 5 to 8 +move 5 from 3 to 2 +move 2 from 5 to 8 +move 8 from 1 to 8 +move 13 from 9 to 7 +move 4 from 7 to 5 +move 4 from 1 to 4 +move 8 from 5 to 6 +move 1 from 1 to 6 +move 4 from 7 to 3 +move 1 from 3 to 1 +move 1 from 1 to 9 +move 4 from 9 to 5 +move 3 from 3 to 7 +move 12 from 8 to 7 +move 2 from 4 to 3 +move 2 from 6 to 9 +move 4 from 8 to 2 +move 2 from 3 to 9 +move 2 from 4 to 7 +move 3 from 5 to 7 +move 2 from 9 to 7 +move 3 from 6 to 1 +move 4 from 6 to 7 +move 1 from 5 to 4 +move 1 from 9 to 3 +move 12 from 2 to 5 +move 4 from 9 to 7 +move 11 from 5 to 1 +move 1 from 6 to 5 +move 1 from 1 to 4 +move 10 from 1 to 2 +move 2 from 5 to 1 +move 1 from 3 to 5 +move 7 from 2 to 5 +move 8 from 7 to 8 +move 2 from 2 to 8 +move 3 from 9 to 4 +move 5 from 4 to 3 +move 1 from 5 to 7 +move 3 from 7 to 1 +move 3 from 5 to 8 +move 1 from 2 to 5 +move 12 from 7 to 6 +move 4 from 1 to 3 +move 2 from 5 to 6 +move 7 from 3 to 7 +move 14 from 6 to 4 +move 1 from 5 to 6 +move 3 from 1 to 3 +move 4 from 3 to 2 +move 2 from 5 to 8 +move 11 from 7 to 4 +move 7 from 4 to 5 +move 1 from 3 to 4 +move 1 from 5 to 6 +move 14 from 8 to 7 +move 11 from 7 to 3 +move 2 from 2 to 6 +move 1 from 2 to 3 +move 5 from 5 to 4 +move 4 from 6 to 4 +move 8 from 7 to 8 +move 3 from 7 to 3 +move 1 from 2 to 1 +move 5 from 8 to 2 +move 4 from 4 to 3 +move 1 from 2 to 9 +move 1 from 1 to 9 +move 3 from 2 to 1 +move 1 from 5 to 4 +move 3 from 8 to 1 +move 1 from 7 to 4 +move 4 from 3 to 9 +move 1 from 8 to 7 +move 2 from 9 to 1 +move 6 from 3 to 4 +move 28 from 4 to 7 +move 15 from 7 to 8 +move 3 from 3 to 8 +move 1 from 2 to 9 +move 2 from 3 to 2 +move 7 from 1 to 4 +move 10 from 4 to 5 +move 10 from 5 to 6 +move 3 from 8 to 2 +move 1 from 1 to 7 +move 1 from 4 to 7 +move 1 from 9 to 6 +move 9 from 6 to 7 +move 1 from 2 to 4 +move 1 from 9 to 5 diff --git a/5.py b/5.py new file mode 100644 index 0000000..27fe274 --- /dev/null +++ b/5.py @@ -0,0 +1,75 @@ +def move_9000(source, destination, n): + for i in range(n): + destination.append(source.pop()) + + +def move_9001(source, destination, n): + things_to_move = source[-n:] + destination.extend(things_to_move) + + for i in range(n): + source.pop() + + +def one(): + """Figure out which crate is on top""" + with open("5.in") as fh: + stacks = [] + for i in range(9): + stacks.append([]) + + for line in fh: + if line.strip() == "": + break + + for stack in range(1, 10): + index = 1 + (stack - 1) * 4 + char = line[index] + if char in '1234567890': + break + + if char != " ": + stacks[stack - 1].append(char) + + for stack in stacks: + stack.reverse() + + for line in fh: + _, n, __, source, ___, destination = line.split(" ") + move_9000(stacks[int(source) - 1], stacks[int(destination) - 1], int(n)) + + for stack in stacks: + print(stack[-1]) + + +def two(): + """Figure out which crate is on top""" + with open("5.in") as fh: + stacks = [] + for i in range(9): + stacks.append([]) + + for line in fh: + if line.strip() == "": + break + + for stack in range(1, 10): + index = 1 + (stack - 1) * 4 + char = line[index] + if char in '1234567890': + break + + if char != " ": + stacks[stack - 1].append(char) + + for stack in stacks: + stack.reverse() + + for line in fh: + _, n, __, source, ___, destination = line.split(" ") + move_9001(stacks[int(source) - 1], stacks[int(destination) - 1], int(n)) + + for stack in stacks: + print(stack[-1]) + +two() diff --git a/6.in b/6.in new file mode 100644 index 0000000..86395e5 --- /dev/null +++ b/6.in @@ -0,0 +1 @@ +tnmmpfmfzmmnsmsjmjjbvvhnhzzfmmgpmgpgbgnnwffjhffzqqmzzbnbssrqqrnnhsnngsszsqzszhzfhzfzwzfzrrmhmghgwhhjjqwqttwhttjllrtrtzzcfzfgzznfznfzfnnbddvmvzmmfsmfsmfffhlfldlqqrnrznnhmmgqqzhhmjhmhppqbpbbngnlldvvdqvvrtrdrtrnttnppfllrbbrprpnpdplpmllhwwddqpdprddzzfccqpcqpcpcbbdhdjdjwjcwcctdcttzgzmmscmsmdmttwhwzhhnjhnhlhvhlvlglpgpmmjmgmrgrddmwddjfftfwflfslffqtfqttpftppflfmmhvhvcvbvhbhggpbgbppvdpvpvfppbwwsnnhphllbdbnbvbmvvzffvsffdldmlmtmccnlnbnjbnjnhhbfhhgzzlwlfflzffdccggdcgcjjhffjfgfgcczjccvwcvvqgvvqvllqzqmqllhjjqnqggttsdddjgdjgjzzrgrfrbrssrgrgdgrgbbssmdsdfddsndnsdnsdnnmqqsspqqmrqqpmmsjmmszzqvqrvrzznnjdndtntfnttgtctqtwwnwswrrthrttsdttlhlvvdzzgqgttnppjpljplpgpvgvqqvppzmmqggtjgtgstslltjltjjgcjcmjmsshvvtppgmmlslqqshqshsllbggfpgffdsdgssncchctcwwtllgqlqblqlqvvmsvmmwnnzppqllsttgmttftvfvjjrzzswzzjvzjzljjchcshcscbbrdbrbcrrnvvtctntvtvbvjvqjqggsrspsprrbgghdghhmwwldldzdttrvrnrfftqtftrrdsszlzvvbtbffftzzrzqrrhjhghhwbhhsjsfsttdjdjnjhjmjpmplplrrdjdcdjdbjblllbqlqdlqlpqptppdhhqmqfqhqhchwwqjqfjqfqhqshsmswsbbvssdspdpsdssstntltrrgnnmttgmmsjjrlrnlrnrnwrwfwlfltlzllcjcmjcjpjhphcpcwppmvmjjzbzvbbfnfcflfddntddbmmmhnnsrnrrvdvnvcvwvcwvwrrqwqccqmmswmmjrjmmwjmjfjhwrtbjzdvlgrjmvzfmhcqsncvlhzzncjlbvcwrdwjmqjcnptqslvfzpsvltgzsvjdsjrppdrmqrbqwhddfhnftfblspsrhtdtjwdnhbcbtlwlvccsfscvczzrrqmwbwbdmwgzqntvflppqvppwrhnvtlsbzqglhsfdgssqzdtjdpwrrhbnbtwhhnmnlwfwlqffjjrndbpwwsvdrhddbjnnqzmtpvvtwbcpndjzlhcfrrdvmljswjzvmfqcdsgqwclqshwrmblszdvsnrpdgnllmlchzdjlrrpndmmgddjqgjqrhwfbwddqdfbvptrmzhtsqfsfswpnvmtswqprjhbzvntgrlzthhnqbtpplqpvcfnpgdtbhqbhflltbbtmmhcwztslmpznttmssclhmnbsbrwlblrbsdfmnpqbwwmsncvzmpqwhzjgcgdrzvglgdtswmstdhrprdjfmqtjlmplbjtzcgnrwpdvpfjjfwjfnnpmdtwtqsgfndngsbmcwjtglqwtfrclbczfcmjtgcwszhzrbcphrhwmhcwghjznzthnwpljjltdlvqtffsrbmwcsvrdmqqggbznnlzbbqtgspqvnjpbdhtzmgttrcwwszwpgdrcnfqtgrgqdrctlzwtdwqppbhnwgldnqltznnfpbfqtgmmwpcqnndbgmrrtgtvnmlfcwsldchjnnqfrhpzwtclrzftsqllgvpqbgmfjdhqjttwcvbpvfqsvhbhhtwnqnbgndbtzhcvgglbhghbzrbrmdllmgfgttqmhtdnwrpwllhnghrjctrbzrcpnjnctvmrlpjhftnfbczrjrnnbqplplcrbngbhvmmvcffmgvbhjzbhcmtwmwgmjmwjvvlqfldswpntjnsjvmdlbzqqlgbwspwvmnwtwjbczmwplrhmjgsppnmtwmvsfwnsgddgwqcvpftcpzrhpldnwmcjgtjmljjbcmjcqdbwczndnjnjgrmtjrqnnjndzqdqpcgdqptdbrqftnwrgqmrzrvsfmmmbpltlncvtgrjfjmvtgwqphczwjhdrdwtfvgztbhrndvpcbgfjfvmrrljwrvcrtdmtjndfnwgcnfrzgsnjpztbwwsbvqfnpjctgrhsflhnzbbsfqbnmtnvrmjzsbjfndvttpvpfjhqntflgbfnzcclcwmhbsgqfjdcgsvrhtstspfzgvgglgddqmclsmzgzgtncdsfmwdvtcsgwvbzjvclwppqdjgfcrcbzcwbdhrnssjbmnmfmwthdrnmlfhqlddwqrdhsdvdcsmcgjsgcmpnhlbnqftpdjswtmpbznlcrhtswgnmwjcdfmljdngzfsmlzjjnzmfzshmztdbdmcqwmlvcrzgpmbjqcghclwvdbrhgvwqchnndftnrtptmctdlhmfjvpzrpccddfpcdwmzqfhnsqzrvwblzfhcjdcjfctczwqrcbjnrpdcbbnsgnlvqqmnsfgsqschjlbzhhsrbvdbfrhvsgrlzwncgwpdbvmblgzbwbcbgqfwmdmgcrbbjfcvmqgztqpptdhwmvmsdqwplpgcjzgqzdrftzhqbltvhrmlrfffcgfpqzwrrbbtlsjgmtbjvtnmhwdpjptjwfwgjgvbfqwmflrrqzlzdcmtlnptdrpcpdnswcfscnndnrfbgwvvncdjgsdpbwptdtvrqlmrhmvvcwblhhzbjdpsbszhrftfbcgwhwrgglnjzqdhcqnvlhgqjhnddvrslhntssptsbhmqwwqqnbvfmcbgpvgjbrttnvlljdbtfplgmbwtcbcdtqdpqqdvhbmpmtszwpzblcfrtznhhtcljtdlhjdbnlhvwgjsmgvrslrfwnmzwlstpgltvrgnpdqztvfnvdhdtwwqdfsmtpbpdclsbnwcgjzchjcsjmvhbjshmjjlpgdzcgbmmchwmcsddsvhsnpqtcpnhqnbvwgwqhtjbqncgwwftnrzsbsjtvqmjzqvvncmncwflcfpcjqgdtbsmjzzsdjfvhnqbgjhmfgjghwscthbfmbndltbqzwpqtmrswvprpmgwqnqpfnmffrpdlpfqmhrthppzvzwbrtjvwvjndsqdlqtbpqwfcttggnjmcqqnmjwfhfjgcvlnmtlgbdvmctzlwbfgnflwtsflgnfbnfbhhdgjctzvvmrhdsmvmmtnqwtszmqcpsbrqrgjfrzctcbzmtdlhwjtfdqbtthdnqcrpwrhcrvjstbhpltvgmvpmvfjstgzjsgzprzcqzqztvvdcnrrqwrhddcrhhncdrlwzwqlnbbzcfmqtnwgfdscmrbwnbldlfrqchzdnlnmwncgrzdclnvcvplgwjsbzmbnnsdrsfhrlssvncnwmcrjdjbjpdtrrvlnbjvspfqbwdpcnnpjzfnmbhcdhlmdgbpvbzmfltzstnznfctcdzhbfsvnfbsjqzmwfllhtrsfghlrpjgrgzgchlwrdmqzbrncsvnwhfqmwjbnvjctzphcsftqsbmwntgvjqhhvwndvmfmjhhhmfdvrlhpvzmmhrbhbddqbdmgqqsvddsswmzqcjmvhztfqpchzpwhdshzjlmbmnsgzqhbnmrshwvtmgmgndtddpfwsjrrjdhncdhtlczdvlbvqplttnzrblthlcffdtfsdtpwzdgbldvnsttvpzmbgnqddrszftcpwrgmfzhjjvghpntmzcttcsnrjnfpqzqqqljhzlrpgwngllqjwnwfcsphqplgbzmfqfgbfsqpsrntszqbcqnhctsnbfshmlbwfflrwwsjwqwfqlgnftdwmctmclwjhjhbsspqldlshbmpbgrftpnbpsqldhrrbdqwfwvfhclrlfdjfmzgmptdjdcsplcspznfjrfhtsjndwpslrdgnllllwqjgznrhswfssdlvdpmwwgmstqbhfmdhtzvzzvhwzbrrvvsl diff --git a/6_1.py b/6_1.py new file mode 100644 index 0000000..086ddef --- /dev/null +++ b/6_1.py @@ -0,0 +1,18 @@ +#!/usr/bin/python + +with open("6.in") as fh: + for line in fh: + line = line.strip() + + start = 0 + end = 14 + for i in range(len(line)): + window = line[start:end] + if len(set(window)) == 14: + print(end) + break + else: + start += 1 + end += 1 + + -- 2.47.1