diff options
-rwxr-xr-x | day01/day01 | bin | 0 -> 79296 bytes | |||
-rw-r--r-- | day01/day01.cpp | 52 | ||||
-rw-r--r-- | day01/day01_input.txt | 2000 | ||||
-rw-r--r-- | day01/day01_input_ez.txt | 10 | ||||
-rw-r--r-- | day01/makefile | 2 | ||||
-rwxr-xr-x | day02/day02 | bin | 0 -> 47672 bytes | |||
-rw-r--r-- | day02/day02.cpp | 50 | ||||
-rw-r--r-- | day02/day02_input.txt | 1000 | ||||
-rw-r--r-- | day02/makefile | 2 | ||||
-rwxr-xr-x | day03/day03 | bin | 0 -> 83112 bytes | |||
-rw-r--r-- | day03/day03.cpp | 96 | ||||
-rw-r--r-- | day03/day03_input.txt | 1000 | ||||
-rw-r--r-- | day03/day03_input_ez.txt | 12 | ||||
-rw-r--r-- | day03/makefile | 2 | ||||
-rwxr-xr-x | day04/day04 | bin | 0 -> 116280 bytes | |||
-rw-r--r-- | day04/day04.cpp | 134 | ||||
-rw-r--r-- | day04/day04_input.txt | 601 | ||||
-rw-r--r-- | day04/day04_input_ez.txt | 19 | ||||
-rw-r--r-- | day04/makefile | 2 |
19 files changed, 4982 insertions, 0 deletions
diff --git a/day01/day01 b/day01/day01 Binary files differnew file mode 100755 index 0000000..8fb500a --- /dev/null +++ b/day01/day01 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 <iostream> +#include <string> +#include <vector> +#include <algorithm> + +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<std::string> split (std::vector<std::string> 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<std::string> vec; + vec = split(vec, txt); + std::vector<int> 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<depths.size(); i++) { + if (i >= window) { + int sum0 = 0, sum1 = 0; + for (int j=0; j<window; j++) sum0 += depths[i-j-1]; + for (int j=0; j<window; j++) sum1 += depths[i-j]; + if (sum1 > 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 Binary files differnew file mode 100755 index 0000000..8755c57 --- /dev/null +++ b/day02/day02 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 <iostream> + +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 Binary files differnew file mode 100755 index 0000000..ccb1732 --- /dev/null +++ b/day03/day03 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 <iostream> +#include <fstream> +#include <string> +#include <vector> + +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<int> get_freq (std::vector<std::string> bits) { + std::vector<int> freq; + for (std::size_t i=0; i<bits[0].size(); i++) { + freq.push_back(0); + } + + for (auto b : bits) { + for (std::size_t i=0; i< b.size(); i++) { + freq[i] += (b[i] == '0' ? 0 : 1)*2-1; + } + } + return freq; +} + +std::vector<std::string> filter (std::vector<std::string> bits, int inv, int sel) { + std::vector<std::string> 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<std::string> 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<freq.size(); i++) { + gamma += freq[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<std::string> o2 = bits; + for (std::size_t i=0; i<freq.size(); i++) { + o2 = filter(o2, 1, i); + if (o2.size() == 1) break; + } + + std::vector<std::string> co2 = bits; + for (std::size_t i=0; i<freq.size(); i++) { + co2 = filter(co2, -1, i); + if (co2.size() == 1) break; + } + + int generator = bin_to_dec(o2[0]); + int scrubber = bin_to_dec(co2[0]); + std::cout << "oxigen generator rating " << scrubber*generator << ", " + << "epsilon " << generator << " (" << o2[0] << "), " + << "gamma " << scrubber << " (" << co2[0] << ")" << std::endl; + + return 0; +} diff --git a/day03/day03_input.txt b/day03/day03_input.txt new file mode 100644 index 0000000..ac22a69 --- /dev/null +++ b/day03/day03_input.txt @@ -0,0 +1,1000 @@ +011001101000 +010101111100 +000000111101 +001001001010 +010011000001 +111111001110 +001011101111 +110011010110 +100011111110 +101110000111 +000011011100 +001111111011 +011101001111 +111001010110 +011100011110 +001011000010 +100010111011 +000101010011 +000001101100 +010001011110 +100010101000 +111101011101 +110000100001 +011011010101 +110101100110 +001101101010 +111010110011 +011111111000 +010001010001 +000001010101 +001001011011 +101111110011 +100011010001 +111010010111 +011010011010 +101111011011 +101010111100 +001111100110 +010100110111 +010110101100 +000111110101 +111110101110 +111010000000 +011111111010 +000101011100 +000001010110 +101000100101 +100001011001 +011101110010 +110111100100 +110011001011 +000010001111 +000100010101 +110111001100 +010001100000 +101111110101 +111000011011 +000100001001 +101101011101 +001001011110 +101100111010 +011011000010 +110010010111 +101001010101 +000000101110 +000011011111 +010001000011 +011011001010 +101101111011 +100010001010 +001001011100 +010011110001 +000001111101 +100001000101 +011101011010 +000010101110 +001010101010 +101010011011 +000111001011 +000011101000 +110100101001 +000111111010 +100111100101 +111010001111 +111100110001 +011111101010 +110101000011 +001111101100 +101000100110 +100101100011 +000011010011 +010101011111 +010000110111 +110011001001 +101011011101 +001011100001 +000001100101 +001001001101 +001101001111 +001110110001 +010110101110 +001100110110 +001000001111 +101101001001 +011111011010 +111111101110 +111001100000 +100101011001 +010101100101 +100000110100 +011001001000 +111100110011 +111011110001 +110011111010 +001101001010 +111110011111 +110101100000 +111001000101 +010001111110 +111011010100 +110011010111 +100100110111 +111111011010 +011110101111 +001011110010 +010111011010 +011101101101 +011010101110 +011000110001 +010110101010 +011110010000 +111111011100 +111011000101 +100110101110 +010101100010 +101100011110 +000010110101 +010010011110 +110000000110 +011111010101 +000110110011 +101011000010 +000011000111 +101011010000 +101101101001 +010000101010 +101001001001 +111010110110 +111000111101 +000001010111 +101110001100 +110010110001 +100000110001 +101100101011 +100000111001 +010110100111 +101011001111 +101010111001 +010010110000 +001110010011 +010101101110 +011000010100 +100111111000 +011110100011 +110100100111 +101110101000 +101010101111 +101001000000 +111010000110 +101001000100 +010001100111 +011011010001 +000101010101 +010110000011 +100000101110 +110010001000 +111000100001 +001001101001 +110010001001 +100001111011 +101010010100 +110011100101 +010101100001 +011101010100 +110100101111 +110100001111 +011000101101 +001011101100 +010010010101 +011011111010 +010101000001 +100101100000 +101001111101 +010000000100 +110000110100 +000000001101 +100100111101 +111100110010 +001011001111 +101100001011 +001111010001 +101100011001 +100110110001 +010111000011 +011010110101 +100111100011 +000111110011 +010101111101 +010010000000 +011000011011 +001100011001 +001011001001 +101110101101 +101111110111 +101011100100 +000100110100 +110000101111 +011001111101 +000000000111 +111001001010 +110100001100 +000001001110 +111001101011 +100011011111 +110000001000 +110101011011 +001010000101 +001011111001 +011011111100 +010100110101 +110101111001 +010110010101 +010010001000 +001001110111 +011111111111 +100011100010 +000110001101 +011111010000 +010111110010 +110010100011 +101011110101 +110011011110 +010000000101 +011101100100 +110010011100 +011101101100 +000010001001 +000011101101 +000101100011 +010111111000 +010111100111 +010101000101 +110111100010 +110001101011 +111010100000 +101010101011 +011101010101 +000100110111 +000111100111 +000100111111 +111100001001 +010000100001 +110101011111 +100010000100 +000011011000 +111011110000 +101000011100 +110001001010 +001000010101 +110110000101 +100000011110 +001101111010 +010111001100 +111011111100 +100101001000 +010111101001 +110010010000 +110011010000 +000010100111 +100101111101 +110101100010 +110100011110 +101111010110 +110001001111 +011101000111 +001011001101 +110001000010 +011110100110 +000101100110 +000110111110 +001010111010 +100110000111 +001000010110 +100001110100 +000111000110 +101100011100 +110100110110 +100011010111 +000101110001 +001010010110 +101000000101 +100101101000 +000111111110 +010010010111 +110010001010 +001100110111 +110110110101 +011111011101 +110101100111 +100100100111 +011011000000 +111101001100 +011101000011 +011101001010 +101101101101 +100100110010 +001000000010 +010010001010 +111110111001 +000111010001 +011100111111 +011111011001 +110101000000 +011110000010 +001111010110 +010011111111 +110101111011 +101110111111 +001001100001 +011100111100 +110111001110 +011000000111 +001100010111 +001011010010 +010010001011 +101110000011 +100000101000 +100010100100 +000111011101 +001000111011 +010010101010 +111011010011 +110100010001 +011110001110 +111010110001 +010000010111 +010110101101 +111101100001 +110011100110 +000101111110 +110010101010 +000001010000 +001101111101 +011011110100 +110001010101 +011001000001 +001101101100 +100011011011 +101011100010 +011011100101 +100110110101 +110111001011 +000100101011 +001101010100 +010000011100 +101100111011 +011001011100 +011011010100 +011100110001 +010010110011 +101000110011 +111101010001 +111000000100 +101101100111 +001011111000 +010100000111 +011110101101 +111011101100 +110101110001 +001110010000 +010010000111 +101001111011 +100100111100 +000101101101 +101111110100 +100000101111 +011001110000 +011110011001 +000101010110 +000000000101 +110010001100 +000111100100 +010010011010 +001111110100 +011010001010 +101100101111 +011001001011 +100011111101 +101100000001 +100100101010 +000000000100 +111001110101 +000010011110 +110110100100 +111010010001 +011101010010 +011100101111 +010110000010 +010000110101 +110101010011 +001110011110 +111010011010 +000110101000 +001111000001 +010110110000 +001100110001 +110011011111 +000100111011 +110001000111 +011010111101 +000010100110 +010100101001 +010001000010 +000101110101 +101100110100 +111000110010 +111011110010 +010111001111 +100000101101 +101100001010 +100100001001 +111111111101 +001010101001 +000011011010 +101011010010 +111001000110 +111100010011 +111010011100 +100000111100 +011100001101 +110001101000 +101111011001 +001100001000 +101110010111 +011111100000 +001011100000 +101011101010 +110010101111 +001110000101 +001111011011 +011110101000 +111000001000 +010100111010 +010010111001 +110000110001 +110011000101 +001110000100 +010100101101 +101010110100 +100001010100 +100011010011 +100000010010 +011101010111 +001000010111 +001100111100 +000110100011 +101111101010 +010001010000 +001100100110 +111001111110 +101000001001 +000010110010 +110111101011 +101011000011 +001000111111 +100011001101 +011010010101 +110011100011 +110010011010 +110001010100 +100010111101 +101110000110 +010111001011 +110011011100 +110001100011 +000100011010 +111011100010 +011110110011 +011111100010 +000100001101 +100010010000 +110000000011 +101001011000 +101100110101 +001010101011 +011001011010 +001010001001 +001111011100 +111100010001 +100011010110 +001000110111 +011011010011 +001100000000 +100001111100 +000011110101 +100010000111 +000010110011 +000010111110 +011110000101 +010000001011 +001111110010 +001110001001 +011101111111 +010110110001 +110000000111 +010101011101 +010111001001 +100100010010 +101001101110 +100001001010 +010001011101 +100111010101 +100000101011 +000100101001 +110111001001 +100100000001 +010111010010 +111101111011 +011010010010 +111101101000 +100110111101 +010010001001 +100111011000 +110101111111 +111010101110 +010011110010 +101001100100 +010000101111 +010011001111 +110010011111 +101110100111 +011010100101 +111111001001 +010101100110 +101001001101 +001000101010 +010001001100 +101001101000 +110110100000 +011101000101 +100101010101 +101110111011 +010010101001 +110100011000 +110101111010 +110000100000 +010011101101 +111011001101 +100100011101 +110100010111 +011100110100 +010111011001 +011101010001 +101000000010 +100111111001 +100100001000 +001000001000 +001000000100 +011110110010 +010101010011 +101101101100 +110111111001 +010000010011 +100010100001 +000110101111 +101010101101 +100101111100 +000111010110 +001101101111 +110010000011 +110100001110 +011111111101 +111011010101 +001010100010 +100010100110 +101101110111 +010110011011 +111001110110 +011110101001 +110011100111 +000100111101 +101100011000 +101101001010 +011111100111 +010000011000 +100001100110 +000000101101 +000111010010 +110000001100 +111111101010 +001000100010 +111111111011 +001011100111 +000101110010 +010111110011 +010000011001 +111001111101 +110100001101 +010001101000 +110000101011 +011011000110 +110010111011 +100111101010 +011001101011 +001101010011 +011000100101 +110111101111 +001000100001 +010010111101 +101101101011 +011111011100 +111111010110 +001110000000 +101011110010 +011101011111 +001001101101 +011101110000 +011100011101 +111101001101 +010111010101 +010111101010 +001000101101 +100000000011 +111110101111 +000111101111 +001110010101 +101111001101 +111100110000 +110010100000 +011101110100 +100011001111 +010110001001 +111100101100 +101001110100 +011010010111 +011000100100 +001100110100 +001001111000 +001000000111 +110100000111 +011000001011 +001011000000 +110110110111 +000010111011 +001001000011 +000011100111 +110011001111 +010000111101 +001110100010 +000011110001 +011001111011 +110111000001 +111111000001 +011001100110 +110010101100 +111101010100 +010010000101 +000011011011 +110110010001 +010111111010 +010000010101 +110000011010 +110001101110 +000110101011 +101111000111 +001101100000 +010100000001 +111110001001 +000011110000 +111100111001 +000001001011 +011000010110 +000001000100 +011100111000 +001011111110 +011100000000 +000101001011 +111111110110 +111010011000 +001000111101 +011001110010 +001101011100 +100110001111 +110110111010 +001110101100 +010000101100 +010011000011 +100101110010 +000000111010 +000001111001 +111101011000 +101000011001 +111110000101 +101111111011 +100110111110 +000110010110 +011011101110 +100000010111 +110111001000 +000010101010 +001010011011 +101010101010 +101100000000 +000101101011 +010110100110 +110010010100 +001010110101 +001110000001 +010001101010 +111111110100 +001101110110 +111101010111 +101011101100 +110001101010 +100111010100 +101101111001 +001011100110 +010010001111 +100101110110 +110011000010 +001111010100 +000101011011 +110000000001 +011011001001 +001001011111 +000111011111 +100001001100 +111011010010 +010101011001 +000001110100 +000010100101 +110110010010 +100010111110 +011110111110 +000001101000 +001011000110 +000010001010 +101101010100 +011011010000 +000011111000 +101000001110 +011110101011 +110100111000 +000011000010 +111111010001 +011101110001 +100000111101 +110100101101 +110000100101 +011001110110 +110001010010 +010010110110 +011110001000 +111010110100 +101111110010 +110000110111 +111101110100 +110111101110 +100110010111 +001001100011 +001110111000 +101110100100 +010000101101 +010111100101 +011001100010 +011100000101 +101001111001 +100011001010 +100010000010 +100101000010 +111111100101 +100001101110 +101001010110 +100000100011 +100000011000 +000110000001 +000000011011 +011000110101 +011010111011 +111110000001 +001001110100 +001011011110 +110111010110 +011101110101 +101111000101 +100001010010 +000001111000 +001110010100 +111111101100 +001011010001 +111001111001 +100101101010 +111000000010 +010101001010 +001010000010 +101011000110 +110011001010 +001000011000 +001010010011 +110000111101 +001001100000 +111101100111 +011001001100 +001100111011 +100001010101 +111010100011 +111000011111 +001000000000 +101110011001 +000000000011 +111011000111 +011010100011 +110000110000 +000011001001 +011000010001 +011110000011 +011101000000 +010100110011 +010110010001 +111001101111 +110111110100 +110111110110 +100111001011 +111100110110 +101010001110 +100110000010 +011011100001 +001101010010 +010001110011 +010011110000 +110010100111 +001101110100 +101010101100 +110000111000 +011101110110 +101011110001 +110011000000 +010000011011 +001011010000 +010111010001 +010100010101 +110101000100 +010011101011 +010110111001 +101111000011 +011011100000 +000010100010 +001100110000 +110000111001 +100100100000 +001101000010 +100000010011 +100010011110 +110101010000 +000100000101 +000111000001 +000001111011 +100111011101 +110111110111 +011101111000 +001001000110 +100110010011 +100011100111 +010011010000 +010011010111 +001101100101 +010000010110 +000101010001 +011111010100 +010010111100 +001010101110 +110000001011 +011001010101 +000001111110 +010111111011 +011110010010 +001001101100 +101100101000 +100000001110 +110001001110 +011110111011 +001000110011 +111100110111 +001101100111 +000110110000 +000010011011 +100110111010 +111110001100 +000000101100 +110000111100 +100110111100 +110111111100 +110000111010 +100001100100 +100010011010 +011011100110 +110100010110 +001001010101 +000110101110 +101001100000 +100010110011 +111000001101 +101110100110 +100010111100 +000101110110 +000011011001 +000001010100 +101100111001 +011101111101 +011110011000 +111010001011 +010101110101 +100001100101 +100110100010 +100110011000 +001010100110 +011001010111 +111111001010 +111111001000 +111110100101 +000101000011 +110101101111 +110100010010 +011100000010 +001000010100 +101100000111 +001010111111 +101001010011 +101011001000 +001100000011 +010010101000 +101101111101 +101001010010 +100101111011 +101110101110 +100000100100 +000000000010 +011101100011 +110000110110 +101000110000 +111011111010 +010111000110 +001111110110 +100111110110 +100110011101 +000000001000 +101110111010 +000101011000 +001011100011 +011101100111 +000011000011 +000101011001 +110101101101 +101000001111 +111000010101 +000011100010 +011010111001 +001100100101 +010111111101 +010101111011 +000101001100 +101010000111 +111100111111 +100000000111 +110111110011 +000110110111 +010011011111 +100110010100 +000100111110 +001000111001 +011111000001 +001010100101 +101010001100 +011100001011 +000101001111 +010010101111 +101000111011 +001101000001 +100100100001 +100010101111 +100111111110 +011011111001 +101000000001 +111001101101 +101011010101 +111111100110 +001010010100 +011101111001 +001100100000 +101001110110 diff --git a/day03/day03_input_ez.txt b/day03/day03_input_ez.txt new file mode 100644 index 0000000..a6366a8 --- /dev/null +++ b/day03/day03_input_ez.txt @@ -0,0 +1,12 @@ +00100 +11110 +10110 +10111 +10101 +01111 +00111 +11100 +10000 +11001 +00010 +01010 diff --git a/day03/makefile b/day03/makefile new file mode 100644 index 0000000..7c21cf0 --- /dev/null +++ b/day03/makefile @@ -0,0 +1,2 @@ +all day03.cpp: + g++ -std=c++20 -o day03 day03.cpp diff --git a/day04/day04 b/day04/day04 Binary files differnew file mode 100755 index 0000000..b28d295 --- /dev/null +++ b/day04/day04 diff --git a/day04/day04.cpp b/day04/day04.cpp new file mode 100644 index 0000000..7736eff --- /dev/null +++ b/day04/day04.cpp @@ -0,0 +1,134 @@ +#include <iostream> +#include <fstream> +#include <vector> + +void split (std::vector<std::string> &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<std::string> lines; + split(lines, repr, "\n"); + for (auto line : lines) { + std::vector<std::string> 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<int> cells; + std::vector<int> state; + + void mark (int ex) { + for (int y=0; y<size; y++) { + for (int x=0; x<size; x++) { + int i = x + y*size; + if (cells[i] == ex) { + state[i] = 1; + } + } + } + } + + bool win () { + for (int y=0; y<size; y++) { + int sum_row = 0; + for (int x=0; x<size; x++) { + int i = x + y*size; + sum_row += state[i]; + } + if (sum_row == size) return true; + } + for (int x=0; x<size; x++) { + int sum_col = 0; + for (int y=0; y<size; y++) { + int i = x + y*size; + sum_col += state[i]; + } + if (sum_col == size) return true; + } + return false; + } + + int score () { + int sum = 0; + for (int y=0; y<size; y++) { + for (int x=0; x<size; x++) { + int i = x + y*size; + if (state[i] == 0) { + sum += cells[i]; + } + } + } + return sum; + } +}; + +int main (int argc, char *argv[]) { + if (argc != 2) return 1; + std::string raw; + std::getline(std::ifstream(argv[1]), raw, '\0'); + + std::vector<int> extract; + auto token = raw.find("\n"); + if (token != std::string::npos) { + std::string ex = raw.substr(0, token); + std::vector<std::string> 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<Board> boards; + + std::vector<std::string> str_boards; + split(str_boards, raw, "\n\n"); + for (auto s : str_boards) { + boards.emplace_back(s); + } + + bool flag = false; + std::vector<Board> filtered = boards; + for (int ex : extract) { + std::cout << ex << " " << filtered.size() << std::endl; + std::vector<Board> 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 |