From dc39e86744bfd34e7460317b375faf34655845a3 Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 6 Dec 2021 18:42:38 +0100 Subject: [PATCH] Initial Commit Signed-off-by: Avior --- .gitattributes | 1 + .gitignore | 1 + README.md | 3 + d1/input.txt | 2000 +++++++++++++++++++++++++++++++++++++++++++++ d1/part1.ts | 12 + d1/part2.ts | 19 + d2/input.txt | 1000 +++++++++++++++++++++++ d2/part1.ts | 26 + d2/part2.ts | 28 + d3/ex.txt | 12 + d3/input.txt | 1000 +++++++++++++++++++++++ d3/part1.ts | 27 + d3/part2.ts | 38 + d4/ex.txt | 19 + d4/input.txt | 601 ++++++++++++++ d4/part1.ts | 30 + d4/part2.ts | 34 + d4/utils.ts | 38 + d5/ex.txt | 10 + d5/input.txt | 500 ++++++++++++ d5/part1.ts | 52 ++ d5/part2.ts | 67 ++ d6/ex.txt | 1 + d6/input.txt | 1 + d6/part1.ts | 28 + d6/part2.ts | 43 + package-lock.json | 261 ++++++ package.json | 9 + 28 files changed, 5861 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 d1/input.txt create mode 100644 d1/part1.ts create mode 100644 d1/part2.ts create mode 100644 d2/input.txt create mode 100644 d2/part1.ts create mode 100644 d2/part2.ts create mode 100644 d3/ex.txt create mode 100644 d3/input.txt create mode 100644 d3/part1.ts create mode 100644 d3/part2.ts create mode 100644 d4/ex.txt create mode 100644 d4/input.txt create mode 100644 d4/part1.ts create mode 100644 d4/part2.ts create mode 100644 d4/utils.ts create mode 100644 d5/ex.txt create mode 100644 d5/input.txt create mode 100644 d5/part1.ts create mode 100644 d5/part2.ts create mode 100644 d6/ex.txt create mode 100644 d6/input.txt create mode 100644 d6/part1.ts create mode 100644 d6/part2.ts create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5230a7 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# 2021 Advent of Code + +https://adventofcode.com/2021 \ No newline at end of file diff --git a/d1/input.txt b/d1/input.txt new file mode 100644 index 0000000..f65b86c --- /dev/null +++ b/d1/input.txt @@ -0,0 +1,2000 @@ +123 +126 +130 +137 +140 +150 +155 +157 +173 +186 +201 +205 +234 +236 +237 +252 +254 +258 +265 +266 +270 +278 +285 +289 +310 +332 +323 +349 +371 +372 +373 +380 +381 +382 +383 +401 +406 +408 +411 +412 +415 +410 +413 +423 +435 +440 +445 +448 +453 +454 +455 +470 +472 +473 +476 +480 +483 +485 +486 +489 +491 +490 +495 +497 +520 +537 +547 +555 +575 +577 +588 +594 +595 +597 +598 +599 +635 +636 +637 +638 +642 +649 +652 +654 +655 +658 +699 +700 +702 +716 +718 +724 +728 +729 +730 +731 +734 +744 +753 +754 +755 +774 +775 +789 +794 +795 +793 +790 +809 +827 +828 +831 +832 +839 +840 +841 +855 +856 +860 +861 +867 +875 +894 +901 +902 +923 +931 +935 +937 +944 +947 +952 +961 +963 +965 +985 +987 +1000 +1008 +1017 +1041 +1047 +1049 +1030 +1048 +1050 +1048 +1059 +1073 +1092 +1091 +1092 +1103 +1111 +1125 +1134 +1136 +1162 +1163 +1188 +1190 +1209 +1214 +1227 +1228 +1235 +1237 +1238 +1240 +1242 +1246 +1248 +1250 +1252 +1258 +1259 +1262 +1263 +1266 +1267 +1272 +1274 +1276 +1277 +1288 +1293 +1299 +1300 +1281 +1287 +1288 +1293 +1298 +1299 +1300 +1325 +1323 +1319 +1330 +1312 +1318 +1337 +1354 +1355 +1360 +1374 +1376 +1377 +1388 +1389 +1395 +1401 +1404 +1406 +1408 +1417 +1416 +1417 +1420 +1428 +1433 +1435 +1453 +1459 +1474 +1480 +1481 +1513 +1509 +1515 +1518 +1522 +1519 +1530 +1531 +1527 +1547 +1549 +1552 +1553 +1554 +1558 +1567 +1570 +1580 +1582 +1585 +1586 +1587 +1609 +1611 +1612 +1614 +1616 +1641 +1640 +1643 +1646 +1617 +1620 +1621 +1626 +1632 +1637 +1638 +1659 +1660 +1661 +1670 +1673 +1674 +1675 +1678 +1679 +1700 +1689 +1697 +1700 +1702 +1706 +1707 +1705 +1711 +1736 +1740 +1743 +1744 +1758 +1764 +1766 +1765 +1770 +1773 +1772 +1775 +1776 +1777 +1780 +1787 +1788 +1790 +1793 +1794 +1800 +1806 +1808 +1837 +1841 +1846 +1847 +1848 +1849 +1848 +1851 +1854 +1853 +1859 +1860 +1865 +1866 +1867 +1873 +1882 +1900 +1913 +1914 +1935 +1937 +1942 +1938 +1941 +1942 +1952 +1953 +1956 +1957 +1959 +1980 +1981 +1982 +1988 +2009 +2020 +2043 +2046 +2033 +2036 +2042 +2047 +2048 +2062 +2052 +2053 +2079 +2082 +2091 +2092 +2091 +2082 +2083 +2090 +2101 +2129 +2130 +2134 +2120 +2121 +2115 +2119 +2123 +2124 +2139 +2140 +2141 +2142 +2145 +2146 +2151 +2148 +2150 +2158 +2162 +2163 +2155 +2160 +2175 +2184 +2192 +2210 +2211 +2214 +2215 +2221 +2222 +2223 +2231 +2233 +2256 +2258 +2243 +2250 +2255 +2269 +2280 +2288 +2294 +2299 +2313 +2321 +2324 +2327 +2354 +2353 +2348 +2363 +2384 +2390 +2391 +2393 +2398 +2401 +2416 +2418 +2419 +2422 +2435 +2436 +2441 +2452 +2453 +2442 +2447 +2451 +2452 +2465 +2470 +2457 +2486 +2524 +2536 +2540 +2543 +2537 +2522 +2531 +2532 +2534 +2553 +2564 +2562 +2570 +2573 +2590 +2575 +2583 +2585 +2559 +2563 +2566 +2567 +2573 +2564 +2565 +2574 +2579 +2605 +2610 +2617 +2615 +2616 +2651 +2652 +2653 +2668 +2670 +2673 +2679 +2681 +2684 +2685 +2686 +2692 +2693 +2697 +2698 +2713 +2710 +2718 +2719 +2726 +2686 +2687 +2690 +2692 +2691 +2708 +2713 +2714 +2713 +2710 +2699 +2704 +2703 +2707 +2713 +2718 +2719 +2713 +2716 +2724 +2726 +2736 +2745 +2748 +2752 +2753 +2754 +2763 +2766 +2767 +2769 +2776 +2777 +2810 +2813 +2814 +2817 +2818 +2825 +2842 +2849 +2862 +2868 +2865 +2869 +2890 +2894 +2909 +2915 +2916 +2919 +2918 +2919 +2923 +2931 +2946 +2925 +2931 +2933 +2934 +2965 +2978 +2981 +2994 +2995 +2996 +2997 +3003 +3011 +3008 +3009 +3011 +3012 +3013 +3018 +3020 +3033 +3032 +3036 +3040 +3030 +3032 +3033 +3035 +3038 +3046 +3052 +3068 +3070 +3043 +3050 +3051 +3052 +3059 +3063 +3065 +3088 +3093 +3094 +3093 +3098 +3102 +3107 +3110 +3113 +3114 +3116 +3110 +3111 +3113 +3116 +3119 +3116 +3121 +3122 +3121 +3125 +3138 +3139 +3145 +3150 +3151 +3149 +3162 +3169 +3178 +3179 +3191 +3202 +3227 +3234 +3236 +3246 +3254 +3258 +3259 +3251 +3267 +3281 +3249 +3270 +3271 +3272 +3281 +3295 +3296 +3295 +3296 +3321 +3327 +3334 +3340 +3321 +3330 +3333 +3336 +3359 +3368 +3376 +3403 +3412 +3417 +3410 +3418 +3421 +3422 +3425 +3433 +3440 +3441 +3443 +3464 +3467 +3471 +3472 +3475 +3473 +3488 +3494 +3481 +3482 +3491 +3514 +3521 +3525 +3543 +3565 +3566 +3567 +3591 +3590 +3591 +3572 +3573 +3567 +3599 +3622 +3623 +3643 +3646 +3651 +3656 +3662 +3663 +3673 +3684 +3679 +3684 +3672 +3678 +3723 +3744 +3742 +3739 +3732 +3746 +3750 +3757 +3759 +3762 +3759 +3758 +3753 +3755 +3760 +3766 +3767 +3771 +3800 +3801 +3805 +3806 +3807 +3806 +3811 +3818 +3819 +3831 +3832 +3840 +3844 +3829 +3842 +3854 +3858 +3874 +3875 +3877 +3880 +3903 +3906 +3907 +3908 +3909 +3929 +3951 +3952 +3962 +3973 +3975 +3976 +3974 +3977 +4004 +4008 +4017 +4004 +4003 +4009 +4010 +4004 +4005 +4007 +4015 +4018 +4026 +4029 +4019 +4022 +4030 +4036 +4037 +4039 +4022 +4024 +4026 +4034 +4033 +4034 +4040 +4042 +4050 +4054 +4055 +4056 +4033 +4047 +4048 +4047 +4048 +4050 +4059 +4077 +4079 +4091 +4092 +4098 +4103 +4107 +4108 +4112 +4114 +4118 +4119 +4125 +4126 +4138 +4137 +4168 +4189 +4195 +4198 +4217 +4220 +4223 +4228 +4234 +4233 +4234 +4236 +4269 +4268 +4269 +4268 +4280 +4291 +4285 +4311 +4312 +4315 +4307 +4313 +4315 +4326 +4332 +4345 +4340 +4353 +4355 +4353 +4354 +4367 +4368 +4377 +4378 +4380 +4382 +4385 +4390 +4392 +4393 +4396 +4397 +4385 +4398 +4386 +4381 +4382 +4370 +4385 +4384 +4403 +4404 +4405 +4408 +4422 +4425 +4422 +4435 +4436 +4438 +4452 +4461 +4465 +4480 +4488 +4495 +4504 +4505 +4508 +4523 +4524 +4527 +4529 +4561 +4577 +4580 +4614 +4635 +4636 +4637 +4639 +4654 +4655 +4652 +4663 +4665 +4666 +4668 +4671 +4677 +4680 +4687 +4689 +4693 +4695 +4688 +4697 +4711 +4724 +4734 +4747 +4748 +4780 +4781 +4793 +4799 +4804 +4805 +4792 +4793 +4794 +4820 +4815 +4817 +4828 +4830 +4834 +4836 +4840 +4839 +4848 +4862 +4867 +4869 +4871 +4870 +4878 +4868 +4869 +4871 +4874 +4897 +4905 +4909 +4910 +4912 +4945 +4946 +4945 +4950 +4951 +4952 +4957 +4958 +4967 +4991 +4998 +5001 +5021 +5022 +5021 +5030 +5031 +5028 +5031 +5014 +5018 +5025 +5027 +5032 +5034 +5036 +5033 +5036 +5035 +5038 +5042 +5043 +5044 +5045 +5062 +5069 +5070 +5068 +5089 +5110 +5114 +5130 +5134 +5154 +5153 +5158 +5162 +5177 +5178 +5182 +5187 +5188 +5189 +5223 +5225 +5237 +5264 +5269 +5270 +5274 +5275 +5276 +5279 +5285 +5266 +5270 +5272 +5275 +5276 +5294 +5298 +5299 +5302 +5306 +5311 +5317 +5304 +5308 +5303 +5324 +5329 +5330 +5334 +5342 +5348 +5367 +5385 +5390 +5382 +5383 +5384 +5388 +5389 +5390 +5399 +5401 +5403 +5407 +5408 +5417 +5445 +5456 +5459 +5462 +5463 +5471 +5472 +5475 +5504 +5525 +5538 +5552 +5553 +5556 +5562 +5598 +5575 +5569 +5571 +5574 +5575 +5562 +5586 +5594 +5599 +5641 +5639 +5642 +5644 +5647 +5643 +5642 +5643 +5645 +5654 +5655 +5672 +5681 +5696 +5700 +5701 +5702 +5705 +5709 +5716 +5721 +5724 +5728 +5749 +5750 +5746 +5744 +5743 +5751 +5754 +5748 +5764 +5765 +5773 +5775 +5778 +5796 +5800 +5801 +5806 +5811 +5826 +5829 +5833 +5844 +5850 +5852 +5861 +5863 +5867 +5883 +5880 +5867 +5862 +5863 +5865 +5866 +5864 +5869 +5871 +5880 +5887 +5908 +5917 +5919 +5928 +5939 +5967 +5954 +5955 +5945 +5950 +5956 +5958 +5968 +5972 +5978 +5979 +5981 +5986 +5987 +5990 +5992 +5993 +6012 +6018 +6021 +6023 +6024 +6025 +6041 +6045 +6042 +6058 +6059 +6060 +6062 +6064 +6072 +6074 +6075 +6068 +6075 +6093 +6095 +6090 +6092 +6107 +6106 +6107 +6108 +6109 +6120 +6123 +6125 +6126 +6129 +6130 +6132 +6149 +6157 +6163 +6164 +6165 +6152 +6154 +6156 +6158 +6155 +6156 +6158 +6163 +6178 +6179 +6180 +6179 +6182 +6184 +6191 +6189 +6199 +6210 +6212 +6218 +6222 +6223 +6232 +6233 +6228 +6232 +6221 +6223 +6225 +6228 +6236 +6237 +6246 +6252 +6254 +6255 +6256 +6255 +6260 +6262 +6263 +6267 +6268 +6272 +6279 +6277 +6276 +6282 +6287 +6305 +6306 +6308 +6309 +6310 +6318 +6319 +6321 +6320 +6328 +6346 +6348 +6351 +6352 +6369 +6370 +6368 +6369 +6371 +6374 +6375 +6370 +6374 +6393 +6403 +6406 +6412 +6420 +6435 +6437 +6438 +6462 +6461 +6462 +6467 +6468 +6494 +6508 +6509 +6518 +6519 +6520 +6521 +6518 +6545 +6546 +6550 +6552 +6567 +6568 +6570 +6578 +6582 +6580 +6591 +6599 +6601 +6595 +6598 +6610 +6628 +6612 +6616 +6614 +6618 +6641 +6640 +6643 +6647 +6663 +6664 +6665 +6668 +6669 +6670 +6685 +6706 +6704 +6708 +6710 +6716 +6717 +6719 +6726 +6736 +6755 +6752 +6753 +6760 +6769 +6774 +6779 +6783 +6792 +6794 +6798 +6804 +6803 +6806 +6809 +6811 +6812 +6817 +6827 +6830 +6822 +6842 +6844 +6848 +6849 +6850 +6852 +6854 +6873 +6891 +6925 +6928 +6930 +6940 +6941 +6942 +6943 +6946 +6951 +6956 +6957 +6966 +6969 +6971 +6973 +7000 +7006 +7007 +7031 +7037 +7046 +7052 +7053 +7070 +7072 +7076 +7084 +7090 +7089 +7117 +7139 +7153 +7168 +7178 +7179 +7168 +7171 +7172 +7171 +7174 +7194 +7226 +7246 +7252 +7256 +7257 +7259 +7261 +7266 +7277 +7296 +7298 +7300 +7315 +7329 +7332 +7333 +7338 +7340 +7347 +7349 +7350 +7351 +7352 +7353 +7356 +7359 +7360 +7361 +7358 +7363 +7364 +7385 +7406 +7409 +7434 +7435 +7436 +7438 +7399 +7401 +7406 +7416 +7409 +7410 +7413 +7415 +7439 +7441 +7440 +7442 +7466 +7465 +7468 +7480 +7481 +7483 +7488 +7498 +7497 +7500 +7503 +7506 +7513 +7518 +7519 +7524 +7506 +7507 +7517 +7519 +7528 +7529 +7533 +7535 +7540 +7542 +7554 +7556 +7557 +7573 +7582 +7593 +7599 +7583 +7591 +7593 +7595 +7599 +7611 +7626 +7618 +7615 +7619 +7620 +7625 +7626 +7628 +7631 +7630 +7631 +7642 +7654 +7656 +7657 +7659 +7673 +7677 +7691 +7697 +7707 +7708 +7710 +7712 +7717 +7724 +7722 +7723 +7722 +7725 +7726 +7724 +7730 +7734 +7760 +7770 +7775 +7788 +7787 +7789 +7797 +7813 +7841 +7853 +7860 +7868 +7883 +7903 +7907 +7908 +7910 +7912 +7919 +7921 +7925 +7926 +7937 +7951 +7954 +7957 +7961 +7964 +7976 +7979 +7971 +7969 +7970 +7982 +7983 +7984 +7993 +8000 +8015 +8017 +8014 +8025 +8019 +8028 +8029 +8030 +8033 +8038 +8040 +8041 +8040 +8044 +8026 +8030 +8031 +8044 +8060 +8064 +8065 +8054 +8056 +8058 +8060 +8061 +8062 +8068 +8072 +8078 +8069 +8067 +8073 +8084 +8119 +8121 +8120 +8122 +8132 +8133 +8127 +8132 +8151 +8154 +8161 +8162 +8158 +8186 +8187 +8172 +8181 +8200 +8202 +8216 +8213 +8215 +8229 +8243 +8244 +8245 +8246 +8239 +8260 +8262 +8279 +8281 +8287 +8288 +8292 +8296 +8299 +8303 +8310 +8311 +8315 +8329 +8330 +8331 +8334 +8346 +8347 +8354 +8377 +8379 +8381 +8388 +8389 +8415 +8413 +8419 +8420 +8421 +8425 +8427 +8428 +8435 +8442 +8426 +8420 +8432 +8435 +8445 +8446 +8450 +8451 +8455 +8456 +8482 +8489 +8487 +8500 +8485 +8493 +8497 +8502 +8501 +8502 +8503 +8505 +8507 +8508 +8509 +8514 +8523 +8527 +8531 +8542 +8540 +8542 +8543 +8544 +8557 +8550 +8552 +8563 +8565 +8566 +8567 +8581 +8591 +8595 +8605 +8613 +8614 +8613 +8615 +8618 +8631 +8628 +8627 +8628 +8629 +8646 +8648 +8650 +8655 +8659 +8681 +8684 +8687 +8690 +8687 +8688 +8719 +8722 +8721 +8723 +8754 +8767 +8749 +8750 +8764 +8772 +8773 +8776 +8778 +8782 +8786 +8784 +8799 +8800 +8815 +8819 +8838 +8833 +8834 +8835 +8837 +8844 +8851 +8852 +8856 +8857 +8870 +8879 +8904 +8910 +8918 +8925 +8928 +8927 +8928 +8936 +8937 +8939 +8944 +8979 +8980 +8994 +8996 +8997 +8999 +9003 +9014 +9015 +9020 +9023 +9026 +9027 +9028 +9030 +9033 +9036 +9038 +9044 +9048 +9063 +9066 +9091 +9092 +9093 +9095 +9099 +9097 +9102 +9103 +9123 +9124 +9125 +9127 +9128 +9132 +9135 +9142 +9149 +9152 +9171 +9166 +9177 +9178 +9162 +9168 +9169 +9170 +9183 +9189 +9199 +9195 +9198 +9203 +9214 +9213 +9222 +9223 +9228 +9229 +9241 +9243 +9229 +9242 +9257 +9262 +9265 +9275 +9276 +9289 +9290 +9297 +9298 +9301 +9313 +9314 +9315 +9316 +9324 +9325 +9328 +9310 +9311 +9336 +9340 +9354 +9356 +9360 +9361 +9362 +9381 +9385 +9393 +9394 +9402 +9403 +9407 +9403 +9415 +9416 +9436 +9442 +9454 +9481 +9485 +9486 +9487 +9513 +9521 +9525 +9521 +9519 +9524 +9526 +9530 +9540 +9568 +9571 +9589 +9609 +9610 +9604 +9602 +9601 +9626 +9630 +9662 +9670 +9672 +9674 +9676 +9682 +9683 +9685 +9687 +9704 +9706 +9707 +9708 +9718 +9732 +9741 +9756 +9775 +9785 +9786 +9797 +9800 +9803 +9806 +9812 +9815 +9840 +9842 +9859 +9865 +9871 +9876 +9894 +9903 +9905 +9912 +9939 +9940 +9946 +9948 +9953 +9960 +9963 +9964 +9967 +9973 +9974 +9986 +9982 +9987 +9988 +10011 +10012 +10013 +10018 +10021 +10022 +10028 +10032 +10034 +10035 +10036 +10037 +10048 +10060 +10107 +10128 +10125 +10136 +10158 +10167 +10158 +10183 +10212 +10223 +10229 +10233 +10229 +10232 +10242 +10245 +10246 +10269 +10274 +10270 +10271 +10293 +10287 +10298 +10299 +10307 +10308 +10315 +10336 +10342 +10350 +10344 +10349 +10353 +10354 +10370 +10377 +10380 +10390 +10410 +10411 diff --git a/d1/part1.ts b/d1/part1.ts new file mode 100644 index 0000000..e45b219 --- /dev/null +++ b/d1/part1.ts @@ -0,0 +1,12 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + +var previous = Infinity +console.log("Result: " + + input.split('\n').reduce((p, c) => { + const tmp = previous + previous = parseInt(c) + return tmp < previous ? p + 1 : p + }, 0) +) \ No newline at end of file diff --git a/d1/part2.ts b/d1/part2.ts new file mode 100644 index 0000000..6d9e6d1 --- /dev/null +++ b/d1/part2.ts @@ -0,0 +1,19 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + +const items = input.split('\n') + +var previous = Infinity +var count = 0 + +for (let i = 0; i < items.length - 3; i++) { + const sum = parseInt(items[i]) + parseInt(items[i + 1]) + parseInt(items[i + 2]) + if (sum > previous) { + count++ + } + + previous = sum +} + +console.log(`Result: ${count}`) \ No newline at end of file diff --git a/d2/input.txt b/d2/input.txt new file mode 100644 index 0000000..d863ae7 --- /dev/null +++ b/d2/input.txt @@ -0,0 +1,1000 @@ +forward 8 +down 9 +forward 2 +down 1 +forward 9 +forward 7 +forward 5 +up 3 +up 3 +down 5 +forward 2 +down 8 +down 3 +forward 6 +down 2 +down 4 +down 7 +down 7 +forward 2 +down 6 +down 8 +down 2 +down 8 +up 9 +down 8 +forward 8 +down 5 +up 4 +forward 4 +forward 4 +forward 3 +down 9 +forward 8 +up 3 +forward 2 +forward 3 +forward 6 +down 7 +down 2 +forward 4 +forward 7 +forward 6 +up 5 +up 1 +forward 4 +down 9 +up 6 +forward 6 +up 9 +forward 1 +down 9 +forward 4 +down 3 +forward 7 +forward 5 +down 1 +up 9 +down 9 +forward 6 +forward 1 +down 5 +down 6 +forward 6 +forward 3 +up 4 +up 9 +down 3 +forward 6 +up 4 +up 6 +forward 4 +down 1 +down 2 +up 9 +forward 8 +down 2 +down 3 +down 4 +up 3 +forward 3 +forward 4 +down 4 +forward 7 +forward 9 +down 7 +forward 6 +forward 2 +up 6 +forward 7 +forward 9 +down 5 +forward 6 +up 9 +forward 6 +forward 2 +forward 6 +up 3 +down 1 +forward 5 +down 3 +forward 7 +down 4 +forward 1 +forward 7 +down 1 +up 2 +down 7 +down 6 +forward 8 +forward 2 +forward 1 +forward 9 +down 3 +forward 3 +down 6 +up 8 +up 3 +forward 1 +forward 3 +forward 7 +down 9 +forward 7 +forward 3 +up 6 +forward 4 +down 9 +forward 2 +down 4 +up 2 +down 1 +up 1 +down 6 +forward 1 +up 6 +up 7 +forward 3 +forward 3 +forward 2 +forward 1 +down 7 +forward 9 +down 5 +down 9 +up 9 +forward 3 +forward 8 +down 3 +forward 9 +forward 4 +down 3 +up 4 +up 8 +up 4 +down 8 +down 6 +down 5 +forward 2 +up 6 +up 1 +up 9 +down 4 +up 8 +forward 6 +down 1 +forward 7 +up 2 +forward 6 +up 2 +down 6 +down 5 +forward 2 +down 2 +down 1 +forward 8 +forward 1 +up 9 +forward 3 +down 6 +forward 2 +forward 8 +down 3 +forward 3 +forward 4 +forward 7 +forward 2 +up 4 +forward 8 +forward 1 +forward 9 +down 3 +down 1 +forward 8 +down 5 +down 3 +forward 5 +down 7 +down 1 +forward 8 +forward 2 +forward 4 +forward 8 +forward 6 +down 1 +forward 5 +forward 9 +forward 9 +up 9 +forward 9 +forward 4 +down 5 +down 2 +down 3 +forward 8 +forward 9 +up 8 +up 1 +up 6 +forward 7 +up 9 +forward 2 +forward 6 +up 6 +forward 3 +up 4 +forward 1 +down 4 +up 6 +down 5 +forward 7 +forward 6 +down 3 +down 4 +forward 3 +down 6 +down 1 +forward 5 +forward 7 +up 8 +forward 4 +up 7 +down 4 +forward 3 +down 7 +forward 7 +forward 4 +forward 1 +forward 8 +up 5 +up 6 +forward 5 +forward 3 +down 6 +forward 8 +forward 2 +forward 7 +down 7 +down 8 +down 3 +up 3 +down 1 +down 1 +forward 6 +forward 9 +forward 4 +forward 9 +forward 6 +down 1 +forward 9 +down 6 +down 8 +up 5 +down 8 +forward 4 +forward 2 +up 6 +down 9 +forward 6 +down 9 +down 6 +down 6 +forward 2 +up 8 +down 7 +down 2 +forward 2 +forward 2 +down 1 +up 8 +down 5 +forward 9 +forward 5 +forward 8 +forward 8 +forward 1 +down 2 +down 7 +up 5 +forward 9 +forward 4 +forward 4 +forward 6 +down 7 +up 5 +forward 5 +up 9 +down 7 +down 4 +down 9 +forward 7 +up 4 +down 1 +down 6 +up 2 +up 6 +down 2 +forward 9 +down 3 +forward 3 +forward 4 +forward 1 +up 2 +forward 6 +down 3 +forward 2 +down 9 +forward 8 +forward 3 +forward 2 +up 5 +forward 3 +forward 1 +down 8 +up 2 +up 4 +up 5 +down 3 +down 6 +down 1 +forward 4 +up 3 +down 1 +down 4 +up 6 +forward 8 +down 5 +down 7 +down 7 +forward 9 +forward 9 +down 2 +up 2 +down 5 +forward 5 +forward 4 +down 7 +forward 4 +down 2 +forward 2 +forward 4 +up 8 +down 8 +up 4 +forward 2 +forward 2 +up 8 +forward 2 +down 3 +down 7 +down 9 +up 6 +up 3 +forward 2 +forward 3 +up 8 +forward 6 +up 8 +up 1 +down 6 +down 8 +up 9 +down 1 +up 8 +forward 9 +forward 4 +forward 9 +forward 8 +forward 1 +down 6 +down 7 +up 5 +down 1 +forward 9 +down 9 +forward 7 +down 5 +forward 7 +down 1 +down 4 +down 4 +forward 6 +forward 1 +up 4 +up 2 +forward 7 +down 6 +down 2 +down 3 +up 7 +up 1 +down 6 +down 6 +down 8 +down 8 +forward 5 +forward 1 +forward 5 +up 8 +forward 8 +up 8 +forward 1 +down 9 +forward 1 +up 7 +up 3 +down 1 +down 9 +up 2 +down 3 +down 2 +forward 9 +up 9 +up 1 +up 5 +forward 8 +down 3 +down 7 +forward 7 +down 8 +down 5 +down 5 +down 4 +down 7 +forward 6 +forward 6 +forward 4 +forward 6 +forward 3 +up 5 +forward 2 +down 7 +forward 1 +down 4 +down 7 +down 7 +forward 4 +down 2 +up 4 +forward 2 +up 2 +up 3 +down 5 +forward 3 +down 2 +forward 5 +down 2 +down 1 +up 4 +up 5 +up 9 +forward 1 +forward 9 +down 9 +up 8 +forward 9 +forward 7 +down 9 +down 2 +down 9 +forward 9 +forward 7 +up 7 +forward 6 +up 6 +forward 5 +forward 6 +down 4 +forward 8 +forward 5 +forward 2 +up 4 +down 4 +forward 1 +down 2 +up 9 +up 7 +up 2 +up 3 +down 9 +forward 4 +up 6 +forward 5 +forward 5 +forward 9 +forward 1 +down 6 +forward 8 +down 5 +up 3 +up 1 +down 2 +up 4 +down 1 +down 9 +forward 8 +down 2 +forward 7 +down 7 +up 5 +down 7 +down 3 +forward 2 +forward 2 +forward 4 +down 9 +down 6 +down 9 +forward 6 +down 6 +down 9 +forward 1 +down 1 +forward 8 +down 4 +up 6 +down 2 +forward 9 +down 3 +up 3 +down 2 +up 2 +up 5 +down 8 +forward 1 +forward 3 +down 8 +up 3 +up 3 +up 3 +forward 2 +up 3 +down 4 +down 1 +down 7 +forward 3 +down 3 +down 8 +down 9 +forward 9 +forward 3 +up 4 +forward 8 +forward 8 +up 7 +up 3 +forward 6 +down 9 +up 1 +forward 2 +down 6 +up 6 +forward 2 +down 6 +down 3 +up 7 +forward 6 +down 6 +down 1 +down 5 +forward 6 +up 2 +down 2 +down 3 +down 1 +up 9 +forward 6 +up 2 +forward 2 +down 6 +up 3 +up 4 +forward 8 +up 8 +up 4 +down 7 +down 4 +up 9 +forward 9 +up 6 +forward 5 +forward 7 +forward 2 +forward 8 +down 7 +down 5 +down 4 +up 3 +forward 7 +down 2 +forward 5 +forward 9 +forward 4 +forward 7 +forward 8 +up 6 +down 1 +forward 3 +forward 9 +forward 1 +down 8 +down 1 +down 3 +down 1 +down 1 +up 3 +down 5 +up 1 +down 8 +down 2 +down 8 +down 3 +forward 2 +forward 8 +forward 4 +down 8 +down 6 +forward 8 +down 7 +forward 8 +forward 2 +forward 6 +forward 6 +forward 4 +up 2 +forward 3 +up 8 +forward 7 +forward 4 +down 8 +down 3 +down 4 +up 8 +forward 5 +forward 3 +up 4 +up 2 +down 6 +forward 4 +up 8 +up 3 +up 8 +down 3 +up 1 +forward 2 +down 4 +down 4 +down 9 +down 5 +forward 9 +up 6 +up 5 +down 8 +down 6 +down 7 +forward 8 +forward 4 +up 4 +forward 1 +down 4 +up 4 +down 9 +up 6 +down 9 +up 3 +forward 4 +down 1 +down 5 +down 5 +up 1 +down 8 +down 9 +down 1 +forward 4 +down 8 +down 6 +down 1 +forward 2 +down 5 +up 1 +up 1 +down 1 +down 3 +down 3 +down 8 +down 6 +down 5 +down 3 +up 3 +forward 5 +down 7 +down 7 +forward 2 +forward 6 +forward 1 +down 8 +forward 2 +up 2 +forward 2 +down 2 +forward 7 +down 7 +down 9 +up 2 +up 2 +down 3 +forward 1 +down 1 +forward 5 +forward 4 +down 4 +forward 6 +forward 2 +forward 7 +forward 2 +forward 8 +down 4 +up 3 +down 3 +up 9 +down 7 +up 8 +down 1 +down 8 +up 9 +down 6 +up 5 +up 8 +down 2 +down 3 +forward 1 +down 5 +down 5 +forward 8 +down 9 +forward 7 +forward 8 +down 1 +down 2 +up 8 +down 2 +up 5 +down 3 +forward 5 +forward 6 +up 4 +up 3 +forward 5 +forward 1 +down 2 +forward 2 +down 9 +up 7 +down 2 +up 8 +forward 2 +forward 2 +up 4 +forward 5 +down 4 +up 6 +up 8 +forward 9 +up 1 +forward 9 +forward 7 +forward 3 +forward 1 +down 1 +forward 5 +forward 2 +forward 6 +forward 6 +forward 3 +forward 7 +up 7 +down 6 +down 2 +up 5 +down 5 +up 2 +forward 7 +forward 2 +down 9 +up 4 +down 5 +down 3 +forward 7 +down 2 +forward 9 +forward 6 +down 3 +down 3 +forward 6 +down 9 +forward 7 +up 5 +up 6 +down 3 +up 4 +forward 4 +up 3 +down 8 +down 9 +down 9 +down 4 +up 1 +up 2 +down 3 +forward 4 +forward 5 +down 1 +up 3 +down 8 +down 7 +forward 2 +up 4 +down 8 +forward 1 +forward 6 +up 8 +down 2 +down 6 +forward 5 +up 8 +forward 7 +down 9 +forward 9 +down 3 +forward 9 +forward 1 +forward 6 +up 7 +forward 1 +down 5 +down 8 +down 3 +forward 5 +forward 6 +down 7 +forward 4 +down 6 +forward 4 +up 4 +down 4 +forward 4 +down 9 +forward 3 +down 6 +forward 3 +down 3 +up 3 +forward 3 +down 4 +down 4 +down 4 +down 5 +forward 5 +down 9 +down 7 +down 1 +forward 5 +forward 3 +forward 8 +down 5 +forward 4 +forward 3 +down 8 +forward 1 +forward 1 +down 6 +forward 4 +down 5 +forward 8 +down 7 +forward 6 +down 7 +up 2 +forward 6 +down 7 +down 3 +down 6 +up 2 +forward 8 +forward 5 +down 6 +forward 5 +up 7 +forward 8 +down 1 +forward 2 +up 7 +down 4 +up 5 +forward 5 +forward 4 +forward 3 +down 1 +forward 8 +up 9 +down 2 +up 4 +forward 7 +up 6 +forward 3 +down 8 +forward 4 +down 2 +down 9 +forward 8 +down 5 +forward 3 +down 9 +up 1 +forward 6 +up 9 +down 7 +forward 5 +forward 3 +down 8 +down 6 +up 3 +down 5 +forward 7 +up 2 +forward 4 +up 1 +down 8 +down 7 +forward 3 +forward 1 +down 3 +down 8 +forward 7 +up 2 +down 7 +up 6 +down 7 +down 1 +down 3 +up 6 +forward 2 +down 5 +forward 1 +forward 7 +forward 2 +down 8 +down 8 +down 7 +forward 7 +forward 5 +forward 1 +forward 7 +forward 3 +down 2 +up 8 +up 4 +up 6 +down 2 +down 1 +down 5 +down 3 +forward 2 +up 1 +forward 8 +up 8 +forward 7 +up 1 +down 7 +forward 7 +forward 5 +forward 3 +up 4 +down 5 +down 5 +forward 3 +forward 9 +down 9 +up 6 +up 7 +down 7 +forward 7 diff --git a/d2/part1.ts b/d2/part1.ts new file mode 100644 index 0000000..97ed403 --- /dev/null +++ b/d2/part1.ts @@ -0,0 +1,26 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split('\n') + +var x = 0 +var y = 0 +for (const line of input) { + const splitted = line.split(' ') + const action = splitted[0] + const value = parseInt(splitted[1]) + + switch (action) { + case 'forward': + x += value + break + case 'up': + y -= value + break + case 'down': + y += value + break + } +} + +console.log(`Result: ${x * y}`) \ No newline at end of file diff --git a/d2/part2.ts b/d2/part2.ts new file mode 100644 index 0000000..5e8a205 --- /dev/null +++ b/d2/part2.ts @@ -0,0 +1,28 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split('\n') + +var positionX = 0 +var depth = 0 +var aim = 0 +for (const line of input) { + const splitted = line.split(' ') + const action = splitted[0] + const value = parseInt(splitted[1]) + + switch (action) { + case 'forward': + positionX += value + depth += aim * value + break + case 'up': + aim -= value + break + case 'down': + aim += value + break + } +} + +console.log(`Result: ${positionX} * ${depth} = ${positionX * depth}`) \ No newline at end of file diff --git a/d3/ex.txt b/d3/ex.txt new file mode 100644 index 0000000..665fd57 --- /dev/null +++ b/d3/ex.txt @@ -0,0 +1,12 @@ +00100 +11110 +10110 +10111 +10101 +01111 +00111 +11100 +10000 +11001 +00010 +01010 \ No newline at end of file diff --git a/d3/input.txt b/d3/input.txt new file mode 100644 index 0000000..40073fe --- /dev/null +++ b/d3/input.txt @@ -0,0 +1,1000 @@ +111011110101 +011000111010 +100000010010 +000111100110 +110011111011 +001100010111 +011000100100 +110011111010 +101011010111 +010001001011 +001011011010 +110001000110 +011101111111 +100101010010 +011010010001 +010111011110 +001101101001 +100000100101 +011010100101 +010011010011 +100000000000 +001010001000 +101100110001 +011010000111 +011011101101 +101000011111 +100010110000 +101011000010 +010001100100 +100100011001 +111000101110 +101010111010 +000111011101 +011101110101 +000010101101 +110110000000 +111110100101 +100110101100 +000001100001 +101001110010 +011101100001 +110111011101 +000001111001 +000110110000 +111001110110 +101011110101 +010010011000 +101011110011 +011101101110 +100010000110 +001000010110 +110000000100 +010111101101 +100000001110 +111010100101 +101000000110 +100001101111 +000010011010 +111001000100 +000100011101 +000101101001 +100111110011 +111011010010 +110111001010 +100111111100 +011011110101 +011001111111 +111010101101 +011111010000 +100010010000 +111110111110 +000111101100 +100001011101 +000100001010 +111110101110 +001000011010 +010100010011 +101111101011 +001001001101 +111111100101 +000101110011 +100001000000 +100001111011 +001001000111 +101101001101 +010011111011 +111001001110 +000100010100 +000101100001 +111011000100 +010101111010 +110110100101 +001011000101 +100110000101 +001110100100 +100111110111 +011100001101 +001001111110 +000001011011 +101001011011 +010111101011 +101001011101 +011101110011 +111110100100 +101100010010 +110001000100 +001101000100 +000110011011 +100111101111 +010100000110 +100101001011 +101101000000 +110000111100 +010011110100 +110101000110 +011111010101 +100101010100 +111111010000 +011000010101 +000001010001 +100100100100 +101101101111 +011011000111 +100101101011 +101001001101 +010110111000 +000111111000 +110010100001 +011011011011 +111001111111 +101010010010 +011110101000 +001110110100 +111011010111 +001011010011 +101000010100 +100001000001 +000001111101 +011000000101 +101010101111 +100011100010 +010010100111 +011111000010 +110000111010 +010111110110 +101000001100 +001111001010 +000000100110 +100000101100 +010001011011 +000000110011 +011101100110 +000011101110 +011110011010 +100000110110 +010011011010 +001000000100 +001001101011 +000101101111 +011000110011 +101001000101 +011010101100 +010010111111 +110010100101 +011100101011 +011110111000 +001000101001 +010011111001 +001111001000 +111010000110 +000010000011 +100101011010 +100010001010 +010111010000 +000000111101 +001000110101 +001101010000 +100000010101 +111000010000 +001100010010 +000110101100 +001111110111 +100111010100 +000110001001 +101010111000 +110111101011 +110000010101 +011000101011 +010111001111 +011000001101 +011011011100 +011011000110 +011110111100 +010110010011 +000100110101 +101100111101 +111001100001 +001111010011 +110100010110 +111010000011 +000011110000 +010010111010 +100010101010 +110010101011 +001100001010 +010011001011 +110011000001 +010011101001 +010101000111 +001011000001 +001110101001 +011111110101 +000011100000 +001001000011 +010111110000 +011001000000 +111111011001 +111010001100 +011011001001 +111001101100 +111001111011 +111100111110 +100110111011 +011011110100 +111011100001 +000111110101 +011100001010 +001110110101 +101110011010 +100010100000 +100100111011 +110000110010 +001000101010 +110001100011 +001101100100 +000101010000 +011110110001 +100100110101 +111101111100 +011011111001 +111101000000 +000100111000 +101100100001 +111100001011 +000111110110 +100101001010 +100000111100 +100100000000 +011001011101 +111111100100 +111101010110 +011110001110 +100101110010 +101110011101 +110001100111 +001110011011 +001111111100 +001101111111 +011000100010 +010001110111 +010010110111 +001001001000 +010010010001 +100111010011 +000011110100 +110000110011 +100001101101 +001111110010 +100111110100 +111010111011 +101011101001 +000100100000 +111010110100 +011111010011 +000101011111 +110011110111 +110101001110 +101111111010 +000110111111 +101011010100 +100011000000 +101010001001 +001110100010 +110100111101 +001100011100 +100111001000 +001010000110 +000001100110 +001000101110 +010011101010 +110001100000 +011011111101 +110110001101 +010101011010 +010010001101 +010101111000 +001110001011 +001001100000 +101110110011 +000011011011 +001010110101 +101101011100 +101011100011 +010100010100 +011111010100 +100110101110 +001100100100 +001100111100 +000000100111 +101011001110 +010010100101 +010100001111 +000010111101 +000111101101 +100010000010 +110101100100 +111100101100 +101101110000 +110000011100 +101111100111 +010111100000 +010100001101 +000110111001 +010010011100 +110000110100 +011000000001 +010100100110 +001111011101 +111101111010 +011011101111 +010011001000 +110010101000 +101001000111 +101100000111 +111000110011 +101101010011 +110000111000 +000010000000 +100010101111 +000111101001 +000100110000 +110011011101 +110110010110 +110100110100 +011110111101 +000001011100 +101010100000 +010100101000 +001111001100 +101010000010 +111000100110 +111101101111 +001000010111 +110000011101 +110101010010 +110101110100 +101001001011 +001001101000 +010001111110 +010011111000 +101010110001 +101110010101 +111011011110 +111011111000 +110000110101 +011110101010 +110011110110 +110001001111 +110001111011 +000011010011 +010001001001 +001111110001 +101000111101 +101010110010 +010100101100 +101000100100 +001110100101 +011110110110 +101001111011 +111100000010 +011010100011 +000011000001 +010101110111 +000010100110 +111110010101 +000110100100 +010111001110 +111100111101 +001001011001 +000111010011 +010100011011 +011111100101 +110111010111 +101111000001 +101010010001 +001111110101 +111111111001 +011010110111 +000110011000 +010010111100 +101011110100 +110010101001 +111011001101 +110010001001 +010100000000 +011101010001 +011100111101 +000111010100 +111111001100 +011100101100 +110100000011 +100011101100 +101101001011 +100111100001 +011010111001 +101010111100 +000011111001 +101010100110 +000110111011 +101100011011 +001100111101 +100110001010 +001011011111 +110111011011 +100011001001 +010000101100 +000111101000 +101011110000 +001111001011 +111010000101 +101010011010 +000100010101 +110100101001 +100010111010 +100011111111 +010010011111 +101010010111 +001000101100 +000000111100 +101000001010 +100010010011 +110011001111 +010001101111 +000000000010 +111100110100 +100001001010 +100101101010 +101100000001 +000110100001 +111101110010 +001100111011 +001101001001 +001010010000 +000001001111 +100101001100 +110010010001 +011010010010 +101100011010 +001101111101 +101111101010 +110111101110 +001000011000 +101100010110 +010001100111 +001011000010 +000010110000 +111100000100 +111100100111 +100101100110 +111101000100 +101110010100 +101011010010 +100111110000 +111101100000 +110111110011 +000000100000 +011011110111 +100110101111 +010011111110 +011111101001 +101001100000 +011000010010 +101001000011 +001001010011 +000010001100 +000110101000 +101110100011 +010001001010 +000110011111 +111001101110 +100011101110 +101001110001 +101001110100 +001001000001 +101100110011 +001111100101 +101111010101 +001111001001 +110101100011 +000000011001 +100100011010 +011011101000 +000011011000 +101011100010 +101110101001 +000110101010 +011000000100 +001111010001 +110001110010 +001101101110 +000100111101 +001000001001 +000111111100 +001110111010 +101000011110 +100001101100 +110101000111 +000011010101 +101110010010 +111011000000 +100100111111 +111100000001 +000100011001 +100001100010 +110011100001 +100100101010 +100100110000 +011000110100 +101001110000 +101111100110 +100011101001 +110100111001 +100011111110 +000001001110 +000110100111 +001000100100 +101011111110 +011100100111 +100101111111 +001011111110 +000010101100 +110100011101 +000100101010 +111001011101 +011010000000 +011011010100 +001001100110 +100000100111 +011000011010 +010000100100 +011010110011 +001011100001 +010111101111 +010100110000 +001111101101 +111001101001 +001001100011 +000000100011 +110010000001 +110000110110 +010011100001 +001000011110 +110001110100 +111111011111 +010000111001 +001101001011 +000111110011 +011110011101 +111001010011 +000010111111 +111000110111 +010100010101 +010100111011 +110001110011 +110100010000 +011110111110 +010111010011 +100001001011 +011010110101 +001111110110 +111011110000 +001110111100 +001101010111 +010110011001 +111000000001 +101011000110 +010110111001 +101010110101 +010010101001 +001110011110 +010100000101 +010011010100 +011110110101 +100000001000 +011011100111 +000101100000 +101001101000 +001101010010 +101110101011 +000110100011 +100110001100 +001010110111 +010000100111 +100100110111 +101000111001 +101011001101 +011110101101 +110010011000 +011100101111 +111101111101 +101001001000 +111010100001 +011011100101 +100110011101 +011100000011 +011110001001 +011111000011 +011100011001 +010100011010 +111010101111 +101100100101 +110110101111 +001011100110 +001110111011 +010010001011 +111001010010 +001011011101 +110100010011 +010110001000 +001110100111 +110011011110 +001011111000 +011111111011 +100111111000 +110000010011 +010011011100 +010111001011 +010110100111 +011010000110 +001111100000 +000010110110 +101011001100 +001100011001 +010010011001 +100010101001 +110100111000 +111010010010 +101110110000 +110100001010 +001010000011 +110111111001 +010100010110 +000110110001 +100101100010 +111101101001 +011001010110 +011100010010 +000111100000 +110000010001 +001010001101 +001001011101 +011101101000 +000101111101 +101101001000 +111010010001 +001010011010 +110010111100 +100111101101 +011111110100 +000110010011 +000011110111 +110111100011 +111111100010 +101101100010 +000111100011 +011010000101 +101010010101 +010101101000 +001001101100 +111000011001 +100100001111 +000001011110 +000101000000 +011011011000 +101111010100 +010101010010 +011001001001 +011100010001 +101101110011 +101110111101 +111011010000 +110000011000 +011111110001 +101111010000 +100101101101 +011001111101 +100101111100 +001110001110 +011001101001 +111101110101 +111100110011 +011101010011 +111111101010 +000011100111 +110110111100 +001010100110 +001011101001 +101001111001 +111101001010 +010110001111 +010100001110 +001110100011 +111111000000 +010110011101 +000110010010 +001011001111 +010111110001 +100100000111 +100110010110 +110100001101 +100001001100 +000010110111 +010000110001 +101110101000 +010000010010 +001001101001 +010110011011 +110101000100 +000000101011 +101001111100 +110100110110 +100001100100 +111010110000 +101110010001 +000000000110 +000100010111 +011010100100 +110111001000 +000000001111 +111111011101 +010100010111 +110010100110 +100100110110 +001101100101 +101010100111 +001110000100 +001010011101 +011110001011 +000101100110 +011000011101 +011110011000 +001011000100 +110001100100 +001111011000 +101000001101 +110111000010 +110010101101 +110001001101 +000011111000 +111110011110 +000010100111 +111111011110 +110010001010 +000101100111 +101000110001 +011111011010 +010111110010 +011001100011 +110011001010 +010011001101 +110101010111 +011101001110 +010011000110 +110000001100 +100001111111 +010101001011 +001100101000 +101010011101 +000011101010 +100011011110 +111001111110 +100110001111 +100101011101 +011111000100 +000010101010 +110010010100 +001110000010 +100100000100 +101011011110 +100111001111 +100101011011 +110001001110 +001101011110 +010001010001 +000110100000 +001000001100 +100111000100 +100010000000 +101111111111 +010011101111 +101011100100 +010111011111 +110011011010 +111101000110 +010000001010 +100110100100 +011000011100 +100011011001 +101000001111 +100001100101 +111110111010 +110101010100 +000110110111 +001110000011 +101110101101 +000101011100 +010011000101 +010101000100 +000001001001 +111011101110 +001010011011 +000001000010 +111110001011 +110101111111 +010000010001 +001100000011 +101101000011 +110100001001 +111100010011 +000000001100 +100000101010 +001011101111 +011111101000 +111011001000 +010011101101 +100101010011 +101000010110 +011100000101 +011101001000 +111000001011 +100001011010 +001000111011 +001100001000 +001011010000 +001000110100 +010011100010 +000111010101 +000000010011 +000011001000 +101100110101 +100110110100 +001100100000 +011100000010 +010101111110 +100100100001 +110111111000 +110110011110 +000101010010 +010011110010 +000000111000 +111000001000 +000110001000 +101010110110 +010111111111 +011100101101 +010100000111 +100010011011 +110010001011 +110011110010 +010101110110 +110000011110 +101010011001 +100100110010 +110100010111 +100001010101 +111010010011 +011100001110 +111101110011 +001011010100 +000001000001 +010010101011 +110000101110 +111100011000 +100001011111 +010011010110 +100001000100 +010001110000 +011011001000 +101101010001 +011101101101 +011001010010 +111010010111 +100110011001 +111101010111 +111110111011 +000011101001 +001010111001 +000000011111 +000000000000 +100100000001 +011100011010 +111101010101 +001001001100 +100010110111 +110111010010 +001110101010 +111010101000 +100011100001 +000000111011 +011000010110 +010000111011 +111110110000 +100001100000 +001110000111 +100000100110 +101000110000 +000110001011 +111111101101 +010100101111 +100111000010 +010110110111 +101010111111 +000110111101 +000100000100 +011010001111 +110010111001 +101001000001 +010010011010 +110011111110 +011000010001 +110110010100 +110110111110 +101100010001 +010101011000 +011000111111 +010110010000 +101100111001 +000111001000 +010010001001 +101110100101 +001110010110 +101011011011 +111111110100 +010100101101 +001110110010 +010101001010 +110011010010 +011011011010 +100110010111 +011111101011 +110010110100 +100100111110 +100100000010 +010000111100 +001111101011 +010101101001 +110100001011 +110101010110 +010111000110 +011101100011 +001011100111 +011001100010 +101001110011 +001100111010 +101000011001 +110101111100 +110011001110 +100001010111 +111111000010 +010110010010 +101000000101 +000010010001 +001100110100 +100010011111 +100111111101 +111111000101 +010000110100 +000001101010 +011000001010 +010000111111 +000010001001 +111110100000 +110101010000 +001011011011 +011011100011 +001011110001 +010110111100 +100011010001 +011010001110 +110110111000 +011011110001 +110100100000 +111011001001 +101001100110 +010010110101 +111111111110 +100001100110 +001110001101 +100111100101 +001101100001 \ No newline at end of file diff --git a/d3/part1.ts b/d3/part1.ts new file mode 100644 index 0000000..9b5c261 --- /dev/null +++ b/d3/part1.ts @@ -0,0 +1,27 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split('\n') + +const list: Array<{0: number, 1: number}> = [] +for (const line of input) { + const splitted = line.split('') + for (let i = 0; i < splitted.length; i++) { + const bit = splitted[i]; + if (!list[i]) { + list[i] = {0: 0, 1: 0} + } + list[i][bit === '0' ? 0 : 1]++ + } +} + +let gamma = '' +let epsilon = '' +for (const item of list) { + gamma = gamma + ((item[0] > item[1]) ? '0' : '1') + epsilon = epsilon + ((item[0] < item[1]) ? '0' : '1') +} + +console.log(list) + +console.log(`Result: ${parseInt(gamma, 2) * parseInt(epsilon, 2)}`) \ No newline at end of file diff --git a/d3/part2.ts b/d3/part2.ts new file mode 100644 index 0000000..c798b3c --- /dev/null +++ b/d3/part2.ts @@ -0,0 +1,38 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split('\n') + + + +function find(mostUsed = true) { + let list = input + for (let i = 0; i < list[0].length; i++) { + const counts = {'0': 0, '1': 0} + for (const line of list) { + const bit = line[i] as '0' | '1' + counts[bit]++ + } + + const comparator = counts['0'] > counts['1'] ? '0' : '1' + let fn: (item: string) => boolean + if (mostUsed) { + fn = (line) => line[i] === comparator + } else { + fn = (line) => line[i] !== comparator + } + + list = list.filter(fn) + + if (list.length === 1) { + break + } + } + + return list[0] +} +const resORG = find() +console.log(`ORG: ${resORG} or ${parseInt(resORG, 2)}`) +const resCSR = find(false) +console.log(`CSR: ${resCSR} or ${parseInt(resCSR, 2)}`) +console.log(`Result: ${parseInt(resORG, 2) * parseInt(resCSR, 2)}`) diff --git a/d4/ex.txt b/d4/ex.txt new file mode 100644 index 0000000..49d17bc --- /dev/null +++ b/d4/ex.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 \ No newline at end of file diff --git a/d4/input.txt b/d4/input.txt new file mode 100644 index 0000000..48cc64f --- /dev/null +++ b/d4/input.txt @@ -0,0 +1,601 @@ +83,5,71,61,88,55,95,6,0,97,20,16,27,7,79,25,81,29,22,52,43,21,53,59,99,18,35,96,51,93,14,77,15,3,57,28,58,17,50,32,74,63,76,84,65,9,62,67,48,12,8,68,31,19,36,85,98,30,91,89,66,80,75,47,4,23,60,70,87,90,13,38,56,34,46,24,41,92,37,49,73,10,94,26,42,40,33,54,86,82,72,39,2,45,78,11,1,44,69,64 + +97 62 17 5 79 + 1 99 98 80 84 +44 16 2 40 94 +68 95 49 32 8 +38 35 23 89 3 + +48 53 59 99 43 +77 24 62 50 27 +28 8 10 86 18 +96 9 92 66 67 +20 55 87 52 31 + +79 51 62 33 5 +15 39 21 48 90 +88 29 7 92 98 +87 49 84 6 14 +72 85 46 71 26 + + 3 86 40 61 65 + 4 82 28 46 32 +31 5 33 96 98 +30 62 68 75 70 + 9 18 92 19 72 + +82 24 95 21 79 +85 84 38 89 50 + 7 10 5 25 20 +99 37 48 86 12 +68 93 6 66 43 + + 9 95 75 14 1 +94 90 40 84 24 +43 72 93 4 87 +48 50 53 20 6 +65 11 38 25 46 + +41 22 47 34 55 +74 57 42 85 33 +40 21 52 78 7 +51 58 37 4 49 +53 75 11 48 76 + +90 6 98 25 80 +41 81 30 87 33 +11 21 79 62 92 +27 60 46 56 88 + 4 69 70 13 84 + + 1 22 72 43 58 +78 97 52 61 62 +27 48 81 2 63 +33 37 4 82 18 +65 28 70 31 59 + +78 51 69 47 16 +48 55 58 70 37 + 7 59 66 5 76 +94 52 82 22 10 +13 83 95 24 79 + + 8 38 40 67 24 +45 9 21 7 89 +82 96 72 92 4 +86 49 80 79 22 +26 11 84 78 70 + +32 73 0 37 86 +78 42 13 30 53 +44 99 51 12 96 +45 57 63 34 58 +41 91 7 49 52 + + 1 66 8 6 7 +47 96 25 77 72 +23 22 31 42 24 +52 27 53 51 99 +21 65 35 84 5 + +49 1 79 39 82 + 7 96 13 33 85 + 3 53 32 12 50 +36 30 27 55 95 +16 24 2 66 77 + +45 75 85 35 72 +99 25 91 68 28 +29 52 1 80 98 +62 46 63 22 44 +82 86 57 24 58 + +70 19 79 7 24 +35 71 93 42 76 +17 88 62 25 12 +54 0 11 32 58 +38 64 29 75 80 + +58 93 63 52 23 +77 60 1 38 87 +75 89 85 25 91 +64 39 96 49 66 +14 45 84 13 29 + +85 10 21 33 80 +78 86 77 41 36 +98 58 53 82 72 +75 20 65 3 46 +52 16 74 45 99 + +45 97 96 23 62 +79 59 60 87 64 +75 2 30 47 50 +85 81 56 11 38 +17 26 40 7 66 + +94 99 67 88 82 +96 5 21 53 52 +41 15 49 35 89 +54 39 66 24 51 + 9 6 62 33 70 + +33 89 48 4 20 +46 66 45 76 7 +12 77 43 60 15 +54 58 91 95 69 +11 8 32 31 18 + +63 78 55 7 60 +95 14 38 10 45 + 3 16 72 53 37 + 1 89 70 75 44 + 5 6 66 13 46 + +74 65 27 53 39 +67 66 76 13 31 +75 51 11 49 59 +18 12 71 9 89 +98 24 73 26 43 + +90 21 75 77 97 +80 29 54 16 10 +55 98 65 19 7 +96 76 20 28 88 +94 83 91 26 86 + +60 57 22 95 23 +81 4 34 36 14 +77 1 45 24 19 +33 88 8 28 74 + 2 17 37 32 94 + +34 82 45 65 44 +70 89 95 20 79 +88 18 62 68 37 +85 17 54 86 69 +97 25 13 42 67 + +70 30 59 94 86 +40 87 20 69 25 +46 44 41 17 79 +75 99 3 91 8 +71 39 73 88 37 + +90 76 12 80 58 +60 45 35 10 33 +79 19 65 54 21 +63 51 77 15 92 +34 53 7 59 44 + +40 14 68 43 37 +12 35 29 82 48 +47 28 97 44 93 +95 56 33 96 27 +38 85 88 49 6 + +88 36 81 42 10 +85 99 29 70 86 +64 15 37 96 61 +66 76 87 17 62 +91 16 60 13 65 + +45 71 66 80 69 +53 39 29 92 99 +23 0 72 36 52 +75 70 33 2 14 +22 77 21 26 3 + +52 32 14 66 47 +53 7 9 69 11 +19 36 57 54 65 +17 26 76 51 42 +13 8 44 63 39 + +23 84 34 35 19 +29 71 81 32 92 +22 49 54 6 56 +64 94 53 89 2 +74 68 11 13 47 + +34 25 67 59 66 +68 27 69 91 33 + 4 56 46 99 21 +51 13 24 41 12 +90 65 19 26 55 + +15 85 8 65 79 +95 51 39 75 96 +18 45 68 81 71 +67 28 21 61 20 +70 29 92 74 36 + +25 75 23 2 38 +66 52 42 62 16 +93 63 78 31 65 + 0 91 77 4 14 +61 59 53 17 10 + +16 95 72 67 17 +71 3 38 90 14 +34 8 55 49 33 +54 79 20 27 80 +96 31 18 70 61 + +60 46 4 56 49 + 2 36 8 51 54 +71 82 97 1 18 +45 69 37 6 26 +85 61 27 92 77 + +62 90 59 67 25 +41 45 7 91 17 +10 29 75 43 82 +12 78 95 37 32 +28 66 76 2 49 + +26 6 49 44 74 +94 34 73 70 64 +14 91 23 88 31 +90 55 62 75 43 + 4 1 63 57 19 + + 2 30 11 55 52 +51 92 73 54 96 +89 22 67 56 17 +49 50 9 95 45 +23 74 13 75 7 + + 6 31 78 64 89 +76 13 83 56 34 +95 29 97 49 37 +66 77 74 73 90 +87 41 62 39 85 + +51 80 38 15 44 +53 23 83 61 63 +27 33 79 40 32 +84 2 82 20 93 +72 92 48 39 98 + +36 78 46 84 14 +56 53 51 92 89 +39 99 77 22 32 +65 38 42 76 7 +62 31 1 87 95 + +74 99 6 4 20 +95 81 27 59 88 +63 69 30 25 87 +92 96 89 42 18 +11 77 91 8 46 + +29 62 77 3 89 +54 12 55 44 34 +66 78 83 98 22 +17 10 67 82 75 +43 16 84 41 19 + +67 24 9 89 48 +56 7 44 47 68 +12 38 35 54 14 +95 58 78 13 28 +97 5 37 99 42 + +48 64 21 23 92 +29 99 75 2 53 +41 97 74 39 89 +66 63 22 45 73 +20 68 30 35 78 + +76 3 47 40 72 +41 7 68 5 58 +12 32 81 62 93 +91 80 17 78 61 +22 95 94 38 33 + +42 27 70 13 5 +77 38 50 3 44 +29 56 36 15 97 +68 20 94 12 54 +64 83 25 55 80 + +77 63 37 68 73 +34 30 22 91 10 +16 80 89 98 45 +46 36 90 95 83 +54 52 57 61 55 + +55 3 33 66 69 +51 97 36 57 50 +56 74 35 84 44 +45 92 18 42 52 +85 13 27 70 20 + +56 68 71 11 63 +12 93 57 94 84 +91 13 29 31 75 +54 49 51 73 5 +81 7 60 53 89 + +73 55 87 35 84 +37 63 41 54 39 +58 42 85 66 68 +96 24 86 72 27 +40 28 4 80 33 + +29 79 8 76 31 +30 20 12 0 61 +14 37 49 45 74 +64 17 1 91 51 +87 67 3 77 47 + +72 15 46 71 75 +41 16 68 14 43 +97 25 78 26 39 +59 57 88 4 52 +20 49 3 23 29 + +33 78 31 35 6 +85 43 7 87 18 +68 93 4 80 96 +98 13 61 77 23 +10 29 34 36 5 + + 0 78 44 49 14 +72 88 30 31 81 +34 87 55 27 11 +58 64 76 40 62 +47 18 38 35 26 + +16 2 67 56 74 +50 41 86 38 39 +32 96 59 40 8 +17 82 49 55 89 +34 88 81 73 94 + +52 18 32 56 61 +40 5 48 64 62 +22 57 19 26 91 +31 3 95 27 87 +74 83 75 99 73 + + 6 65 91 22 86 +82 72 60 41 87 + 2 71 9 12 84 +51 90 43 49 80 +15 20 54 66 29 + +39 64 35 23 10 +73 25 1 45 93 +50 37 95 86 78 +52 6 2 0 13 +26 89 27 62 80 + +65 67 95 33 60 +55 49 64 92 7 +56 75 73 35 99 + 8 72 80 0 46 +41 25 2 69 4 + +26 51 31 44 25 +21 6 70 12 71 +67 69 13 63 79 +81 74 8 89 30 +16 48 88 72 66 + +99 69 61 29 86 +67 88 5 20 2 +70 60 27 82 6 +95 65 30 9 85 +23 58 59 87 66 + +40 90 43 57 26 +10 52 27 64 72 + 3 83 11 54 42 +39 20 87 15 81 +49 28 58 33 29 + +11 32 63 96 81 +77 82 0 30 15 +88 31 41 46 6 +17 55 76 42 87 +24 93 70 66 40 + +35 6 28 90 21 +72 74 78 43 3 +47 17 13 41 96 +68 12 76 81 11 +70 34 33 25 54 + +94 9 58 91 38 +84 7 22 30 63 +23 26 49 93 48 +79 75 99 96 67 +90 19 66 57 47 + +35 98 24 31 41 +79 63 92 70 11 +36 3 72 50 93 +90 21 40 38 77 + 0 14 42 99 67 + +96 45 75 97 94 +68 35 9 30 67 +25 88 40 46 37 +82 79 90 76 55 +50 59 58 22 21 + +96 73 49 36 56 + 6 45 30 81 76 +10 95 70 88 98 +43 47 74 66 84 +77 83 68 54 28 + +96 48 64 89 6 +76 12 47 8 30 +39 55 95 11 62 +68 25 50 63 31 +59 17 46 52 78 + +66 27 61 79 73 +37 88 47 84 72 +50 18 99 7 76 +97 11 53 43 30 +42 56 98 39 63 + +64 13 45 7 72 +66 35 18 68 86 +38 30 89 11 29 +37 76 23 14 67 +36 61 87 26 46 + +20 72 10 30 17 +25 14 74 71 58 +34 51 45 43 76 +38 75 50 98 42 + 2 12 67 66 82 + +44 23 73 56 88 + 4 96 90 0 32 +40 86 47 87 50 +28 30 42 39 17 +10 12 16 8 14 + +21 33 7 20 78 +81 46 77 42 79 +84 28 82 93 68 +90 63 60 0 34 +35 70 40 29 54 + +93 8 11 2 39 +74 40 95 69 57 +86 21 31 88 63 +52 16 19 20 22 +72 7 25 90 77 + +83 29 90 48 46 +97 21 2 65 15 +89 28 60 69 26 +77 75 9 35 96 +82 49 66 5 16 + +80 57 2 73 46 +22 50 87 60 89 +95 74 98 93 62 +86 61 10 69 9 +48 31 53 88 84 + +46 17 28 56 50 +64 65 43 73 22 +32 31 89 20 38 +13 49 18 55 72 +83 41 78 94 57 + +39 8 68 87 21 +78 59 27 0 14 +25 3 96 51 63 +92 35 19 57 99 +83 75 69 37 72 + +42 36 34 77 69 +21 55 47 52 89 +61 90 3 23 41 +45 80 29 27 99 +79 86 87 93 74 + +59 8 97 48 73 +40 31 29 49 85 +41 68 11 9 45 +87 74 77 75 91 +67 27 70 90 16 + +80 47 53 81 36 +75 35 87 90 89 +19 5 56 28 26 + 8 44 77 31 20 +61 96 27 99 79 + +35 16 40 94 65 +60 28 46 51 61 +45 53 36 89 80 +33 93 12 39 42 +13 68 57 64 26 + +39 55 88 78 72 + 6 82 52 1 60 +41 23 97 44 11 + 3 15 21 93 38 +24 90 7 80 2 + +81 46 31 56 30 +94 22 58 69 41 +42 91 20 0 14 +71 11 17 37 12 + 7 73 79 9 26 + +38 32 24 98 79 +48 49 4 17 90 +12 20 95 99 10 +94 23 30 92 97 +84 18 57 11 53 + +75 22 42 59 55 +23 33 90 2 52 +94 13 78 0 16 +39 72 67 45 31 +11 53 7 83 28 + +43 33 52 89 40 +53 94 87 90 19 +98 51 64 63 62 +66 65 57 93 18 +80 79 59 99 73 + +57 63 96 3 27 +88 74 9 60 99 +48 30 1 18 15 +23 77 89 24 55 +37 58 67 91 10 + +36 73 27 72 8 +75 74 87 55 7 + 2 67 34 84 51 +94 18 23 62 11 +65 41 3 29 53 + +63 67 73 53 13 +28 54 19 72 93 +48 41 55 64 33 +83 70 65 26 22 +11 86 35 16 18 + +13 50 19 48 58 +28 42 83 20 29 + 5 96 92 90 3 +87 93 56 23 78 +98 57 0 72 62 + +95 76 16 5 56 +55 28 52 88 73 + 6 99 75 90 18 +12 25 22 44 57 +62 37 36 30 48 + +24 41 73 90 46 +55 91 63 86 44 + 0 74 72 47 76 +34 13 33 65 62 +49 75 10 15 27 + +85 63 62 11 38 +53 29 2 8 13 +87 64 31 69 58 +88 84 17 3 26 + 5 32 23 33 39 + +25 8 81 29 95 +65 56 86 34 17 +38 66 85 43 26 +39 12 70 32 19 +49 68 10 4 13 \ No newline at end of file diff --git a/d4/part1.ts b/d4/part1.ts new file mode 100644 index 0000000..7130879 --- /dev/null +++ b/d4/part1.ts @@ -0,0 +1,30 @@ +import fs from 'fs' +import { Board, calculateBoardScore, hasBoardWon, parseBoard } from './utils' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + +const items = input.split('\n')[0].split(',').map((it) => parseInt(it)) + +const boards = input.split('\n\n').map((board, index) => { + if (index === 0) return undefined + return parseBoard(board) +}).filter((it) => it) as Array + +root: for (let i = 1; i <= items.length; i++) { + const subList = items.slice(0, i) + for (let j = 0; j < boards.length; j++) { + const board = boards[j]; + const won = hasBoardWon(board, subList) + if (won) { + console.log('Board', j, 'has won!') + const score = calculateBoardScore(board, subList) + console.log(board) + console.log('Score:', score) + console.log('items:', subList) + console.log('item:', subList[subList.length - 1]) + console.log('Result:', score * subList[subList.length - 1]) + break root + } + + } +} \ No newline at end of file diff --git a/d4/part2.ts b/d4/part2.ts new file mode 100644 index 0000000..5fc4408 --- /dev/null +++ b/d4/part2.ts @@ -0,0 +1,34 @@ +import fs from 'fs' +import { Board, calculateBoardScore, hasBoardWon, parseBoard } from './utils' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + +const items = input.split('\n')[0].split(',').map((it) => parseInt(it)) + +const boards = input.split('\n\n').map((board, index) => { + if (index === 0) return undefined + return parseBoard(board) +}).filter((it) => it) as Array + +root: for (let i = 1; i <= items.length; i++) { + const subList = items.slice(0, i) + for (let j = 0; j < boards.length; j++) { + const board = boards[j]; + const won = hasBoardWon(board, subList) + if (won) { + console.log('Board', j, 'has won, removing...') + boards.splice(j, 1) + j-- + if (boards.length === 0) { + const score = calculateBoardScore(board, subList) + console.log('Score:', score) + console.log('items:', subList) + console.log('item:', subList[subList.length - 1]) + console.log('Result:', score * subList[subList.length - 1]) + break root + } + continue + } + + } +} \ No newline at end of file diff --git a/d4/utils.ts b/d4/utils.ts new file mode 100644 index 0000000..352b6b1 --- /dev/null +++ b/d4/utils.ts @@ -0,0 +1,38 @@ +export type Board = Array> + +export function hasBoardWon(board: Board, values: Array) { + const victoryBoard: Board = board.map((line) => line.map((value) => values.includes(value))) + let colsHasFalse = Array.from(Array(victoryBoard.length)).map(() => false) + for (let lineIndex = 0; lineIndex < victoryBoard.length; lineIndex++) { + const line = victoryBoard[lineIndex]; + let hasFalse = false + for (let columnIndex = 0; columnIndex < line.length; columnIndex++) { + const item = line[columnIndex]; + if (!item) { + colsHasFalse[columnIndex] = true + hasFalse = true + } + } + + if (!hasFalse) { + return true + } + } + return colsHasFalse.includes(false) +} + +export function parseBoard(board: string): Board { + const lines = board.split('\n') + const res: Board = [] + for (let i = 0; i < lines.length; i++) { + const line = lines[i] + res[i] = line.split(/ ?/g).map((v) => parseInt(v)).filter((it) => !isNaN(it)) + } + return res +} + +export function calculateBoardScore(board: Board, subList: Array) { + return board.reduce((bp, bc) => { + return bp + bc.reduce((lp, lc) => subList.includes(lc) ? lp : lp + lc, 0) + }, 0) +} \ No newline at end of file diff --git a/d5/ex.txt b/d5/ex.txt new file mode 100644 index 0000000..1d4e36d --- /dev/null +++ b/d5/ex.txt @@ -0,0 +1,10 @@ +0,9 -> 5,9 +8,0 -> 0,8 +9,4 -> 3,4 +2,2 -> 2,1 +7,0 -> 7,4 +6,4 -> 2,0 +0,9 -> 2,9 +3,4 -> 1,4 +0,0 -> 8,8 +5,5 -> 8,2 \ No newline at end of file diff --git a/d5/input.txt b/d5/input.txt new file mode 100644 index 0000000..2455beb --- /dev/null +++ b/d5/input.txt @@ -0,0 +1,500 @@ +491,392 -> 34,392 +337,52 -> 485,52 +256,605 -> 256,959 +889,142 -> 153,878 +189,59 -> 512,382 +399,193 -> 598,193 +578,370 -> 795,153 +79,450 -> 569,450 +565,444 -> 270,149 +39,28 -> 39,846 +114,353 -> 114,383 +356,61 -> 356,327 +140,132 -> 515,132 +361,848 -> 361,527 +466,257 -> 466,784 +818,397 -> 818,14 +693,554 -> 693,984 +171,290 -> 171,655 +989,889 -> 170,70 +527,855 -> 527,549 +209,355 -> 486,355 +800,430 -> 291,939 +980,38 -> 31,987 +964,559 -> 964,799 +491,612 -> 930,173 +57,977 -> 958,76 +149,465 -> 349,465 +512,624 -> 629,507 +460,943 -> 460,441 +988,29 -> 988,968 +104,337 -> 441,337 +939,48 -> 939,546 +941,904 -> 498,461 +850,972 -> 649,771 +840,901 -> 23,84 +231,790 -> 231,873 +230,668 -> 840,58 +410,922 -> 435,897 +341,337 -> 341,406 +264,752 -> 258,752 +457,969 -> 457,757 +465,42 -> 465,350 +748,783 -> 502,783 +461,930 -> 461,142 +392,265 -> 215,265 +417,805 -> 417,231 +825,870 -> 60,105 +524,167 -> 703,346 +963,829 -> 308,174 +730,361 -> 730,252 +61,373 -> 61,593 +873,893 -> 132,152 +820,719 -> 417,719 +142,238 -> 212,168 +142,653 -> 676,119 +392,955 -> 392,453 +368,385 -> 414,385 +464,762 -> 592,762 +542,168 -> 542,789 +622,693 -> 166,237 +477,290 -> 792,290 +731,56 -> 731,677 +516,77 -> 326,77 +595,973 -> 779,973 +68,487 -> 128,487 +389,738 -> 762,738 +721,13 -> 827,119 +797,625 -> 347,625 +75,67 -> 75,458 +931,142 -> 219,854 +422,835 -> 980,835 +278,565 -> 753,565 +225,970 -> 806,389 +791,725 -> 691,725 +924,975 -> 18,69 +326,763 -> 969,120 +663,895 -> 663,559 +940,965 -> 142,167 +146,425 -> 791,425 +832,968 -> 272,408 +494,804 -> 694,804 +23,25 -> 900,902 +621,163 -> 894,163 +587,605 -> 587,716 +41,931 -> 383,589 +888,530 -> 341,530 +292,801 -> 292,567 +537,213 -> 245,213 +513,84 -> 527,84 +623,516 -> 623,128 +549,729 -> 509,729 +576,232 -> 869,232 +513,847 -> 433,847 +536,612 -> 434,612 +608,377 -> 33,952 +137,762 -> 424,475 +329,286 -> 584,541 +493,296 -> 493,316 +160,343 -> 189,343 +477,929 -> 976,430 +695,607 -> 557,607 +745,322 -> 28,322 +777,73 -> 76,774 +163,723 -> 163,816 +30,549 -> 63,516 +163,914 -> 898,179 +603,823 -> 603,78 +498,616 -> 886,228 +229,591 -> 341,591 +742,841 -> 343,841 +720,808 -> 934,808 +985,48 -> 48,985 +368,859 -> 178,859 +506,30 -> 144,30 +19,110 -> 19,750 +293,689 -> 293,294 +13,462 -> 980,462 +536,963 -> 346,773 +836,471 -> 462,471 +506,952 -> 489,952 +830,15 -> 461,15 +392,378 -> 237,378 +295,48 -> 295,825 +264,679 -> 264,602 +487,582 -> 487,116 +832,677 -> 788,677 +469,770 -> 211,512 +400,773 -> 394,773 +262,836 -> 262,454 +51,17 -> 969,935 +483,525 -> 838,880 +71,124 -> 164,31 +103,226 -> 912,226 +785,169 -> 785,454 +858,825 -> 176,143 +248,960 -> 427,781 +255,37 -> 767,37 +832,149 -> 506,149 +256,246 -> 86,246 +447,448 -> 765,448 +654,159 -> 654,158 +120,500 -> 120,341 +200,19 -> 839,658 +451,251 -> 763,563 +931,75 -> 931,312 +69,404 -> 311,646 +31,678 -> 31,231 +410,307 -> 410,236 +988,976 -> 387,375 +654,402 -> 738,486 +30,942 -> 942,30 +115,652 -> 98,669 +405,764 -> 375,734 +88,759 -> 125,759 +636,835 -> 722,835 +300,60 -> 126,60 +159,225 -> 159,319 +934,188 -> 934,74 +46,822 -> 708,160 +605,612 -> 605,463 +200,281 -> 536,617 +392,11 -> 79,324 +917,126 -> 258,785 +803,143 -> 803,180 +116,556 -> 651,556 +922,222 -> 468,676 +266,782 -> 896,782 +733,448 -> 764,448 +915,75 -> 305,685 +150,243 -> 842,243 +485,641 -> 963,641 +965,206 -> 965,275 +78,868 -> 748,198 +37,947 -> 859,947 +429,289 -> 429,48 +378,261 -> 378,624 +768,494 -> 768,782 +702,566 -> 113,566 +290,148 -> 913,771 +806,931 -> 849,931 +725,970 -> 299,970 +38,565 -> 740,565 +262,730 -> 973,730 +826,376 -> 826,97 +318,576 -> 318,227 +159,868 -> 448,868 +344,256 -> 344,615 +824,188 -> 588,424 +505,843 -> 897,843 +293,348 -> 293,488 +433,833 -> 165,565 +56,471 -> 169,471 +77,896 -> 914,59 +405,904 -> 405,174 +274,364 -> 274,88 +785,704 -> 538,704 +877,389 -> 681,389 +790,936 -> 327,936 +89,143 -> 755,809 +721,450 -> 721,406 +253,664 -> 811,664 +881,143 -> 97,927 +205,738 -> 645,738 +869,951 -> 282,364 +374,697 -> 374,592 +251,989 -> 251,977 +521,187 -> 885,187 +536,401 -> 536,38 +636,840 -> 636,873 +695,333 -> 52,976 +790,757 -> 790,358 +314,765 -> 882,765 +880,439 -> 127,439 +266,848 -> 810,304 +802,419 -> 802,936 +554,67 -> 554,956 +311,379 -> 685,753 +183,544 -> 305,544 +857,341 -> 407,791 +306,559 -> 727,980 +184,477 -> 509,152 +934,174 -> 934,154 +28,12 -> 28,968 +418,984 -> 112,678 +788,89 -> 837,89 +229,425 -> 192,462 +714,701 -> 424,411 +198,313 -> 156,355 +142,742 -> 215,742 +15,639 -> 15,787 +573,396 -> 462,396 +954,977 -> 76,99 +645,448 -> 652,448 +958,822 -> 376,240 +47,359 -> 212,194 +524,366 -> 524,916 +100,977 -> 501,576 +932,148 -> 115,965 +854,120 -> 421,553 +318,630 -> 318,964 +196,31 -> 874,709 +812,826 -> 812,679 +111,890 -> 897,104 +46,35 -> 972,35 +40,842 -> 40,835 +390,510 -> 98,510 +832,57 -> 124,765 +422,331 -> 422,44 +696,837 -> 696,555 +849,571 -> 849,679 +598,143 -> 598,261 +670,745 -> 670,757 +660,390 -> 660,912 +960,578 -> 960,253 +123,343 -> 123,28 +643,199 -> 969,199 +66,642 -> 669,39 +776,30 -> 776,173 +595,951 -> 84,951 +908,183 -> 724,367 +330,332 -> 330,455 +954,955 -> 188,955 +981,269 -> 90,269 +235,579 -> 513,579 +217,25 -> 217,990 +811,810 -> 811,405 +245,255 -> 367,255 +860,225 -> 860,100 +753,626 -> 697,626 +755,404 -> 836,404 +733,476 -> 336,476 +562,172 -> 964,172 +339,989 -> 749,989 +167,581 -> 167,611 +217,475 -> 217,747 +103,598 -> 431,270 +11,989 -> 989,11 +925,90 -> 46,969 +26,963 -> 935,54 +40,925 -> 40,816 +67,942 -> 984,25 +933,652 -> 933,242 +942,292 -> 942,138 +889,909 -> 180,200 +604,770 -> 237,770 +30,627 -> 973,627 +750,777 -> 750,645 +254,797 -> 254,169 +939,167 -> 347,759 +889,682 -> 394,682 +788,338 -> 388,338 +757,252 -> 169,252 +806,131 -> 699,131 +562,270 -> 562,481 +950,349 -> 459,840 +219,915 -> 932,202 +977,505 -> 977,708 +915,559 -> 915,125 +366,397 -> 366,717 +54,723 -> 433,723 +570,842 -> 236,508 +513,365 -> 513,80 +569,523 -> 569,266 +278,764 -> 278,178 +136,136 -> 84,84 +787,108 -> 787,809 +461,388 -> 855,782 +64,898 -> 848,114 +628,71 -> 178,521 +842,66 -> 842,699 +293,68 -> 742,68 +960,102 -> 358,704 +834,669 -> 27,669 +11,43 -> 374,406 +399,803 -> 340,803 +564,211 -> 20,755 +370,841 -> 370,321 +518,590 -> 518,255 +470,150 -> 470,850 +769,182 -> 234,717 +97,787 -> 97,382 +36,31 -> 982,977 +831,467 -> 471,827 +253,836 -> 547,836 +957,681 -> 957,919 +768,831 -> 768,275 +98,36 -> 955,893 +283,413 -> 840,413 +21,870 -> 20,870 +979,507 -> 979,37 +339,757 -> 210,757 +388,594 -> 801,594 +867,939 -> 91,163 +755,864 -> 755,501 +856,177 -> 736,57 +74,365 -> 376,63 +386,451 -> 815,22 +389,883 -> 679,593 +116,216 -> 157,175 +693,960 -> 693,454 +704,962 -> 306,962 +613,442 -> 867,442 +578,13 -> 578,855 +417,683 -> 118,683 +127,161 -> 742,161 +646,979 -> 646,270 +14,842 -> 14,802 +496,902 -> 506,912 +468,354 -> 468,875 +714,431 -> 714,172 +554,297 -> 554,790 +717,664 -> 883,664 +551,182 -> 980,611 +794,932 -> 499,637 +384,499 -> 507,499 +32,368 -> 257,368 +984,131 -> 904,131 +973,16 -> 10,979 +189,178 -> 189,752 +492,404 -> 492,593 +11,515 -> 117,515 +230,182 -> 230,954 +652,16 -> 663,16 +698,693 -> 490,693 +252,942 -> 587,942 +551,901 -> 428,778 +899,320 -> 903,316 +14,577 -> 313,278 +409,576 -> 409,475 +466,883 -> 819,883 +221,472 -> 609,472 +686,828 -> 686,720 +988,989 -> 13,14 +514,171 -> 227,171 +868,842 -> 632,842 +279,824 -> 697,406 +678,464 -> 678,687 +736,358 -> 736,259 +933,66 -> 24,975 +679,470 -> 679,689 +979,953 -> 45,19 +98,826 -> 737,187 +612,732 -> 612,681 +985,23 -> 23,985 +787,732 -> 332,277 +660,211 -> 660,61 +395,19 -> 246,19 +129,876 -> 955,50 +676,246 -> 821,246 +980,26 -> 18,988 +142,945 -> 142,218 +165,240 -> 540,240 +941,522 -> 941,129 +876,274 -> 876,340 +627,782 -> 905,782 +928,235 -> 246,235 +336,449 -> 92,205 +748,62 -> 748,787 +804,725 -> 356,277 +910,89 -> 19,980 +391,99 -> 155,335 +608,127 -> 516,219 +337,255 -> 337,649 +818,831 -> 818,859 +146,204 -> 301,359 +629,646 -> 906,923 +87,860 -> 824,123 +613,867 -> 613,946 +286,339 -> 286,626 +942,120 -> 595,467 +35,207 -> 187,207 +684,559 -> 283,158 +48,768 -> 48,349 +656,965 -> 656,27 +865,341 -> 865,576 +218,786 -> 152,786 +697,69 -> 583,69 +790,79 -> 552,79 +310,547 -> 846,11 +428,809 -> 428,940 +664,829 -> 664,455 +265,775 -> 749,775 +362,221 -> 309,168 +437,253 -> 437,597 +601,324 -> 245,680 +24,69 -> 24,476 +420,344 -> 420,525 +215,866 -> 635,866 +926,770 -> 315,770 +413,650 -> 413,624 +751,765 -> 475,489 +673,709 -> 39,75 +230,689 -> 805,689 +31,209 -> 789,967 +698,255 -> 909,255 +641,752 -> 866,527 +346,780 -> 391,825 +328,905 -> 328,130 +628,674 -> 628,354 +666,110 -> 98,678 +846,651 -> 846,371 +28,946 -> 28,482 +289,844 -> 458,675 +605,602 -> 605,297 +355,217 -> 239,217 +453,96 -> 195,354 +988,90 -> 145,933 +801,194 -> 801,109 +894,708 -> 894,212 +177,447 -> 607,877 +824,391 -> 788,391 +386,940 -> 471,855 +703,425 -> 583,425 +848,110 -> 36,922 +603,596 -> 685,678 +584,458 -> 584,482 +464,903 -> 343,903 +888,413 -> 405,413 +320,185 -> 103,185 +475,458 -> 55,878 +371,843 -> 371,466 +785,507 -> 785,570 +904,553 -> 904,983 +872,600 -> 872,848 +296,693 -> 751,238 +490,488 -> 322,488 +37,371 -> 185,223 +238,618 -> 238,883 +232,89 -> 123,89 +20,14 -> 961,955 +794,318 -> 914,318 +407,499 -> 246,338 +641,514 -> 227,514 +284,210 -> 562,488 +164,566 -> 498,900 +20,825 -> 150,955 +235,384 -> 537,686 +151,116 -> 979,944 +697,133 -> 59,771 +212,226 -> 38,226 +523,527 -> 523,497 +119,493 -> 352,726 +927,157 -> 154,930 +336,149 -> 581,394 +103,580 -> 354,580 +891,494 -> 532,853 +22,272 -> 538,788 +544,296 -> 519,271 +821,382 -> 821,155 +501,807 -> 501,202 +588,76 -> 708,76 +773,681 -> 184,681 +754,936 -> 86,268 +582,972 -> 40,972 +530,458 -> 530,329 +109,433 -> 649,433 +411,215 -> 411,311 +433,568 -> 433,585 +232,504 -> 799,504 +72,442 -> 38,442 \ No newline at end of file diff --git a/d5/part1.ts b/d5/part1.ts new file mode 100644 index 0000000..1d7c736 --- /dev/null +++ b/d5/part1.ts @@ -0,0 +1,52 @@ +import fs from 'fs' + +function parseLine(line: string): Array<`${number}:${number}`> { + const splitted = line.split(' -> ') + const xy1 = splitted[0].split(',').map((it) => parseInt(it)) + const xy2 = splitted[1].split(',').map((it) => parseInt(it)) + const xMin = Math.min(xy1[0], xy2[0]) + const xMax = Math.max(xy1[0], xy2[0]) + const yMin = Math.min(xy1[1], xy2[1]) + const yMax = Math.max(xy1[1], xy2[1]) + + if (xMin !== xMax && yMin !== yMax) { + return [] + } + + + // console.log(xy1, xy2) + // console.log(xMin, xMax, yMin, yMax) + + const res: Array<`${number}:${number}`> = [] + + for (let x = xMin; x <= xMax; x++) { + for (let y = yMin; y <= yMax; y++) { + res.push(`${x}:${y}`) + } + } + + return res +} + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split('\n') + +const cellCount: Record<`${number}:${number}`, number> = {} + +for (let i = 0; i < input.length; i++) { + const line = input[i]; + const vents = parseLine(line) + for (const vent of vents) { + if (!(vent in cellCount)) { + cellCount[vent] = 0 + } + cellCount[vent]++ + } +} + +console.log(cellCount) + +console.log( + "Result:", + Object.values(cellCount).reduce((p, it) => it >= 2 ? p+1 : p, 0) +) diff --git a/d5/part2.ts b/d5/part2.ts new file mode 100644 index 0000000..74b7e9a --- /dev/null +++ b/d5/part2.ts @@ -0,0 +1,67 @@ +import fs from 'fs' + +function parseLine(line: string): Array<`${number}:${number}`> { + const splitted = line.split(' -> ') + const xy1 = splitted[0].split(',').map((it) => parseInt(it)) + const xy2 = splitted[1].split(',').map((it) => parseInt(it)) + const xMin = Math.min(xy1[0], xy2[0]) + const xMax = Math.max(xy1[0], xy2[0]) + const yMin = Math.min(xy1[1], xy2[1]) + const yMax = Math.max(xy1[1], xy2[1]) + + + // console.log(xy1, xy2) + // console.log(xMin, xMax, yMin, yMax) + + const isDiagonal = xMin !== xMax && yMin !== yMax + const res: Array<`${number}:${number}`> = [] + + if (isDiagonal) { + const xChange = xy1[0] > xy2[0] ? -1 : 1 + const yChange = xy1[1] > xy2[1] ? -1 : 1 + let x = xy1[0] + let y = xy1[1] + for (let i = 0; i <= (xMax - xMin); i++) { + const tmp = `${x}:${y}` as `${number}:${number}` + // console.log(line, tmp) + res.push(tmp) + x += xChange + y += yChange + + } + } else { + for (let x = xMin; x <= xMax; x++) { + for (let y = yMin; y <= yMax; y++) { + const tmp = `${x}:${y}` as `${number}:${number}` + // console.log(line, tmp) + res.push(tmp) + } + } + } + + + return res +} + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split('\n') + +const cellCount: Record<`${number}:${number}`, number> = {} + +for (let i = 0; i < input.length; i++) { + const line = input[i]; + const vents = parseLine(line) + for (const vent of vents) { + if (!(vent in cellCount)) { + cellCount[vent] = 0 + } + cellCount[vent]++ + } +} + +console.log(cellCount) + +console.log( + "Result:", + Object.values(cellCount).reduce((p, it) => it >= 2 ? p+1 : p, 0) +) diff --git a/d6/ex.txt b/d6/ex.txt new file mode 100644 index 0000000..a7af2b1 --- /dev/null +++ b/d6/ex.txt @@ -0,0 +1 @@ +3,4,3,1,2 \ No newline at end of file diff --git a/d6/input.txt b/d6/input.txt new file mode 100644 index 0000000..ba3c3cc --- /dev/null +++ b/d6/input.txt @@ -0,0 +1 @@ +5,4,3,5,1,1,2,1,2,1,3,2,3,4,5,1,2,4,3,2,5,1,4,2,1,1,2,5,4,4,4,1,5,4,5,2,1,2,5,5,4,1,3,1,4,2,4,2,5,1,3,5,3,2,3,1,1,4,5,2,4,3,1,5,5,1,3,1,3,2,2,4,1,3,4,3,3,4,1,3,4,3,4,5,2,1,1,1,4,5,5,1,1,3,2,4,1,2,2,2,4,1,2,5,5,1,4,5,2,4,2,1,5,4,1,3,4,1,2,3,1,5,1,3,4,5,4,1,4,3,3,3,5,5,1,1,5,1,5,5,1,5,2,1,5,1,2,3,5,5,1,3,3,1,5,3,4,3,4,3,2,5,2,1,2,5,1,1,1,1,5,1,1,4,3,3,5,1,1,1,4,4,1,3,3,5,5,4,3,2,1,2,2,3,4,1,5,4,3,1,1,5,1,4,2,3,2,2,3,4,1,3,4,1,4,3,4,3,1,3,3,1,1,4,1,1,1,4,5,3,1,1,2,5,2,5,1,5,3,3,1,3,5,5,1,5,4,3,1,5,1,1,5,5,1,1,2,5,5,5,1,1,3,2,2,3,4,5,5,2,5,4,2,1,5,1,4,4,5,4,4,1,2,1,1,2,3,5,5,1,3,1,4,2,3,3,1,4,1,1 diff --git a/d6/part1.ts b/d6/part1.ts new file mode 100644 index 0000000..ef57020 --- /dev/null +++ b/d6/part1.ts @@ -0,0 +1,28 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split(',').map((it) => parseInt(it)) + +const numberOfDays = 80 +const LOG = false + +if (LOG) console.log("Initial state:", input) + +for (let i = 1; i <= numberOfDays; i++) { + const len = input.length + for (let j = 0; j < len; j++) { + if (input[j] === 0) { + input[j] = 6 + input.push(8) + } else { + input[j]-- + } + } + + if (LOG) console.log("After", i, "days:", input) + +} + +console.log( + "Result:", input.length +) diff --git a/d6/part2.ts b/d6/part2.ts new file mode 100644 index 0000000..b059c2e --- /dev/null +++ b/d6/part2.ts @@ -0,0 +1,43 @@ +import fs from 'fs' + +const input = fs.readFileSync(__dirname + '/input.txt').toString() + .split(',').map((it) => parseInt(it)) + +const numberOfDays = 256 +const LOG = false + + +const list: Record = {} + +for (const fishy of input) { + if (!(fishy in list)) { + list[fishy] = 0 + } + list[fishy]++ +} + +if (LOG) console.log("Initial state:", list, Object.values(list).reduce((p, c) => p + c, 0)) + +for (let i = 1; i <= numberOfDays; i++) { + let newBorns = 0 + for (let v = 0; v <= 8; v++) { + if (!(v in list)) { + list[v] = 0 + } + if (v === 0) { + newBorns = list[v] ?? 0 + } else { + list[v - 1] = list[v] + } + } + list[8] = newBorns + list[6] = newBorns + (list[6] ?? 0) + + + if (LOG) console.log("After", i, "days:", list, Object.values(list).reduce((p, c) => p + c, 0)) + +} + +console.log( + "Result:", Object.values(list).reduce((p, c) => p + c, 0) +) diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..92e71e0 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,261 @@ +{ + "name": "2021", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "ts-node": "^10.4.0", + "typescript": "^4.5.2" + }, + "devDependencies": { + "@types/node": "^16.11.11" + } + }, + "node_modules/@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", + "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", + "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", + "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", + "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" + }, + "node_modules/@types/node": { + "version": "16.11.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", + "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==" + }, + "node_modules/acorn": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz", + "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/ts-node": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz", + "integrity": "sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==", + "dependencies": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + } + }, + "dependencies": { + "@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" + }, + "@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "requires": { + "@cspotcode/source-map-consumer": "0.8.0" + } + }, + "@tsconfig/node10": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", + "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" + }, + "@tsconfig/node12": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", + "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==" + }, + "@tsconfig/node14": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", + "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + }, + "@tsconfig/node16": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", + "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" + }, + "@types/node": { + "version": "16.11.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", + "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==" + }, + "acorn": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.6.0.tgz", + "integrity": "sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw==" + }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "ts-node": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz", + "integrity": "sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==", + "requires": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + } + }, + "typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==" + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..81b499f --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "devDependencies": { + "@types/node": "^16.11.11" + }, + "dependencies": { + "ts-node": "^10.4.0", + "typescript": "^4.5.2" + } +}