From fb54beb2bef7fe6b0d4e524b03c61d3f94ffee09 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Thu, 6 Jan 2022 13:05:05 +0100 Subject: init --- day01/day01 | Bin 0 -> 79296 bytes day01/day01.cpp | 52 ++ day01/day01_input.txt | 2000 ++++++++++++++++++++++++++++++++++++++++++++++ day01/day01_input_ez.txt | 10 + day01/makefile | 2 + day02/day02 | Bin 0 -> 47672 bytes day02/day02.cpp | 50 ++ day02/day02_input.txt | 1000 +++++++++++++++++++++++ day02/makefile | 2 + day03/day03 | Bin 0 -> 83112 bytes day03/day03.cpp | 96 +++ day03/day03_input.txt | 1000 +++++++++++++++++++++++ day03/day03_input_ez.txt | 12 + day03/makefile | 2 + day04/day04 | Bin 0 -> 116280 bytes day04/day04.cpp | 134 ++++ day04/day04_input.txt | 601 ++++++++++++++ day04/day04_input_ez.txt | 19 + day04/makefile | 2 + 19 files changed, 4982 insertions(+) create mode 100755 day01/day01 create mode 100644 day01/day01.cpp create mode 100644 day01/day01_input.txt create mode 100644 day01/day01_input_ez.txt create mode 100644 day01/makefile create mode 100755 day02/day02 create mode 100644 day02/day02.cpp create mode 100644 day02/day02_input.txt create mode 100644 day02/makefile create mode 100755 day03/day03 create mode 100644 day03/day03.cpp create mode 100644 day03/day03_input.txt create mode 100644 day03/day03_input_ez.txt create mode 100644 day03/makefile create mode 100755 day04/day04 create mode 100644 day04/day04.cpp create mode 100644 day04/day04_input.txt create mode 100644 day04/day04_input_ez.txt create mode 100644 day04/makefile diff --git a/day01/day01 b/day01/day01 new file mode 100755 index 0000000..8fb500a Binary files /dev/null and b/day01/day01 differ diff --git a/day01/day01.cpp b/day01/day01.cpp new file mode 100644 index 0000000..113f86d --- /dev/null +++ b/day01/day01.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +std::string read (char* name) { + FILE *f = fopen(name, "r"); + char c = fgetc(f); std::string txt; + while (c != EOF) { txt += c; c = fgetc(f); } + fclose(f); + return txt; +} + +std::vector split (std::vector vec, std::string name) { + auto token = name.find("\n"); + if (token != std::string::npos) { + vec.push_back(name.substr(0, token)); + return split(vec, name.substr(token+1)); + } else if (name.size() > 1) { + vec.push_back(name); + } + return vec; +} + +int main (int argc, char* argv[]) { + if (argc < 2 && argc > 3) return 1; + std::string txt = read(argv[1]); + + std::vector vec; + vec = split(vec, txt); + std::vector depths; + for (auto v : vec) { + depths.push_back(std::stoi(v)); + } + + int window = 1; + if (argc == 3) { window = atoi(argv[2]); } + + int inc = 0; + for (std::size_t i=0; i= window) { + int sum0 = 0, sum1 = 0; + for (int j=0; j sum0) inc ++; + } + } + + std::cout << "The number of depth increases is " << inc << std::endl; + + return 0; +} diff --git a/day01/day01_input.txt b/day01/day01_input.txt new file mode 100644 index 0000000..b3ee114 --- /dev/null +++ b/day01/day01_input.txt @@ -0,0 +1,2000 @@ +198 +208 +209 +212 +213 +217 +218 +223 +222 +224 +216 +233 +238 +239 +240 +250 +263 +264 +267 +274 +288 +316 +319 +330 +340 +347 +349 +354 +350 +349 +351 +352 +353 +371 +383 +385 +405 +413 +455 +451 +459 +458 +459 +461 +463 +475 +480 +486 +489 +497 +502 +512 +513 +516 +517 +528 +559 +560 +558 +565 +566 +567 +571 +573 +574 +582 +583 +585 +589 +597 +608 +607 +614 +619 +608 +624 +665 +666 +675 +695 +698 +703 +711 +733 +738 +739 +742 +743 +763 +775 +778 +804 +806 +810 +812 +818 +819 +828 +867 +866 +876 +878 +881 +875 +881 +858 +859 +868 +869 +860 +888 +890 +891 +893 +894 +919 +924 +925 +933 +937 +950 +955 +966 +984 +989 +993 +996 +997 +1015 +1031 +1035 +1039 +1055 +1057 +1058 +1059 +1060 +1061 +1067 +1069 +1070 +1059 +1060 +1077 +1079 +1078 +1080 +1087 +1088 +1090 +1097 +1082 +1102 +1105 +1106 +1120 +1125 +1130 +1132 +1154 +1141 +1135 +1131 +1133 +1134 +1137 +1138 +1141 +1142 +1143 +1166 +1175 +1193 +1201 +1236 +1238 +1234 +1240 +1242 +1243 +1271 +1276 +1277 +1272 +1286 +1288 +1290 +1292 +1317 +1341 +1361 +1363 +1375 +1376 +1377 +1383 +1387 +1390 +1402 +1404 +1412 +1418 +1426 +1429 +1466 +1480 +1483 +1478 +1484 +1486 +1488 +1491 +1486 +1489 +1492 +1517 +1520 +1523 +1539 +1546 +1551 +1521 +1517 +1518 +1522 +1525 +1526 +1539 +1540 +1544 +1545 +1561 +1571 +1572 +1574 +1575 +1568 +1573 +1587 +1588 +1600 +1603 +1627 +1629 +1633 +1645 +1670 +1671 +1685 +1690 +1696 +1698 +1703 +1698 +1699 +1702 +1714 +1716 +1709 +1738 +1753 +1761 +1766 +1769 +1772 +1761 +1763 +1774 +1781 +1782 +1799 +1802 +1816 +1818 +1819 +1805 +1810 +1817 +1819 +1831 +1834 +1835 +1852 +1855 +1858 +1859 +1856 +1857 +1868 +1885 +1891 +1893 +1890 +1891 +1892 +1893 +1896 +1911 +1912 +1914 +1916 +1914 +1918 +1930 +1932 +1958 +1966 +1976 +1982 +1985 +1986 +1987 +1992 +1997 +2031 +2041 +2042 +2044 +2058 +2060 +2075 +2073 +2084 +2087 +2090 +2125 +2128 +2129 +2130 +2131 +2136 +2137 +2145 +2150 +2152 +2155 +2161 +2162 +2165 +2167 +2189 +2197 +2199 +2214 +2226 +2233 +2234 +2241 +2242 +2256 +2259 +2263 +2257 +2267 +2270 +2269 +2272 +2273 +2275 +2279 +2284 +2285 +2266 +2271 +2287 +2291 +2310 +2313 +2314 +2317 +2311 +2312 +2311 +2312 +2326 +2331 +2332 +2338 +2340 +2352 +2355 +2360 +2361 +2357 +2371 +2384 +2380 +2392 +2393 +2396 +2397 +2400 +2417 +2420 +2421 +2422 +2444 +2457 +2458 +2464 +2467 +2494 +2495 +2498 +2510 +2514 +2521 +2526 +2525 +2533 +2536 +2547 +2544 +2547 +2556 +2557 +2558 +2561 +2570 +2571 +2573 +2575 +2583 +2584 +2585 +2572 +2574 +2575 +2587 +2589 +2590 +2602 +2603 +2604 +2605 +2589 +2603 +2608 +2611 +2616 +2613 +2617 +2618 +2619 +2628 +2629 +2630 +2631 +2639 +2645 +2649 +2657 +2665 +2673 +2680 +2679 +2680 +2702 +2703 +2709 +2711 +2714 +2715 +2716 +2715 +2721 +2720 +2739 +2745 +2748 +2752 +2749 +2748 +2749 +2751 +2752 +2750 +2760 +2777 +2778 +2779 +2780 +2787 +2800 +2805 +2810 +2812 +2820 +2821 +2843 +2846 +2853 +2862 +2861 +2867 +2880 +2890 +2891 +2892 +2885 +2887 +2890 +2894 +2897 +2925 +2926 +2931 +2933 +2940 +2943 +2941 +2959 +2971 +2982 +2984 +3002 +3006 +3008 +3012 +3013 +3034 +3043 +3059 +3063 +3064 +3060 +3075 +3090 +3091 +3104 +3108 +3114 +3117 +3106 +3104 +3110 +3113 +3114 +3126 +3119 +3138 +3140 +3141 +3143 +3139 +3145 +3147 +3153 +3161 +3170 +3168 +3180 +3181 +3177 +3196 +3210 +3216 +3232 +3233 +3234 +3235 +3239 +3240 +3242 +3243 +3244 +3243 +3248 +3249 +3275 +3276 +3278 +3280 +3286 +3291 +3293 +3294 +3301 +3310 +3319 +3326 +3338 +3339 +3348 +3366 +3376 +3371 +3372 +3404 +3407 +3408 +3425 +3444 +3451 +3457 +3452 +3459 +3468 +3491 +3475 +3476 +3481 +3505 +3516 +3519 +3542 +3543 +3541 +3542 +3541 +3551 +3553 +3552 +3533 +3542 +3543 +3561 +3562 +3563 +3566 +3571 +3572 +3596 +3600 +3603 +3607 +3608 +3609 +3613 +3654 +3665 +3672 +3661 +3662 +3663 +3670 +3676 +3683 +3707 +3709 +3714 +3717 +3709 +3710 +3713 +3714 +3715 +3716 +3735 +3749 +3763 +3770 +3784 +3782 +3786 +3790 +3792 +3794 +3803 +3805 +3819 +3823 +3826 +3828 +3838 +3839 +3843 +3870 +3877 +3888 +3889 +3891 +3892 +3893 +3894 +3880 +3860 +3878 +3880 +3888 +3893 +3898 +3904 +3906 +3907 +3910 +3918 +3927 +3946 +3973 +3982 +3979 +3980 +3993 +3984 +3988 +3986 +3987 +3988 +3989 +3997 +4000 +4001 +4025 +4030 +4034 +4038 +4040 +4044 +4046 +4048 +4057 +4067 +4079 +4092 +4094 +4122 +4124 +4128 +4127 +4128 +4132 +4136 +4141 +4146 +4151 +4153 +4163 +4167 +4168 +4170 +4172 +4176 +4177 +4178 +4194 +4198 +4199 +4201 +4203 +4204 +4205 +4204 +4209 +4211 +4213 +4224 +4240 +4242 +4255 +4266 +4280 +4284 +4295 +4310 +4323 +4343 +4351 +4359 +4383 +4387 +4388 +4397 +4401 +4403 +4404 +4405 +4425 +4431 +4435 +4439 +4444 +4452 +4461 +4470 +4466 +4467 +4469 +4481 +4482 +4498 +4496 +4504 +4505 +4512 +4518 +4520 +4521 +4523 +4534 +4516 +4527 +4525 +4534 +4535 +4551 +4565 +4570 +4571 +4578 +4584 +4595 +4609 +4610 +4618 +4628 +4629 +4630 +4634 +4636 +4637 +4640 +4659 +4664 +4669 +4665 +4673 +4687 +4688 +4693 +4694 +4697 +4667 +4678 +4679 +4702 +4707 +4706 +4709 +4711 +4718 +4725 +4716 +4718 +4723 +4724 +4726 +4727 +4729 +4735 +4736 +4738 +4739 +4758 +4763 +4773 +4774 +4776 +4777 +4778 +4777 +4785 +4786 +4771 +4773 +4774 +4777 +4781 +4783 +4788 +4791 +4794 +4807 +4816 +4818 +4825 +4828 +4838 +4822 +4831 +4837 +4841 +4851 +4854 +4870 +4876 +4888 +4889 +4900 +4906 +4909 +4910 +4917 +4919 +4920 +4926 +4928 +4934 +4941 +4943 +4945 +4948 +4950 +4956 +4951 +4948 +4954 +4958 +4960 +4959 +4962 +4969 +4982 +4986 +4994 +5000 +5009 +5027 +5025 +5029 +5033 +5037 +5036 +5037 +5040 +5032 +5033 +5034 +5039 +5045 +5050 +5045 +5076 +5077 +5082 +5083 +5106 +5107 +5114 +5117 +5137 +5138 +5143 +5147 +5153 +5156 +5171 +5182 +5183 +5184 +5185 +5189 +5182 +5189 +5194 +5201 +5205 +5213 +5218 +5221 +5223 +5230 +5231 +5243 +5255 +5230 +5228 +5237 +5245 +5248 +5259 +5260 +5272 +5278 +5281 +5287 +5286 +5287 +5298 +5328 +5329 +5333 +5335 +5337 +5339 +5341 +5346 +5349 +5350 +5351 +5358 +5359 +5360 +5374 +5376 +5359 +5360 +5388 +5401 +5406 +5410 +5412 +5413 +5414 +5415 +5435 +5436 +5441 +5443 +5448 +5446 +5448 +5449 +5464 +5465 +5466 +5469 +5470 +5492 +5493 +5494 +5509 +5520 +5528 +5530 +5537 +5541 +5542 +5559 +5562 +5563 +5588 +5595 +5596 +5601 +5618 +5626 +5627 +5641 +5667 +5679 +5685 +5693 +5695 +5717 +5733 +5734 +5754 +5755 +5757 +5758 +5759 +5760 +5761 +5771 +5774 +5780 +5784 +5785 +5787 +5788 +5790 +5800 +5811 +5814 +5810 +5811 +5794 +5792 +5803 +5804 +5812 +5814 +5815 +5836 +5852 +5853 +5855 +5878 +5879 +5880 +5883 +5889 +5897 +5911 +5932 +5934 +5935 +5936 +5938 +5939 +5941 +5951 +5955 +5950 +5951 +5954 +5970 +5971 +5974 +5977 +5978 +5985 +5986 +6013 +6024 +6031 +6037 +6043 +6052 +6051 +6053 +6076 +6096 +6101 +6106 +6108 +6115 +6125 +6106 +6107 +6104 +6114 +6142 +6143 +6162 +6169 +6170 +6171 +6181 +6198 +6199 +6202 +6206 +6207 +6244 +6246 +6249 +6250 +6254 +6264 +6271 +6276 +6277 +6268 +6271 +6288 +6293 +6308 +6309 +6326 +6341 +6345 +6344 +6341 +6364 +6365 +6366 +6370 +6371 +6373 +6376 +6377 +6378 +6377 +6379 +6386 +6396 +6397 +6420 +6422 +6429 +6433 +6463 +6472 +6473 +6490 +6491 +6492 +6497 +6522 +6523 +6524 +6519 +6520 +6521 +6525 +6530 +6531 +6534 +6535 +6543 +6552 +6558 +6584 +6586 +6587 +6588 +6606 +6614 +6618 +6646 +6650 +6651 +6654 +6677 +6663 +6665 +6676 +6655 +6653 +6655 +6665 +6667 +6682 +6692 +6703 +6704 +6707 +6715 +6719 +6730 +6731 +6733 +6743 +6747 +6748 +6750 +6759 +6771 +6772 +6776 +6775 +6776 +6782 +6785 +6812 +6841 +6858 +6860 +6859 +6877 +6886 +6895 +6914 +6919 +6922 +6924 +6933 +6935 +6936 +6937 +6938 +6952 +6962 +6965 +6984 +6987 +6986 +6985 +6977 +6967 +6968 +6966 +6980 +6997 +6994 +7002 +7008 +7000 +6975 +7009 +7014 +7015 +7026 +7027 +7034 +7036 +7041 +7040 +7041 +7045 +7048 +7065 +7074 +7075 +7082 +7087 +7092 +7098 +7097 +7111 +7127 +7124 +7135 +7136 +7137 +7140 +7153 +7156 +7158 +7174 +7176 +7177 +7163 +7166 +7159 +7157 +7158 +7164 +7165 +7172 +7190 +7194 +7199 +7200 +7205 +7208 +7207 +7222 +7227 +7244 +7249 +7271 +7272 +7273 +7274 +7281 +7286 +7288 +7314 +7315 +7317 +7318 +7319 +7304 +7307 +7308 +7309 +7312 +7319 +7322 +7337 +7338 +7345 +7346 +7350 +7360 +7361 +7362 +7360 +7395 +7400 +7404 +7405 +7407 +7406 +7411 +7420 +7435 +7440 +7442 +7446 +7453 +7446 +7448 +7467 +7471 +7469 +7470 +7482 +7485 +7492 +7488 +7489 +7492 +7493 +7494 +7497 +7504 +7520 +7525 +7547 +7554 +7543 +7553 +7560 +7561 +7577 +7589 +7591 +7593 +7587 +7596 +7597 +7584 +7590 +7591 +7599 +7626 +7627 +7628 +7630 +7645 +7639 +7645 +7652 +7657 +7662 +7664 +7674 +7680 +7681 +7694 +7698 +7716 +7704 +7705 +7706 +7708 +7712 +7716 +7715 +7717 +7722 +7723 +7728 +7721 +7722 +7724 +7727 +7735 +7737 +7725 +7746 +7747 +7750 +7761 +7762 +7765 +7777 +7780 +7776 +7777 +7778 +7759 +7769 +7770 +7787 +7797 +7798 +7804 +7803 +7804 +7805 +7811 +7825 +7824 +7826 +7827 +7828 +7851 +7867 +7887 +7889 +7890 +7900 +7904 +7917 +7918 +7935 +7941 +7942 +7946 +7947 +7948 +7949 +7976 +7979 +7981 +7983 +7988 +7999 +8000 +8009 +8011 +8012 +8019 +8021 +8025 +8027 +8006 +8011 +8034 +8036 +8037 +8038 +8013 +8024 +8029 +8032 +8033 +8034 +8032 +8034 +8036 +8059 +8060 +8063 +8064 +8081 +8090 +8097 +8122 +8135 +8147 +8149 +8150 +8151 +8162 +8174 +8154 +8158 +8162 +8170 +8171 +8188 +8189 +8190 +8191 +8196 +8205 +8216 +8217 +8222 +8233 +8239 +8240 +8242 +8257 +8249 +8262 +8264 +8274 +8309 +8311 +8328 +8333 +8335 +8338 +8344 +8350 +8349 +8350 +8363 +8366 +8370 +8371 +8395 +8398 +8401 +8410 +8425 +8429 +8430 +8441 +8443 +8445 +8451 +8452 +8455 +8458 +8431 +8443 +8453 +8459 +8477 +8474 +8479 +8476 +8487 +8488 +8489 +8500 +8501 +8503 +8504 +8538 +8523 +8529 +8530 +8556 +8573 +8576 +8589 +8595 +8624 +8632 +8634 +8628 +8636 +8635 +8636 +8644 +8659 +8661 +8641 +8652 +8659 +8650 +8664 +8667 +8674 +8676 +8678 +8686 +8696 +8697 +8735 +8740 +8749 +8767 +8769 +8747 +8751 +8760 +8755 +8766 +8768 +8777 +8782 +8788 +8796 +8799 +8801 +8809 +8807 +8816 +8827 +8831 +8835 +8836 +8843 +8844 +8845 +8851 +8858 +8860 +8862 +8863 +8889 +8891 +8912 +8913 +8924 +8928 +8929 +8939 +8955 +8957 +8958 +8963 +8988 +8989 +8997 +8995 +8999 +8968 +8990 +8991 +8992 +8994 +8996 +9013 +9024 +9026 +9035 +9046 +9047 +9083 +9084 +9089 +9096 +9108 +9107 +9116 +9123 +9122 +9128 +9132 +9151 +9155 +9163 +9174 +9178 +9183 +9199 +9209 +9217 +9219 +9232 +9233 +9232 +9237 +9241 +9244 +9245 +9247 +9251 +9252 +9266 +9285 +9284 +9291 +9294 +9295 +9296 +9300 +9322 +9328 +9333 +9337 +9345 +9346 +9347 +9371 +9375 +9394 +9397 +9404 +9406 +9422 +9425 +9438 +9440 +9435 +9442 +9455 +9473 +9475 +9496 +9499 +9500 +9511 +9512 +9513 +9539 +9540 +9543 +9547 +9550 +9557 +9571 +9577 +9593 +9600 +9609 +9615 +9620 +9621 +9616 +9625 +9626 +9637 +9638 +9642 +9648 +9656 +9654 +9661 +9665 +9696 +9705 +9710 +9719 +9720 +9717 +9718 +9717 +9719 +9724 +9725 +9738 +9741 +9743 +9744 +9745 +9765 +9778 +9779 +9789 +9791 +9773 +9778 +9780 +9782 +9783 +9782 +9797 +9799 +9800 +9801 +9823 +9824 +9834 +9836 +9841 +9845 +9847 +9865 +9868 +9883 +9884 +9887 +9890 +9892 +9899 +9908 +9910 +9911 +9915 +9918 +9922 +9926 +9923 +9944 +9947 +9948 +9949 +9958 +9959 +9961 +9973 +9954 +9976 +9978 +10001 +10000 +9992 +9997 +9985 +9995 +9996 +10005 +9999 +10001 +10002 +10009 +10041 +10045 +10051 +10070 +10071 +10073 +10100 +10099 +10100 +10101 +10102 +10105 +10082 +10083 +10082 +10086 +10112 +10113 +10114 +10122 +10124 +10127 +10140 +10156 +10157 +10158 +10159 +10162 +10163 +10166 +10177 +10178 +10180 +10178 +10179 +10191 +10186 +10198 +10201 +10204 +10227 +10229 +10232 +10234 +10246 +10247 +10248 +10249 +10250 +10269 +10277 +10278 +10279 +10289 +10291 +10294 +10292 +10304 +10324 +10339 +10342 +10343 +10349 +10354 +10371 +10370 +10374 +10376 +10379 +10405 +10406 +10405 +10403 +10411 +10412 +10411 +10419 +10422 +10435 +10437 +10438 +10437 +10440 +10427 +10421 +10432 +10434 +10439 +10449 +10442 +10469 +10471 +10476 +10480 +10481 +10485 +10507 +10508 +10511 +10512 +10513 +10523 +10524 +10529 +10536 +10552 +10563 +10569 +10573 +10575 +10576 +10578 +10596 +10602 +10630 +10647 +10657 +10659 +10684 +10687 +10692 +10693 +10700 +10702 +10703 +10709 +10714 +10716 +10727 +10746 +10744 +10754 +10753 +10754 +10755 +10759 +10763 +10764 +10765 +10769 +10770 +10771 +10777 +10796 +10807 +10813 +10818 +10825 +10830 +10835 +10836 +10849 +10858 +10873 +10882 +10879 +10882 +10886 +10902 +10903 +10931 +10930 diff --git a/day01/day01_input_ez.txt b/day01/day01_input_ez.txt new file mode 100644 index 0000000..167e291 --- /dev/null +++ b/day01/day01_input_ez.txt @@ -0,0 +1,10 @@ +199 +200 +208 +210 +200 +207 +240 +269 +260 +263 diff --git a/day01/makefile b/day01/makefile new file mode 100644 index 0000000..92fb064 --- /dev/null +++ b/day01/makefile @@ -0,0 +1,2 @@ +all day01.cpp: + g++ -std=c++20 -o day01 day01.cpp diff --git a/day02/day02 b/day02/day02 new file mode 100755 index 0000000..8755c57 Binary files /dev/null and b/day02/day02 differ diff --git a/day02/day02.cpp b/day02/day02.cpp new file mode 100644 index 0000000..dccb44a --- /dev/null +++ b/day02/day02.cpp @@ -0,0 +1,50 @@ +#include + +int main (int argc, char *argv[]) { + if (argc != 2) return 1; + + int depth = 0; + int forward = 0; + + int aim = 0; + int aim_depth = 0; + + FILE *f = fopen(argv[1], "r"); + char c = fgetc(f); + std::string command; + while (c != EOF) { + if (c == '\n') { + auto token_space = command.find(" "); + if (token_space != std::string::npos) { + std::string op = command.substr(0, token_space); + int amt = std::stoi(command.substr(token_space+1)); + if (op == "forward") { + forward += amt; + aim_depth += aim * amt; + } + if (op == "down") { + depth += amt; + aim += amt; + } + if (op == "up") { + depth -= amt; + aim -= amt; + } + } + command = ""; + } + else command += c; + c = fgetc(f); + } + + std::cout << "depth " << depth << ", " + << "forward " << forward << ", " + << "product " << depth * forward << std::endl; + + std::cout << "using aim: depth " << aim_depth << ", " + << "forward " << forward << ", " + << "aim " << aim << ", " + << "product " << aim_depth * forward << std::endl; + + return 0; +} diff --git a/day02/day02_input.txt b/day02/day02_input.txt new file mode 100644 index 0000000..7834464 --- /dev/null +++ b/day02/day02_input.txt @@ -0,0 +1,1000 @@ +forward 8 +forward 9 +forward 9 +down 3 +forward 9 +down 1 +down 7 +down 7 +down 4 +down 2 +down 6 +down 6 +down 2 +forward 6 +forward 6 +forward 2 +forward 2 +forward 7 +forward 6 +up 6 +up 8 +forward 5 +forward 4 +down 6 +forward 7 +down 5 +forward 5 +down 8 +down 8 +down 7 +forward 4 +down 2 +forward 7 +up 8 +forward 3 +down 2 +forward 1 +up 3 +forward 3 +up 1 +down 3 +up 7 +up 2 +down 4 +down 2 +forward 9 +forward 3 +down 8 +forward 5 +up 9 +up 4 +forward 9 +down 1 +forward 6 +down 3 +forward 8 +up 2 +forward 3 +up 7 +down 4 +forward 2 +forward 7 +forward 3 +down 1 +down 3 +up 5 +forward 6 +down 5 +down 4 +down 8 +down 2 +up 5 +forward 7 +up 8 +forward 2 +down 5 +forward 3 +up 1 +up 5 +down 8 +down 3 +forward 4 +forward 4 +forward 1 +up 8 +down 9 +forward 7 +forward 9 +down 5 +up 3 +down 9 +up 6 +forward 1 +forward 3 +forward 5 +down 5 +forward 6 +down 3 +down 8 +forward 3 +forward 5 +forward 7 +forward 6 +down 9 +down 5 +down 6 +down 5 +down 1 +down 8 +forward 3 +down 9 +down 5 +down 5 +forward 9 +forward 2 +down 7 +forward 9 +forward 9 +up 1 +forward 3 +up 9 +forward 5 +forward 7 +down 7 +forward 2 +up 8 +up 6 +down 7 +down 3 +down 5 +down 2 +forward 6 +forward 6 +up 6 +up 2 +forward 4 +forward 7 +forward 1 +down 4 +up 8 +down 3 +up 1 +down 2 +forward 4 +forward 7 +up 1 +down 7 +forward 8 +up 2 +down 8 +up 4 +up 4 +up 2 +down 8 +up 4 +down 6 +up 8 +down 5 +up 5 +down 8 +forward 9 +down 1 +down 5 +forward 3 +forward 3 +up 9 +down 2 +forward 3 +down 6 +forward 1 +forward 9 +forward 3 +down 8 +up 4 +down 1 +down 8 +up 1 +forward 2 +down 7 +up 3 +up 8 +down 2 +up 6 +forward 6 +down 9 +forward 4 +forward 7 +up 9 +forward 3 +forward 2 +down 8 +down 2 +down 5 +down 5 +down 1 +up 7 +down 4 +forward 5 +down 9 +down 5 +down 1 +down 6 +forward 9 +down 6 +forward 3 +down 3 +up 6 +forward 2 +forward 6 +down 2 +down 9 +down 6 +down 1 +down 7 +down 6 +down 6 +up 1 +forward 8 +down 9 +down 6 +down 8 +down 8 +down 6 +down 3 +forward 9 +forward 6 +down 9 +forward 5 +down 6 +down 6 +down 9 +down 7 +down 3 +forward 1 +up 9 +forward 9 +down 7 +forward 4 +down 1 +forward 9 +up 9 +down 7 +forward 5 +down 3 +up 7 +forward 9 +forward 6 +forward 3 +forward 8 +down 4 +down 1 +down 7 +down 7 +up 4 +down 9 +forward 6 +forward 7 +down 8 +forward 2 +forward 2 +forward 9 +forward 6 +forward 9 +up 6 +up 8 +forward 2 +up 3 +forward 9 +forward 1 +down 4 +forward 8 +down 4 +forward 5 +forward 7 +up 2 +forward 5 +down 4 +forward 3 +down 5 +forward 9 +up 3 +forward 8 +down 7 +down 7 +down 9 +forward 2 +down 1 +down 6 +up 8 +down 2 +down 1 +up 3 +down 3 +forward 2 +forward 6 +up 6 +down 3 +up 9 +up 3 +down 8 +up 6 +down 2 +forward 4 +up 1 +down 5 +down 4 +up 9 +up 7 +forward 7 +down 9 +forward 9 +forward 5 +forward 3 +down 4 +up 6 +up 7 +down 7 +down 6 +up 9 +up 4 +down 7 +forward 7 +forward 8 +down 9 +forward 5 +forward 4 +down 5 +forward 8 +forward 5 +up 3 +down 9 +forward 1 +forward 2 +up 3 +down 2 +down 1 +forward 5 +forward 5 +forward 6 +up 2 +forward 3 +down 7 +down 6 +up 3 +down 4 +down 4 +forward 5 +down 3 +up 6 +forward 1 +up 8 +forward 7 +forward 1 +forward 9 +down 2 +up 8 +up 1 +up 4 +forward 9 +forward 3 +forward 5 +down 1 +up 9 +down 1 +forward 3 +down 6 +down 8 +up 4 +forward 6 +up 7 +down 8 +forward 9 +up 2 +down 7 +down 1 +forward 9 +up 7 +forward 3 +forward 9 +forward 1 +forward 1 +down 9 +forward 1 +up 4 +down 5 +forward 4 +down 1 +forward 4 +forward 9 +up 4 +down 3 +down 6 +up 2 +down 6 +down 5 +forward 5 +up 1 +up 9 +forward 8 +up 3 +down 1 +forward 3 +forward 7 +up 6 +up 3 +down 6 +forward 7 +up 6 +down 7 +forward 8 +up 4 +down 8 +up 9 +up 3 +down 3 +forward 8 +down 4 +down 9 +forward 2 +down 7 +up 1 +forward 9 +forward 5 +up 8 +forward 9 +forward 4 +forward 9 +forward 7 +down 4 +up 4 +down 7 +down 4 +down 4 +down 1 +forward 5 +forward 4 +down 1 +down 4 +down 8 +down 3 +forward 7 +forward 4 +down 1 +down 9 +up 3 +forward 2 +down 8 +down 9 +down 2 +down 5 +up 9 +down 9 +up 9 +forward 5 +forward 8 +forward 9 +down 5 +forward 6 +down 8 +down 9 +forward 8 +up 5 +up 9 +up 7 +up 8 +forward 9 +forward 1 +up 6 +down 8 +down 8 +forward 1 +up 1 +forward 8 +forward 6 +down 4 +forward 1 +down 7 +forward 8 +forward 3 +up 3 +down 4 +down 2 +forward 2 +forward 3 +up 4 +down 3 +forward 2 +down 8 +forward 7 +up 3 +down 2 +forward 2 +down 5 +up 6 +up 6 +forward 4 +up 4 +down 8 +forward 8 +down 9 +down 9 +down 6 +down 2 +forward 2 +up 6 +up 5 +forward 3 +forward 3 +up 9 +down 3 +forward 8 +down 5 +forward 5 +forward 7 +down 3 +down 4 +down 1 +down 8 +down 1 +down 1 +forward 9 +forward 3 +down 8 +down 6 +up 9 +forward 1 +forward 5 +up 9 +up 8 +forward 2 +up 8 +down 9 +up 2 +forward 5 +forward 1 +forward 8 +down 3 +forward 4 +down 5 +up 6 +forward 8 +forward 9 +forward 3 +down 1 +down 3 +down 3 +up 4 +forward 9 +down 3 +down 6 +forward 3 +forward 2 +down 6 +down 8 +forward 6 +up 8 +up 3 +up 4 +forward 2 +forward 4 +forward 4 +forward 7 +down 6 +up 8 +down 3 +forward 8 +forward 4 +down 7 +down 5 +forward 6 +forward 4 +forward 6 +down 3 +forward 3 +down 1 +down 7 +forward 3 +forward 2 +forward 7 +down 5 +up 4 +down 6 +down 9 +forward 3 +forward 5 +forward 3 +down 1 +forward 2 +up 5 +up 6 +forward 2 +down 4 +forward 3 +down 4 +down 1 +forward 8 +up 2 +down 3 +down 6 +up 5 +forward 3 +forward 6 +down 3 +forward 1 +down 7 +forward 2 +forward 1 +forward 6 +forward 5 +forward 3 +down 4 +down 8 +forward 1 +up 2 +up 8 +down 4 +forward 9 +up 6 +forward 5 +forward 7 +down 5 +forward 5 +down 1 +forward 4 +forward 5 +up 2 +forward 5 +up 8 +up 1 +forward 2 +down 4 +down 6 +forward 4 +down 2 +down 3 +forward 2 +up 3 +up 4 +forward 2 +down 6 +forward 1 +forward 4 +down 6 +forward 7 +up 2 +forward 7 +forward 6 +up 2 +forward 8 +forward 4 +forward 9 +down 1 +down 8 +forward 3 +forward 2 +down 8 +up 1 +forward 4 +down 8 +forward 2 +forward 8 +up 2 +down 1 +forward 4 +forward 2 +up 4 +up 2 +down 3 +up 8 +forward 3 +up 8 +forward 9 +up 1 +up 5 +down 5 +down 6 +forward 1 +up 5 +up 8 +forward 7 +down 5 +up 4 +forward 2 +up 4 +up 4 +down 2 +forward 6 +forward 2 +down 7 +down 5 +forward 1 +down 2 +down 5 +down 7 +up 8 +down 8 +up 5 +down 1 +forward 5 +down 2 +forward 5 +down 1 +up 7 +up 2 +forward 2 +forward 3 +forward 6 +forward 3 +down 8 +up 8 +forward 8 +forward 1 +forward 7 +up 2 +forward 9 +down 1 +forward 5 +up 9 +forward 3 +forward 7 +forward 8 +up 1 +down 3 +forward 5 +down 2 +forward 6 +forward 3 +down 9 +up 5 +forward 2 +down 4 +up 1 +forward 4 +up 4 +down 8 +down 8 +forward 3 +forward 8 +down 7 +up 3 +forward 1 +up 3 +forward 9 +forward 7 +forward 1 +down 6 +forward 3 +down 1 +down 8 +forward 5 +forward 3 +up 6 +forward 5 +forward 4 +forward 3 +forward 9 +forward 8 +down 6 +down 2 +forward 7 +forward 6 +up 6 +down 6 +down 4 +down 3 +forward 8 +down 9 +up 5 +forward 3 +forward 2 +down 5 +up 4 +down 6 +down 3 +forward 9 +down 2 +forward 9 +forward 8 +up 1 +down 2 +forward 7 +up 5 +up 6 +down 8 +up 9 +up 8 +forward 1 +forward 5 +down 9 +forward 8 +down 8 +up 1 +down 7 +forward 7 +up 3 +down 3 +down 1 +forward 2 +down 3 +forward 9 +forward 2 +down 8 +down 2 +forward 5 +down 9 +down 1 +down 5 +down 6 +up 4 +up 3 +down 1 +up 7 +forward 6 +down 3 +down 6 +up 5 +forward 8 +up 8 +down 1 +down 2 +up 8 +down 7 +forward 7 +forward 4 +down 8 +down 3 +forward 3 +down 4 +forward 3 +down 6 +forward 4 +forward 7 +forward 9 +up 7 +forward 1 +down 7 +down 8 +down 8 +up 6 +down 3 +forward 5 +forward 5 +forward 9 +forward 4 +down 4 +down 8 +down 7 +down 1 +forward 2 +forward 4 +down 3 +down 6 +down 7 +forward 5 +down 8 +down 1 +forward 4 +forward 3 +forward 1 +down 6 +down 7 +down 1 +forward 6 +down 4 +up 2 +forward 4 +down 2 +up 5 +down 2 +down 6 +up 7 +forward 4 +forward 7 +forward 9 +up 5 +down 9 +up 5 +forward 6 +down 2 +up 8 +up 9 +up 9 +forward 5 +down 2 +forward 2 +down 7 +forward 5 +forward 9 +up 8 +down 8 +forward 1 +down 2 +up 3 +forward 3 +down 5 +forward 4 +down 3 +forward 4 +forward 9 +forward 3 +down 5 +forward 4 +down 2 +forward 5 +forward 8 +up 6 +up 2 +down 3 +forward 6 +down 5 +down 4 +down 4 +down 4 +up 2 +up 2 +forward 6 +forward 2 +forward 9 +down 2 +down 9 +down 8 +forward 2 +down 3 +up 3 +forward 5 +down 4 +up 3 +forward 3 +down 1 +forward 7 +forward 5 +forward 6 +down 8 +down 5 +down 5 +down 9 +up 2 +forward 3 +down 4 +down 9 +forward 3 +forward 9 +forward 2 +forward 4 +up 6 +down 6 +up 9 +forward 8 +down 7 +forward 1 +forward 4 +up 1 +up 2 +down 9 +forward 6 +down 6 +down 1 +down 4 +down 7 +down 6 +forward 5 +up 1 +up 7 +down 2 +down 8 +down 2 +down 7 +down 3 +up 9 +down 7 +down 5 +down 6 +forward 9 +up 3 +forward 2 +down 8 +forward 4 +down 6 +forward 3 +up 3 +down 5 +up 4 +forward 6 +forward 7 +forward 9 +down 3 +forward 7 +forward 3 +down 4 +up 4 +down 8 +forward 6 +forward 7 +forward 9 +forward 4 +down 3 +up 5 +down 7 +down 7 +forward 9 diff --git a/day02/makefile b/day02/makefile new file mode 100644 index 0000000..61ca2f4 --- /dev/null +++ b/day02/makefile @@ -0,0 +1,2 @@ +all day02.cpp: + g++ -std=c++20 -o day02 day02.cpp diff --git a/day03/day03 b/day03/day03 new file mode 100755 index 0000000..ccb1732 Binary files /dev/null and b/day03/day03 differ diff --git a/day03/day03.cpp b/day03/day03.cpp new file mode 100644 index 0000000..036cd07 --- /dev/null +++ b/day03/day03.cpp @@ -0,0 +1,96 @@ +#include +#include +#include +#include + +int bin_to_dec (std::string bin) { + int dec = 0, pow = 1; + for (std::size_t i=bin.size(); i > 0; i--) { + dec += pow * (bin[i-1] == '0' ? 0 : 1); + pow *= 2; + } + return dec; +} + +std::vector get_freq (std::vector bits) { + std::vector freq; + for (std::size_t i=0; i filter (std::vector bits, int inv, int sel) { + std::vector res; + auto freq = get_freq(bits); + + for (auto b : bits) { + int f = freq[sel] * inv; + if (f == 0) f += inv; + if ((f > 0 ? '0' : '1') == b[sel]) { + res.push_back(b); + } + } + + return res; +} + +int main (int argc, char *argv[]) { + if (argc != 2) return 1; + + std::string raw; + std::getline(std::ifstream(argv[1]), raw, '\0'); + + std::vector bits; + + while (1) { + auto token = raw.find("\n"); + if (token != std::string::npos) { + bits.push_back(raw.substr(0, token)); + raw = raw.substr(token+1); + } else { + if (raw.size() > 0) bits.push_back(raw); + break; + } + } + + auto freq = get_freq(bits); + + std::string gamma = "", epsilon = ""; + for (std::size_t i=0; i 0 ? "1" : "0"; + epsilon += freq[i] > 0 ? "0" : "1"; + } + + int g = bin_to_dec(gamma); + int e = bin_to_dec(epsilon); + std::cout << "power level " << e*g << ", " + << "epsilon " << e << " (" << epsilon << "), " + << "gamma " << g << " (" << gamma << ")" << std::endl; + + std::vector o2 = bits; + for (std::size_t i=0; i co2 = bits; + for (std::size_t i=0; i +#include +#include + +void split (std::vector &vec, std::string str, std::string del) { + auto token = str.find(del); + if (token != std::string::npos) { + vec.push_back(str.substr(0, token)); + split(vec, str.substr(token+del.size()), del); + } else { vec.push_back(str); } +} + +class Board { + public: + Board(std::string repr) { + std::vector lines; + split(lines, repr, "\n"); + for (auto line : lines) { + std::vector strcells; + split(strcells, line, " "); + size = 0; + for (auto strcell : strcells) { + if (strcell.size() == 0) continue; + cells.push_back(std::stoi(strcell)); + state.push_back(0); + size++; + } + } + + } + + int size; + std::vector cells; + std::vector state; + + void mark (int ex) { + for (int y=0; y extract; + auto token = raw.find("\n"); + if (token != std::string::npos) { + std::string ex = raw.substr(0, token); + std::vector vec; + split(vec, ex, ","); + for (auto v : vec) { extract.push_back(std::stoi(v)); } + + raw = raw.substr(token+2); + if (raw[raw.size()-1] == '\n') raw = raw.substr(0, raw.size()-1); + } else return 1; + + std::vector boards; + + std::vector str_boards; + split(str_boards, raw, "\n\n"); + for (auto s : str_boards) { + boards.emplace_back(s); + } + + bool flag = false; + std::vector filtered = boards; + for (int ex : extract) { + std::cout << ex << " " << filtered.size() << std::endl; + std::vector next; + int size = filtered.size(), seen = 0;; + for (auto& board : filtered) { + board.mark(ex); + if (board.win() && filtered.size() != 1) { + if (!flag) { + std::cout << "first winner product: " << ex * board.score() << ", " + << "ex: " << ex << ", score: " << board.score() << std::endl; + flag = true; + } + } else { + next.push_back(board); + } + } + if (next.size() == 1 && next[0].win()) { + int score = next[0].score(); + std::cout << "last winner product: " << ex * score << ", " + << "ex: " << ex << ", score: " << score << std::endl; + break; + } + filtered = next; + } + + return 0; +} diff --git a/day04/day04_input.txt b/day04/day04_input.txt new file mode 100644 index 0000000..033baa2 --- /dev/null +++ b/day04/day04_input.txt @@ -0,0 +1,601 @@ +38,54,68,93,72,12,33,8,98,88,21,91,53,61,26,36,18,80,73,47,3,5,55,92,67,52,25,40,56,95,9,62,30,31,85,65,14,2,78,75,15,39,87,27,58,42,60,32,41,83,51,77,10,66,70,4,37,6,89,23,16,49,48,63,94,97,86,64,74,82,7,0,11,71,44,43,50,69,45,81,20,28,46,79,90,34,35,96,99,59,1,76,22,24,17,57,13,19,84,29 + +57 7 8 38 31 +17 96 5 12 18 +58 45 81 89 4 +73 51 93 32 10 +74 50 26 0 24 + +79 67 21 84 71 +25 22 19 80 13 +10 63 90 78 33 +93 50 89 58 87 +91 7 45 6 41 + +66 85 4 91 41 +59 69 16 0 90 +35 13 64 61 93 +11 20 29 67 77 +92 75 58 3 34 + +19 1 34 50 76 +26 75 8 28 20 +96 64 49 77 2 +18 58 62 53 60 +82 99 38 10 83 + +89 69 97 16 48 +32 3 83 17 33 +82 53 15 50 94 +52 0 86 25 81 +42 38 84 73 76 + +68 18 44 61 66 +24 21 22 6 41 +48 29 4 64 78 +93 25 88 95 96 +72 49 51 2 5 + +35 41 59 23 21 + 0 66 34 12 85 +61 26 29 68 5 +28 69 90 2 96 + 1 16 32 24 44 + +98 73 33 82 18 +51 62 88 67 6 +99 44 53 39 36 +34 90 50 72 43 +64 40 11 26 5 + +88 8 81 57 99 +61 16 22 50 5 +26 84 85 7 15 +97 27 47 18 21 + 3 78 66 94 58 + +56 40 68 20 24 +26 98 6 76 89 +61 63 22 99 83 +31 5 32 54 82 +18 23 17 46 13 + +35 95 67 73 13 +86 33 7 9 43 +44 28 55 32 52 +54 91 84 97 98 +17 49 93 23 56 + +22 90 61 12 13 +87 4 46 25 88 +70 38 53 80 11 +75 56 96 49 32 + 3 55 43 19 67 + +40 17 70 76 61 +82 86 37 8 28 +60 48 24 83 53 +57 87 44 92 63 +10 49 88 15 55 + +36 80 47 46 84 +25 70 2 79 75 +55 5 13 99 45 +54 73 83 59 67 +57 0 69 33 68 + +51 52 21 44 36 +17 30 15 42 18 + 6 3 47 94 2 +57 77 45 70 90 +29 60 19 9 84 + +16 12 37 6 27 +86 87 21 70 71 +84 0 11 67 83 + 5 68 33 23 26 +51 43 28 79 49 + +22 5 53 12 42 +29 81 46 13 88 +80 65 8 62 33 +72 67 34 21 35 +38 77 90 52 44 + +63 57 52 82 96 +46 11 32 20 58 +35 15 83 1 55 +18 16 73 19 17 +22 88 45 95 47 + +43 15 7 97 88 +96 52 84 86 49 +80 13 21 28 29 +16 36 98 82 41 +32 10 62 68 24 + +46 69 8 55 50 +28 21 92 79 73 +19 71 74 53 44 +24 27 10 14 85 + 2 39 58 81 72 + +68 74 43 62 61 +82 73 37 40 93 +16 7 41 54 96 +10 3 85 70 65 +69 71 94 5 81 + +17 53 87 80 98 +76 41 30 25 58 +29 14 73 74 43 +20 91 24 70 39 +46 48 51 9 18 + +20 41 36 81 93 +46 75 33 73 78 +26 16 80 54 90 +87 17 12 67 1 +51 10 39 91 45 + +76 21 31 3 69 +27 42 97 32 87 +26 22 4 63 38 +46 77 67 80 43 +37 50 59 88 96 + +17 16 10 68 76 + 2 45 94 29 40 + 1 54 60 66 93 + 0 13 42 39 70 + 6 82 46 74 43 + +87 95 31 22 94 +86 30 39 56 18 +89 74 23 11 64 +63 48 85 20 49 +27 15 40 83 50 + +81 48 47 73 95 +40 65 89 69 5 +38 76 85 30 11 +31 61 8 67 62 +41 68 42 78 20 + +46 85 96 83 20 +94 52 7 97 31 +29 95 99 34 62 + 8 69 6 51 54 +38 59 5 56 55 + +18 15 10 35 96 +44 66 58 91 9 +12 2 45 98 80 +22 69 37 67 79 +46 36 23 51 75 + +11 58 64 85 26 +21 43 32 36 65 +94 61 40 68 67 +14 23 6 53 2 +93 9 74 3 90 + +73 82 46 37 20 +47 75 38 45 54 +76 34 65 44 58 +93 89 27 13 33 +85 67 40 42 17 + +13 66 2 65 10 +98 4 83 79 92 +22 48 93 6 23 +24 39 17 60 9 +77 49 16 19 35 + +96 37 88 4 32 +80 89 59 39 63 +67 19 35 10 40 +91 66 47 9 79 +45 21 86 92 30 + +76 85 37 32 29 +59 41 44 23 93 +86 24 83 81 57 +22 21 82 53 16 +38 99 79 49 30 + +54 29 64 65 62 +44 59 83 75 56 +11 13 34 12 24 +96 39 31 95 16 +41 38 21 25 60 + +49 8 3 67 2 +30 81 39 26 33 +83 73 47 32 65 +48 20 75 24 40 +74 28 11 19 96 + +87 25 49 81 7 +99 34 35 50 86 +18 24 68 4 78 +59 8 71 0 41 +92 54 64 75 46 + + 2 19 73 29 10 +55 6 43 48 22 +64 14 62 39 97 +99 26 68 25 12 +98 72 45 38 40 + +59 76 40 37 9 +42 23 1 12 54 +49 51 17 11 34 +74 95 26 78 67 +65 32 98 80 45 + +50 86 95 29 38 + 6 11 24 10 73 +63 28 30 46 68 +34 9 20 58 77 +88 52 79 89 98 + +32 20 93 39 80 +67 98 99 4 26 +22 89 97 13 73 +88 11 72 31 78 +76 95 64 43 75 + +75 23 81 89 90 +98 86 88 38 99 +51 7 65 2 3 +16 59 49 41 87 +57 20 58 72 83 + +21 81 24 43 12 +55 74 2 90 5 +13 89 59 42 3 +47 66 38 20 62 +61 56 72 84 41 + +83 68 73 77 66 +96 48 24 7 98 +57 4 86 10 34 +22 46 80 75 49 +89 35 60 79 37 + +27 50 90 37 28 +81 74 58 39 61 + 8 72 31 85 57 +52 43 9 5 91 +68 86 0 4 89 + +14 41 70 67 59 +13 94 31 69 65 +76 19 9 79 1 +33 20 53 91 36 +80 50 21 37 85 + +16 47 62 33 12 +11 74 44 63 60 + 2 23 84 80 42 +14 58 67 81 24 + 8 29 31 91 43 + +62 86 26 57 74 + 9 46 47 81 39 + 4 99 59 89 3 +20 76 51 70 84 +95 72 43 67 61 + +75 93 56 15 30 +11 49 97 16 45 +52 91 21 92 62 + 0 74 85 48 63 +28 76 59 79 60 + +36 18 0 69 10 +34 33 21 5 23 +73 42 50 14 11 +75 26 95 79 51 +76 93 1 43 22 + +86 64 25 9 54 +67 79 49 1 8 +63 47 60 4 46 +94 97 57 38 30 +91 87 0 68 15 + +94 46 6 69 9 +18 49 43 30 31 +79 35 76 45 92 +67 89 82 2 57 +65 21 24 81 52 + + 5 58 43 37 61 +65 67 54 15 50 +69 75 14 17 96 +23 95 71 33 9 +68 82 10 3 29 + +56 43 88 35 82 +44 14 64 60 23 +33 5 96 86 47 +70 74 27 4 1 +51 71 95 59 11 + +46 14 44 6 19 +54 81 59 31 28 + 7 67 73 23 86 +25 91 57 43 92 +65 76 80 47 77 + + 3 39 70 90 23 +64 77 33 83 22 + 6 36 81 80 68 +85 45 72 53 42 + 7 19 88 13 9 + +88 3 72 6 29 +33 13 1 85 68 +28 32 78 8 63 +15 99 35 80 41 +61 50 43 53 39 + +22 88 19 86 54 +78 3 70 65 85 +18 12 21 14 17 + 5 48 64 81 71 +89 91 55 30 87 + +35 82 37 42 25 +44 53 12 2 73 +18 24 0 75 51 +34 26 54 52 86 +56 64 31 57 80 + +45 97 83 15 5 +40 77 1 53 84 +67 44 52 37 20 +36 64 33 82 90 +49 22 6 65 99 + +18 69 23 78 55 +45 4 31 54 44 +16 97 13 81 86 +77 87 91 53 33 + 1 84 83 75 40 + +95 46 89 7 38 +83 32 99 44 20 + 6 57 37 34 48 +69 5 84 29 54 +62 27 13 80 53 + +45 92 59 71 83 +52 75 42 46 86 +76 33 50 80 69 +36 89 90 3 31 + 7 5 48 38 53 + +86 80 77 18 87 +79 93 52 17 20 +30 68 48 12 91 +25 98 13 9 47 +45 73 97 15 59 + +93 60 34 18 25 +38 80 81 91 40 +43 87 20 79 7 +70 68 6 24 23 +46 97 32 78 67 + + 9 6 28 17 42 + 2 86 84 90 13 +91 58 16 37 76 +15 3 45 51 4 +64 99 41 59 39 + +44 3 85 80 93 + 0 43 90 40 89 +82 91 55 79 75 +30 5 68 50 1 +37 24 59 62 66 + +38 55 21 45 1 +23 14 95 25 22 +84 10 39 9 0 +17 15 58 70 49 +62 44 77 65 88 + + 8 62 25 75 39 +20 95 65 11 32 + 5 92 15 86 66 +64 34 60 7 85 +10 76 6 53 61 + +71 61 62 25 35 +23 30 37 14 9 +99 98 52 51 19 +77 57 17 72 85 +33 91 31 43 67 + +76 66 39 36 44 +49 97 93 33 52 +13 70 21 17 32 +71 98 80 19 60 +73 15 99 74 9 + +41 8 33 29 87 +42 86 66 31 50 +45 60 83 81 21 +36 4 98 43 0 +49 76 18 90 16 + +83 53 34 39 58 +91 68 17 62 4 + 2 76 44 31 35 +14 61 49 84 92 +73 6 86 27 65 + +56 70 47 60 97 +35 89 26 99 59 +67 23 27 74 65 +61 62 15 18 45 +54 93 0 9 71 + +11 24 97 15 30 +46 74 17 48 43 +16 64 72 60 37 +63 90 41 91 66 +25 95 1 54 49 + +87 67 27 26 38 +63 44 65 25 81 + 1 66 96 62 17 +82 2 58 4 86 +61 64 54 24 90 + +72 94 69 85 43 +38 11 93 39 13 +86 92 12 42 75 + 6 89 58 88 52 +79 19 20 55 14 + +77 93 58 6 52 +27 48 29 60 71 +87 24 25 54 49 +53 38 90 51 80 +57 50 18 1 13 + +85 84 54 2 51 +33 41 0 38 80 + 5 62 1 28 96 +17 88 64 26 90 +78 91 56 34 74 + +83 14 82 6 55 +30 13 99 57 39 +93 73 37 19 8 +29 49 76 22 92 +69 66 9 60 53 + +51 78 52 72 79 +42 55 74 88 44 +90 75 65 87 69 +22 35 64 36 86 +63 41 19 59 49 + +49 86 81 23 12 +93 16 9 8 95 +68 33 4 82 61 +45 28 85 87 38 +35 70 63 18 52 + +63 93 38 34 61 +75 21 86 42 25 +52 85 99 24 36 +41 11 79 54 47 +44 84 65 28 89 + +91 37 30 39 59 + 7 94 90 38 40 +72 21 75 31 61 +68 42 34 20 8 + 3 16 76 44 57 + +32 55 36 81 42 +21 75 68 28 65 +46 70 29 54 64 +66 89 96 25 43 +79 76 41 77 71 + +41 29 60 74 34 +84 49 83 72 92 +22 6 21 17 94 +15 44 62 28 2 +25 93 64 1 42 + +68 76 23 62 10 +36 87 15 12 57 +79 46 18 83 11 +48 81 58 52 28 +72 40 64 55 21 + +25 51 42 63 41 + 0 72 92 23 13 +65 1 69 33 2 +78 27 95 61 55 +30 54 48 3 57 + +50 40 58 66 59 +84 79 64 75 44 +88 93 41 25 97 +19 86 37 91 81 +10 26 94 77 34 + +76 44 11 16 60 +19 92 91 58 50 +97 5 46 4 52 +87 42 65 75 15 +12 2 54 27 86 + +77 38 51 29 89 + 7 76 54 48 44 +88 50 2 5 53 +12 70 26 57 74 +31 19 18 34 47 + +35 99 86 96 62 +61 97 71 70 66 +49 55 36 76 3 +94 23 31 91 26 +80 8 20 95 15 + + 4 96 40 36 12 +87 75 38 30 11 +69 29 23 85 91 +49 5 14 57 24 +88 20 99 78 65 + +34 65 71 79 67 +28 1 33 47 11 +15 86 84 83 55 +35 10 19 63 23 +58 66 45 77 26 + +74 13 25 39 8 +46 47 77 37 0 +60 1 81 42 18 + 5 51 78 30 4 +36 12 10 32 82 + +51 83 58 10 56 +28 18 43 99 14 + 3 57 30 49 88 +20 68 76 73 82 + 1 85 77 22 47 + +50 12 11 97 83 +40 10 49 81 63 +43 15 91 3 2 +52 20 53 89 33 +42 94 59 78 46 + +19 63 86 82 9 +69 13 27 88 37 +45 51 79 11 8 + 2 29 41 84 73 +76 24 78 96 38 + +15 19 88 95 54 +28 94 96 27 26 + 8 82 68 6 71 +33 9 99 62 63 +38 83 41 14 79 + +67 57 2 21 19 +11 79 74 45 95 +42 90 68 47 62 +80 61 1 0 39 +43 76 40 27 66 diff --git a/day04/day04_input_ez.txt b/day04/day04_input_ez.txt new file mode 100644 index 0000000..669a51d --- /dev/null +++ b/day04/day04_input_ez.txt @@ -0,0 +1,19 @@ +7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 + +22 13 17 11 0 + 8 2 23 4 24 +21 9 14 16 7 + 6 10 3 18 5 + 1 12 20 15 19 + + 3 15 0 2 22 + 9 18 13 17 5 +19 8 7 25 23 +20 11 10 24 4 +14 21 16 12 6 + +14 21 17 24 4 +10 16 15 9 19 +18 8 23 26 20 +22 11 13 6 5 + 2 0 12 3 7 diff --git a/day04/makefile b/day04/makefile new file mode 100644 index 0000000..ef809af --- /dev/null +++ b/day04/makefile @@ -0,0 +1,2 @@ +all day04.cpp: + g++ -std=c++20 -o day04 day04.cpp -- cgit v1.2.3-54-g00ecf