diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b943dbc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} \ No newline at end of file diff --git a/day_1/input.txt b/day_1/input.txt new file mode 100644 index 0000000..6f7f9fe --- /dev/null +++ b/day_1/input.txt @@ -0,0 +1,1000 @@ +37033 48086 +80098 34930 +88073 69183 +54342 63061 +98409 87908 +81400 96222 +42062 53621 +55208 48086 +10847 20622 +53237 11766 +12609 19507 +31524 33054 +83455 96879 +53344 76641 +94982 66380 +69183 70224 +35580 12846 +87598 24335 +82193 11774 +69512 57198 +59322 57031 +68842 58244 +44042 39233 +16249 57139 +85264 31175 +10891 68793 +40085 98617 +91566 98409 +87478 49199 +39821 33343 +74610 62695 +68536 31524 +68470 52968 +49918 78866 +22935 44471 +76024 92757 +65243 98409 +93508 26529 +89938 19767 +74104 28327 +95395 51124 +57361 30769 +17053 38420 +89386 27077 +66052 49634 +31107 86173 +20356 70681 +32859 77448 +61081 68078 +66997 11420 +47491 52799 +52909 18865 +98231 14451 +78232 81629 +13844 65959 +42821 44935 +42441 17048 +43148 63037 +64953 17930 +94799 43046 +36346 50323 +62122 36926 +12807 35501 +62695 49155 +70681 87913 +44566 67881 +84508 75693 +53457 53621 +81188 75898 +18550 78193 +78314 72664 +28118 75012 +55363 82133 +55936 96958 +71769 62301 +64882 55809 +22070 52069 +80402 18865 +87887 59381 +19262 90572 +85007 46788 +36926 95926 +19398 39233 +38479 40232 +32794 85776 +82010 48505 +44551 59594 +52215 96042 +47295 62695 +23560 64868 +41516 29134 +78567 96879 +56100 44280 +37923 53621 +23366 20622 +88384 38143 +32427 93236 +28815 77641 +64098 70832 +63820 52069 +65685 41926 +77989 34282 +19213 73228 +90916 59042 +34392 59594 +53405 20622 +61530 85362 +67067 58244 +15915 52074 +84869 45493 +16808 52099 +83066 30481 +60279 34507 +18216 69308 +43386 89121 +48876 20622 +81226 81863 +13439 96879 +33538 20803 +57046 57031 +97890 31524 +49650 81758 +83353 53621 +97124 11654 +42320 55708 +15216 67981 +41159 54382 +23511 59594 +69428 62695 +75545 54382 +40455 50323 +14796 17517 +64841 54382 +45297 98409 +85055 15951 +54382 89121 +75123 48014 +77380 73118 +89593 29398 +65102 84571 +29684 50323 +78501 98409 +22658 48086 +69048 37242 +78675 43046 +42018 64394 +20090 98409 +73590 59594 +77407 70588 +54617 60692 +31801 30470 +94282 59594 +23846 84393 +80158 75833 +41973 18865 +10733 72754 +21476 89327 +53199 42757 +57875 22438 +80198 27009 +78998 36146 +46245 29134 +50181 37209 +65481 89603 +11531 16038 +33594 38324 +57846 75210 +92753 46215 +16725 78130 +67071 32249 +58481 81278 +79423 50340 +97039 64868 +87562 54382 +43046 90102 +39144 51352 +59594 15951 +84863 15951 +17517 18865 +49574 65630 +32557 63961 +46236 13439 +97729 58376 +71110 50323 +96590 53621 +94510 30481 +71029 34573 +86457 21887 +28954 17350 +35852 31524 +93863 39233 +47572 73683 +97380 18865 +30754 30481 +60704 89447 +92001 69183 +32801 66142 +81487 31524 +18073 52639 +35906 59208 +43812 17762 +98364 54382 +63099 93285 +23874 11420 +23929 15951 +63965 58244 +13509 50297 +67586 72452 +38100 76429 +57896 36516 +31621 59594 +68378 13399 +98229 89945 +37332 42762 +39317 13399 +29751 70681 +23350 49329 +94426 54530 +51125 98409 +13568 25793 +40634 93771 +76318 20622 +56797 62352 +77125 92452 +92723 78193 +52702 97941 +71042 48086 +75241 48086 +82106 86471 +43549 51785 +57031 93563 +45097 85133 +39233 38284 +44072 23577 +78219 48086 +10218 75355 +34441 52069 +27486 64929 +94555 15951 +36126 33020 +50417 20622 +97392 18353 +59162 90002 +43315 19287 +28705 67881 +29116 18865 +54164 39121 +41481 91282 +81138 85776 +85885 67495 +96203 95531 +11050 37542 +12902 95734 +23499 10033 +86109 18865 +13588 75493 +11234 42933 +58393 31524 +74806 69463 +81423 40663 +56077 58244 +55377 18865 +19426 52069 +46626 54382 +37701 33145 +57512 74160 +27195 70681 +14778 22306 +24054 25503 +23289 29807 +37933 36926 +61780 11400 +50323 83188 +33579 91321 +63956 13439 +99407 96879 +91416 76077 +88001 95578 +62066 33499 +24116 98790 +47745 19497 +64915 31524 +15961 93427 +68594 81210 +34351 59202 +40327 98303 +72705 67448 +12525 23334 +43151 82488 +35068 49777 +68599 69183 +94043 78193 +13678 98199 +81582 69183 +73934 36346 +55739 43046 +85642 75087 +91889 62893 +67778 92891 +35695 73450 +55718 78193 +63959 34907 +38017 98409 +66723 17517 +74248 43974 +88967 64011 +83130 20258 +99204 59594 +70476 66058 +61286 50220 +48510 31524 +79991 38603 +19872 59594 +87662 98303 +19340 52069 +43964 15951 +90112 80030 +43191 15951 +98554 72878 +21344 54382 +19604 98409 +33237 10812 +51468 40519 +38791 85794 +74239 29333 +66680 95424 +24080 97635 +90972 18626 +87429 97643 +91221 28641 +72127 62326 +24113 72380 +81008 23132 +99596 15951 +33037 17517 +90429 94990 +95722 78709 +44529 11954 +40869 74940 +85270 98409 +61916 88339 +94503 31524 +57636 10919 +34500 53621 +67881 27216 +93866 48086 +95505 41472 +60258 13439 +73971 96879 +78155 84381 +52246 30293 +42752 11420 +91033 69183 +91316 64187 +99667 30481 +26343 66657 +47584 85776 +88747 93445 +48170 29134 +82355 98303 +72601 67372 +59362 16525 +23719 70681 +73439 89676 +41361 45165 +91378 13419 +23936 33954 +98014 13399 +15650 65042 +64527 77524 +57963 13032 +24657 39982 +71342 37777 +48315 75222 +54519 66142 +76974 53621 +85608 27055 +20837 93663 +54927 24425 +13139 20622 +15005 11420 +84490 76060 +89171 70473 +17832 96879 +18470 54382 +45260 83667 +17276 27108 +52681 32349 +61355 13439 +47525 11420 +36905 70681 +59209 75250 +95591 47770 +14642 68650 +40203 73611 +52858 61463 +48675 42759 +98405 64868 +80951 82870 +53621 79358 +25327 78193 +87475 48086 +51819 24117 +27015 17111 +98465 66142 +72427 73936 +71733 96879 +89121 60064 +22901 30122 +10856 48527 +36754 64868 +50122 50538 +52355 73026 +40825 40951 +80386 16069 +83603 36182 +58594 13717 +31497 71550 +40053 48086 +38188 39233 +18994 96329 +79861 50323 +23321 85776 +61404 10062 +95531 53621 +34909 98952 +23995 93754 +13871 98442 +54796 30148 +35319 93955 +64282 26287 +83133 82959 +56071 47244 +67009 47394 +92507 47341 +85776 46164 +30709 57965 +59236 35175 +20724 66427 +33428 94891 +11751 44280 +36923 59594 +76810 42646 +35667 96679 +42268 98409 +57684 38466 +40804 66142 +76968 66990 +99714 52069 +57148 28084 +16707 54930 +16915 32950 +18508 45796 +84647 62099 +24717 15951 +97165 52069 +88312 54080 +44527 62695 +13285 75521 +15532 45721 +83771 98303 +69300 69450 +33929 98294 +63656 85776 +58244 89121 +98243 65914 +79896 43809 +61035 98303 +66387 66433 +35297 91503 +60092 18889 +93026 91504 +73054 33258 +64475 70681 +54041 12197 +23521 20243 +91854 58244 +95611 62695 +70144 14591 +46105 93466 +13551 22559 +98318 32023 +72900 96879 +17675 99283 +21850 56050 +50581 44825 +49017 89297 +26268 73032 +76642 24749 +57925 72795 +63723 27403 +32025 20622 +15951 48086 +85672 58244 +24553 57031 +49464 62695 +67767 85776 +58337 85776 +74953 59594 +69307 20622 +54291 39233 +52996 15951 +65777 98303 +66534 75432 +23911 73020 +35599 53621 +80629 79286 +59328 98303 +88093 18865 +25517 18865 +19457 58244 +12955 55118 +90990 19917 +45463 45747 +77714 64511 +56882 42004 +25038 31524 +85217 20622 +99959 36346 +79460 26413 +86151 41237 +48086 30398 +31177 36926 +15315 83228 +73930 58503 +31633 37808 +25732 52462 +72722 22108 +21950 54382 +32065 92741 +45641 26363 +97024 96879 +44240 57089 +59276 20622 +42165 57163 +72746 70681 +70771 36926 +38232 78721 +71104 91763 +93422 84268 +82725 93116 +38739 25006 +93983 67881 +66261 37918 +45318 60554 +29927 61543 +75323 14960 +76535 13439 +95437 57747 +70363 58272 +79957 15661 +67064 32990 +20092 96879 +12567 69183 +52045 86433 +56000 76650 +72348 62567 +68077 58244 +51346 64868 +90427 68815 +55238 84016 +63141 23115 +44187 48086 +73242 46883 +37067 74850 +22831 78193 +33348 54605 +36004 75163 +69742 62695 +97982 85776 +81147 69183 +30121 44534 +89460 70312 +65414 48502 +41797 70681 +97715 59594 +11895 62739 +53566 36346 +88592 13685 +44867 18865 +38494 93238 +90302 57031 +29959 77575 +14477 64868 +95081 94031 +80618 98409 +31630 59639 +11480 15771 +57197 12243 +69484 97473 +15324 54382 +85375 28233 +70310 39233 +29134 66142 +17677 70681 +10533 50323 +32670 13399 +65046 89121 +27250 57826 +50565 18865 +10750 15951 +86359 36926 +17412 20622 +56284 58734 +24630 32786 +51890 31524 +62891 15178 +90991 54171 +18599 35575 +18865 35025 +26344 13399 +18002 85776 +61277 96879 +37141 57031 +86471 75319 +55111 37439 +41036 72230 +57319 96257 +44621 10761 +63452 89121 +64428 44023 +94409 64868 +97533 68365 +44422 53621 +82027 13439 +12954 54919 +47142 25744 +85528 66521 +81778 62695 +67727 32777 +66391 39630 +24686 62695 +81899 59594 +23924 99354 +28401 50030 +25839 98409 +80138 30520 +54999 14824 +93520 54172 +75113 64190 +60779 18923 +10355 41820 +32709 20332 +54938 70681 +49081 57031 +59825 82761 +38481 66142 +17642 85776 +93320 64868 +86185 89121 +90785 20622 +78441 70270 +15058 58554 +13159 99885 +71048 82807 +18657 62823 +25375 54382 +86493 57461 +68185 49281 +36666 48086 +57255 76149 +69221 70681 +13455 45466 +44124 44225 +12571 79912 +22123 18865 +41374 19055 +14066 88458 +42576 53164 +54786 71358 +48734 32761 +72366 76013 +38118 52069 +28516 98303 +84839 92356 +33967 51873 +39686 42909 +97775 58244 +97891 20622 +95436 31524 +40160 26365 +45663 83105 +73959 62695 +83007 21673 +34716 18865 +42940 60190 +30448 98303 +54016 56062 +98158 11420 +76233 67511 +71248 14271 +33181 52757 +73295 59594 +42588 69183 +28020 18683 +65760 13399 +51626 35859 +23978 66142 +26564 53338 +34634 15951 +47149 30575 +28625 20989 +78780 85370 +98473 26689 +66142 58244 +37914 48086 +91597 96879 +42550 89165 +79970 74953 +73019 69183 +21908 27351 +96153 79995 +58843 53621 +91807 12526 +92395 71081 +21579 48086 +79524 98282 +34060 85776 +27571 41575 +62300 37578 +88423 72261 +66840 95531 +39956 44045 +77892 67881 +10204 80385 +55417 42304 +34672 18865 +40908 48086 +97799 20148 +25065 53621 +62503 98409 +96437 67881 +74378 31222 +61972 70681 +89255 70681 +80855 18865 +54885 38371 +64050 15556 +21358 10464 +25723 92679 +95201 53621 +61421 49146 +86050 89893 +93226 78113 +42266 75153 +11881 17646 +69987 30481 +71028 85327 +24743 32122 +48190 85312 +45256 64868 +19567 11420 +89596 50323 +49101 86202 +68965 39233 +50874 13439 +17159 24728 +50369 35203 +78343 56136 +55351 73651 +48074 59594 +11532 42633 +82644 92794 +95771 34677 +59150 28294 +38484 64868 +48890 64382 +68966 28298 +51394 66142 +69899 91877 +20622 27299 +47091 19931 +81236 72834 +78009 41686 +48131 52069 +34760 83087 +54872 88748 +99903 44280 +75164 77528 +98303 81353 +89179 47262 +93330 85776 +64653 62695 +75680 59594 +28615 46658 +24345 58244 +79606 36346 +48948 97944 +98505 89997 +56392 90073 +76055 90144 +82417 29331 +62098 20173 +17254 59594 +48731 89213 +91622 10612 +96177 62695 +52069 59594 +13399 98409 +32967 62695 +80796 97619 +77193 28072 +55904 13399 +84250 81410 +53217 64868 +10500 80320 +67277 53621 +72249 93147 +65047 54902 +17107 63592 +76194 12779 +27559 83996 +79679 50585 +61580 69975 +65266 31524 +88473 84465 +79876 62695 +65441 16454 +80352 69183 +82496 39233 +52114 67176 +51220 91015 +50000 53335 +42335 68722 +53404 43046 +99871 66142 +32080 89121 +31786 17440 +92788 21713 +56249 44735 +61367 48207 +62686 18865 +96072 82701 +20243 17083 +12117 35213 +19815 26817 +79102 94396 +44142 48396 +69916 20622 +55931 67881 +31342 63716 +39653 62400 +77941 81859 +11114 80231 +52176 70681 +57866 95927 +16866 98409 +58810 52495 +30481 13399 +47222 62695 +44280 37037 +14384 62695 +87330 99383 +36889 98303 +87970 58244 +53739 41685 +40509 84262 +87526 11810 +34019 89121 +66761 29134 +82984 80221 +83300 43046 +31073 13399 +38528 10345 +42647 69040 +78499 66142 +65835 13399 +11888 52069 +16021 52069 +77506 18865 +37718 48194 +30087 28445 +11104 52070 +16603 52069 +32201 52069 +80129 87617 +30931 20174 +55331 36346 +88876 58551 +78652 57031 +81997 26780 +44346 20622 +31652 15430 +97390 65924 +84105 42911 +51646 52069 +73632 39233 +22774 58432 +67720 10485 +94677 22142 +15291 23118 +97553 91441 +13036 16132 +66370 89121 +47010 64499 +14579 36926 +71383 38714 +36373 44545 +80180 48086 +30591 52069 +90029 94693 +99057 45433 +96879 59594 +30934 96879 +40909 64001 +83174 44065 +99020 88105 +11420 41090 +52834 64349 +29417 40615 +23216 84918 +61489 62695 +69615 63436 +64767 37178 +28368 31524 +29166 83509 +88181 26952 +92376 46034 +56924 13399 +16465 18865 +29356 68035 +54993 36926 +18295 67097 +82237 43901 +78347 15951 +31212 15951 +36998 54208 +72196 14327 +10596 59594 +40421 66142 +10375 71778 +53059 29196 +33476 68714 +88721 27093 +82358 83161 +45486 51031 +61135 70681 +25501 16321 +12221 62619 +98976 89121 +83483 36480 +24673 41710 +36211 39233 +65135 61232 +64780 43227 +80301 70681 +45462 68721 +67491 81035 +79555 81549 +58586 95531 +52960 12428 +49575 44280 +65496 13439 +66682 98303 +93266 13399 +30310 69183 +21871 50286 +53042 52803 +22862 21603 +78193 85776 +87258 87131 +76615 84237 +88433 86471 +11880 74358 +27516 54382 +90874 52601 +95239 98303 +35641 18223 +93150 13439 +23926 14395 +68954 80564 +67708 28415 +54348 11420 +32006 70313 +89793 59594 +47625 20243 +42304 15951 +48069 91705 +44492 92921 +18981 42304 +13501 71398 +64868 18580 +38280 87499 +40480 96879 +76161 87470 +53440 26034 +99706 54382 +22102 95972 +23433 56267 +70986 83482 +49356 98303 +25792 48432 +87046 20622 +44220 54382 +19076 22755 +66811 96311 +90099 15951 +33595 70999 +19173 20622 +12964 56430 \ No newline at end of file diff --git a/day_1/solve_1.ts b/day_1/solve_1.ts new file mode 100644 index 0000000..28309c4 --- /dev/null +++ b/day_1/solve_1.ts @@ -0,0 +1,24 @@ +let txt = await Deno.readTextFile("input.txt"); +txt = txt.trim(); +const lst = txt.split("\r\n").map((x) => + x.split(" ") + .filter((x) => x.length > 0)) + .map(x => { + console.log(x); + return x; + }) + .map((x) => [parseInt(x[0]), parseInt(x[1])]); + +const left = lst.map((x) => x[0]); +const right = lst.map((x) => x[1]); + +// Part 1 + +const sl = left.toSorted(); +const sr = right.toSorted(); + +console.log(sr.filter(x => isNaN(x))); + +const sum = sl.map((x, i) => Math.abs(x - sr[i])).reduce((a, b) => a + b, 0); + +console.log(sum); \ No newline at end of file diff --git a/day_1/solve_2.ts b/day_1/solve_2.ts new file mode 100644 index 0000000..b9382e9 --- /dev/null +++ b/day_1/solve_2.ts @@ -0,0 +1,67 @@ +let txt = await Deno.readTextFile("input.txt"); +txt = txt.trim(); +const lst = txt.split("\r\n").map((x) => + x.split(" ") + .filter((x) => x.length > 0)) + .map(x => { + console.log(x); + return x; + }) + .map((x) => [parseInt(x[0]), parseInt(x[1])]); + +const left = lst.map((x) => x[0]); +const right = lst.map((x) => x[1]); + +// Part 2 + +//Counter class +class Counter { + private _data: Map = new Map(); + private _total: number = 0; + + constructor(data: number[]) { + data.forEach(x => { + this.set(x); + }); + } + + get total(): number { + return this._total; + } + + get count(): Map { + return this._data; + } + + get(key: number): number { + return this._data.get(key) ?? 0; + } + + set(key: number): void { + this._total++; + const count = this._data.get(key) ?? 0; + this._data.set(key, count + 1); + } +} + +/** + * get the similarity score between two arrays + * + * @param a + * @param b + */ +function calcSimilarityScore(a: number[], b: number[]): number { + const counterA = new Counter(a); + const counterB = new Counter(b); + + let score = 0; + counterA.count.forEach((v, k) => { + const bv = counterB.get(k); + score += bv * v * k; + }); + + return score; +} + +const score = calcSimilarityScore(left, right); +console.log(score); \ No newline at end of file diff --git a/day_2/input.txt b/day_2/input.txt new file mode 100644 index 0000000..d45bc25 --- /dev/null +++ b/day_2/input.txt @@ -0,0 +1,1000 @@ +67 69 71 72 75 78 76 +4 6 7 9 11 12 12 +20 22 25 27 28 29 33 +35 37 39 42 43 46 48 53 +46 49 48 51 53 +31 33 31 34 31 +83 86 85 88 89 91 91 +74 75 78 81 80 83 86 90 +72 73 72 74 75 80 +19 21 22 25 25 28 +4 6 6 7 10 9 +49 51 52 55 55 58 58 +40 41 43 44 44 48 +53 56 56 57 62 +26 29 33 34 36 38 +35 38 41 45 44 +28 31 33 35 39 39 +75 77 81 82 86 +85 86 88 89 93 98 +78 80 85 88 90 +36 39 42 43 44 47 53 50 +74 77 80 85 86 87 90 90 +51 53 54 57 59 64 68 +15 17 23 25 32 +46 45 47 49 51 +25 23 26 27 30 27 +51 50 51 52 53 53 +51 50 52 55 56 59 63 +40 38 40 42 43 48 +23 21 22 19 22 25 +22 20 22 25 24 27 30 28 +95 92 94 95 93 93 +78 75 77 76 80 +31 30 31 33 31 32 37 +12 10 12 15 15 18 +67 66 68 68 67 +67 64 64 66 66 +71 70 72 72 74 75 78 82 +15 14 14 16 19 20 25 +50 47 48 50 52 56 58 59 +5 4 5 8 12 15 14 +37 34 36 40 42 45 45 +5 2 4 5 9 10 11 15 +11 8 12 13 15 20 +25 22 25 32 34 37 38 41 +6 4 7 10 16 13 +95 92 97 99 99 +17 16 23 24 28 +78 75 80 81 86 +11 11 14 16 17 +40 40 43 45 48 50 47 +37 37 40 41 42 43 46 46 +90 90 92 94 98 +35 35 36 38 43 +74 74 77 76 79 82 84 87 +23 23 25 27 26 23 +94 94 95 98 95 96 97 97 +70 70 68 70 74 +2 2 1 2 8 +46 46 48 48 51 +69 69 72 74 77 79 79 77 +49 49 52 54 57 57 57 +28 28 29 29 33 +51 51 53 56 56 59 61 67 +27 27 29 33 36 39 42 +29 29 30 34 37 38 41 39 +34 34 35 36 40 42 42 +22 22 26 28 32 +7 7 10 14 20 +35 35 38 39 46 48 +23 23 24 26 29 36 35 +27 27 29 35 35 +61 61 66 69 70 74 +26 26 32 34 36 43 +41 45 46 48 49 51 +5 9 11 13 14 16 17 15 +72 76 79 81 83 86 87 87 +64 68 69 72 75 76 79 83 +27 31 33 36 37 40 46 +85 89 92 93 94 91 92 +65 69 66 67 68 70 72 71 +84 88 91 94 93 93 +78 82 79 82 83 84 86 90 +15 19 20 19 24 +41 45 48 50 53 53 56 59 +27 31 32 32 31 +84 88 88 90 90 +8 12 12 13 17 +84 88 89 89 95 +58 62 64 68 69 71 +1 5 9 12 15 14 +57 61 62 65 68 69 73 73 +1 5 9 10 14 +46 50 53 57 63 +63 67 68 69 74 75 77 +55 59 66 68 70 68 +6 10 11 17 17 +76 80 82 88 89 90 94 +73 77 82 85 90 +12 18 19 22 24 +47 54 55 58 60 62 59 +4 9 11 14 14 +64 70 71 72 73 77 +80 86 88 90 95 +61 68 71 68 71 74 76 +79 85 87 84 85 88 86 +51 56 57 55 58 58 +37 42 41 44 45 48 50 54 +74 79 76 78 80 82 88 +61 66 66 67 70 +37 43 46 49 49 48 +77 82 85 86 88 91 91 91 +26 33 33 35 36 37 39 43 +42 49 49 52 58 +39 44 47 50 52 56 58 +36 41 43 44 47 48 52 51 +42 49 50 54 54 +63 70 73 75 77 81 85 +74 80 84 87 93 +75 80 83 86 93 94 +4 10 13 14 19 21 20 +65 72 75 80 83 86 89 89 +64 70 73 74 80 81 82 86 +20 25 30 33 38 +57 56 54 51 48 49 +88 87 86 83 83 +55 52 49 48 45 42 40 36 +59 56 54 53 50 49 44 +28 26 25 22 21 20 21 19 +10 9 7 5 7 10 +44 42 40 43 43 +50 47 50 48 47 44 43 39 +79 76 78 77 74 69 +32 29 29 27 25 +30 29 26 23 20 20 22 +61 58 58 56 55 54 51 51 +80 77 76 76 72 +56 54 51 51 44 +64 61 58 56 55 51 50 47 +28 26 25 21 20 18 16 19 +94 93 91 89 86 82 82 +76 74 73 70 69 65 64 60 +76 75 71 70 63 +66 63 62 57 56 +55 53 50 44 47 +53 52 49 46 44 42 37 37 +66 64 63 57 53 +41 39 37 36 33 28 26 21 +21 24 21 19 17 14 +67 70 68 65 64 62 61 62 +52 53 52 49 49 +85 86 85 84 83 81 77 +30 32 29 27 25 20 +77 80 81 80 77 76 +96 99 98 95 92 94 96 +87 88 91 90 90 +63 65 64 63 66 65 61 +76 78 77 75 76 70 +50 51 48 48 47 46 45 44 +73 76 75 75 78 +56 57 56 56 55 54 52 52 +53 56 54 54 51 49 47 43 +64 67 67 66 60 +56 58 55 53 52 48 45 +44 45 44 41 37 40 +15 17 16 12 12 +58 60 58 57 54 50 47 43 +52 55 51 48 41 +83 86 81 78 77 75 +46 47 45 44 43 37 40 +59 60 53 51 50 48 48 +23 26 25 24 23 17 13 +54 55 48 46 45 43 41 34 +14 14 11 10 7 5 +80 80 78 75 74 72 69 71 +63 63 62 60 58 58 +65 65 64 63 59 +98 98 95 94 92 89 87 81 +97 97 98 97 96 +95 95 97 96 97 +45 45 44 42 40 38 41 41 +6 6 7 5 1 +22 22 23 22 17 +47 47 46 44 44 43 +23 23 21 21 20 19 21 +30 30 27 27 24 24 +82 82 82 81 77 +51 51 49 49 48 46 41 +16 16 13 9 7 5 4 1 +82 82 78 77 75 73 76 +89 89 87 83 80 80 +64 64 61 57 55 51 +59 59 55 54 52 50 44 +36 36 30 28 25 +33 33 30 29 23 20 23 +13 13 7 6 6 +51 51 48 47 41 39 35 +92 92 86 84 82 81 78 72 +97 93 92 89 88 85 83 +58 54 52 50 49 47 49 +42 38 36 34 31 31 +86 82 80 79 76 75 71 +92 88 87 86 84 77 +55 51 48 47 45 48 46 45 +40 36 37 35 36 +20 16 15 12 15 12 12 +51 47 48 45 42 38 +83 79 77 78 76 75 69 +27 23 21 18 15 15 13 11 +80 76 74 71 70 70 73 +78 74 72 72 71 69 68 68 +29 25 24 24 21 17 +67 63 61 61 55 +98 94 90 87 85 83 82 +98 94 90 87 86 87 +44 40 36 33 33 +96 92 90 86 82 +49 45 42 38 31 +70 66 65 58 56 53 +49 45 42 41 39 32 33 +37 33 32 27 26 25 25 +34 30 29 27 25 24 18 14 +26 22 19 18 13 12 5 +59 53 51 49 46 43 +28 21 18 16 14 11 9 12 +21 16 15 12 11 11 +28 22 21 20 17 14 10 +49 43 40 37 31 +14 7 6 8 5 2 1 +42 36 34 32 35 37 +49 42 41 43 40 39 38 38 +61 54 57 54 53 50 47 43 +97 90 92 91 89 86 85 79 +36 29 27 25 25 24 21 +28 23 23 20 18 16 17 +33 27 26 26 23 20 20 +90 83 83 80 76 +34 28 28 25 22 17 +61 54 50 47 46 44 43 42 +22 16 13 10 7 3 5 +73 68 64 63 63 +44 37 36 32 30 29 25 +85 79 78 75 71 65 +64 57 52 51 50 +54 47 42 39 40 +88 82 80 77 71 71 +61 55 54 49 45 +94 89 88 82 76 +43 40 37 34 31 28 27 30 +21 25 28 32 34 35 33 +54 57 59 58 57 55 +27 31 33 35 39 +10 14 16 16 17 18 22 +66 69 70 69 72 74 +21 27 29 31 34 41 45 +44 45 51 53 56 59 60 64 +73 74 71 65 62 61 62 +54 51 49 46 42 39 34 +81 83 82 75 72 70 66 +58 57 60 63 63 65 63 +72 71 68 64 64 +89 83 77 74 74 +42 45 48 52 51 +16 16 18 18 22 +62 69 72 75 76 76 77 80 +10 10 13 13 18 +53 59 62 64 64 65 67 71 +73 70 68 66 67 65 61 +95 92 89 87 85 80 79 78 +2 2 3 9 9 +77 76 71 70 66 +46 42 41 41 39 36 32 +57 58 57 53 50 50 +82 78 77 75 73 67 68 +71 69 73 76 77 75 +58 64 65 67 66 68 71 +95 91 88 86 82 83 +38 38 35 32 32 +39 42 45 48 50 54 56 61 +82 88 91 92 90 +51 47 45 42 41 39 37 38 +86 88 88 86 84 83 83 +62 62 58 56 54 54 +65 58 55 54 53 49 +90 86 85 82 79 +34 37 35 33 32 31 24 24 +93 89 86 89 91 +29 36 37 44 47 44 +32 35 33 32 29 26 25 22 +47 43 42 38 38 +80 82 83 82 82 +8 8 9 10 11 14 16 18 +16 14 17 19 20 21 28 25 +27 30 29 26 22 +65 64 61 60 57 53 51 +13 20 22 26 26 +47 42 41 39 37 35 33 33 +45 47 53 54 55 60 +66 62 60 58 55 56 54 50 +63 67 69 73 75 78 79 79 +4 6 7 10 12 9 10 14 +32 27 24 20 17 15 10 +39 39 38 36 35 37 33 +63 65 67 64 67 +24 24 22 23 22 +13 20 21 22 26 +27 27 24 22 21 21 18 20 +26 29 31 32 34 33 +76 76 75 74 71 68 64 62 +10 10 12 10 9 10 +47 40 37 36 34 37 +48 48 46 45 42 42 37 +58 58 57 51 48 42 +23 19 17 14 7 4 +64 57 55 50 47 46 49 +59 62 60 57 55 52 50 52 +55 50 50 47 45 39 +69 65 63 65 64 63 62 +55 56 54 50 48 47 50 +20 20 15 12 10 9 +38 37 37 40 41 44 46 46 +65 68 70 67 68 68 +5 7 13 16 19 +72 71 76 79 85 +86 81 78 75 73 76 73 67 +80 74 73 70 72 73 +71 67 60 59 58 55 52 52 +56 60 62 61 64 66 67 71 +79 74 71 67 65 64 +41 37 33 32 25 +96 90 88 86 80 78 76 72 +47 44 46 49 48 50 53 +12 19 23 24 27 28 +95 97 95 92 89 83 +47 44 46 49 50 57 58 58 +63 67 70 70 68 +34 30 27 26 19 +19 23 28 31 29 +46 53 54 58 61 66 +14 17 14 11 11 7 +77 77 75 74 73 71 68 +61 61 63 67 72 +59 55 53 50 47 45 45 +93 91 92 89 88 +55 48 46 47 45 43 40 40 +52 46 45 42 38 34 +76 73 72 69 65 63 64 +45 45 43 41 42 +69 69 66 63 59 56 52 +34 40 41 44 47 50 50 +42 42 45 52 55 57 64 +64 68 70 73 79 +66 60 59 56 53 53 50 46 +51 50 52 54 56 57 61 +52 59 62 62 63 66 64 +84 84 85 88 91 94 97 97 +57 57 60 59 58 58 +25 22 19 20 21 22 26 +67 65 63 61 58 57 56 50 +61 61 62 66 68 71 +86 79 77 75 76 73 69 +2 3 6 6 8 10 7 +17 22 24 27 32 +17 17 10 9 6 5 7 +73 69 72 71 65 +21 17 15 13 15 12 11 11 +28 31 34 38 42 +57 57 56 53 50 48 48 44 +71 69 70 71 72 73 74 81 +2 6 6 7 9 +7 11 12 15 16 16 18 18 +24 20 19 18 16 11 9 5 +85 81 79 77 75 73 69 +23 24 27 29 30 32 32 32 +36 29 26 26 24 21 +6 5 8 11 12 12 15 17 +14 9 7 6 6 6 +28 25 22 22 21 +74 75 73 71 73 71 67 +46 50 51 56 58 61 62 64 +16 23 25 29 32 34 35 39 +37 37 43 45 42 +26 26 32 34 38 +11 11 13 14 15 18 18 19 +75 77 74 70 67 63 +68 74 71 73 76 79 82 87 +69 69 71 70 67 61 +77 80 81 81 85 +36 39 36 33 33 32 29 30 +18 20 23 23 25 26 +80 86 88 85 89 +22 21 18 16 13 13 +64 64 63 61 56 +25 23 24 24 27 33 +16 16 17 19 18 19 +62 58 58 57 55 54 +20 25 27 32 32 +38 33 32 31 28 26 20 +77 76 75 73 70 63 63 +44 49 50 56 57 58 60 +48 53 56 58 60 60 63 63 +65 60 59 58 58 57 59 +35 36 38 39 42 49 +17 13 11 11 8 8 +67 71 75 78 84 +81 81 82 85 87 90 91 95 +69 69 72 74 77 80 86 +59 58 57 57 59 +57 60 61 64 67 66 71 +59 58 61 64 65 67 64 +51 51 53 56 53 53 +24 26 27 31 33 34 +26 27 30 32 35 35 +82 85 83 82 79 76 76 69 +60 56 54 52 51 45 42 35 +20 13 14 11 10 +73 71 68 67 64 61 57 +28 29 28 24 18 +54 47 45 39 38 35 +41 43 46 50 53 53 +32 36 38 44 47 54 +17 16 16 15 11 +50 51 48 48 46 +54 52 53 51 56 +21 25 27 30 32 30 36 +79 77 79 80 80 84 +18 19 18 17 14 13 13 +8 15 16 18 20 20 26 +42 42 44 48 49 49 +44 37 34 31 30 26 25 25 +76 80 81 82 88 92 +27 27 22 21 18 15 15 +26 26 25 19 17 13 +35 32 34 32 31 25 +37 41 43 50 50 +19 18 16 11 8 6 8 +18 21 19 13 6 +57 58 56 53 51 47 46 +58 57 54 51 52 52 +73 72 75 81 84 88 +14 13 18 20 21 24 +65 65 62 61 59 59 59 +76 80 80 83 85 88 91 97 +89 85 81 80 77 +23 23 23 26 27 25 +71 69 70 69 66 +29 31 36 37 40 43 45 45 +77 74 71 71 71 +44 47 44 41 44 39 +69 74 77 79 78 75 +55 55 57 60 63 62 66 +74 73 71 69 69 66 59 +25 21 20 17 16 13 13 14 +26 30 31 29 31 33 33 +37 41 44 45 48 52 53 +67 67 68 65 72 +76 76 79 77 79 80 83 82 +28 30 33 35 33 31 +48 54 56 57 61 62 59 +31 26 25 24 22 20 +10 11 13 13 20 +3 3 7 10 12 14 18 +75 79 76 79 80 81 +16 21 27 29 31 33 35 40 +24 20 19 18 18 17 10 +90 93 90 83 82 80 79 +37 35 33 30 29 27 26 24 +20 17 15 13 11 10 9 +1 2 5 6 9 11 13 15 +42 44 46 48 50 52 54 57 +40 38 36 34 31 28 +24 23 20 17 16 15 13 12 +78 77 75 72 71 68 67 +65 66 69 71 74 77 79 82 +65 64 62 59 58 +70 67 66 64 62 +23 21 20 19 16 +26 29 30 33 35 36 +50 48 47 45 44 41 38 +9 12 13 15 17 18 20 21 +43 41 40 38 37 34 32 +24 23 21 19 16 13 10 9 +93 91 88 86 83 80 +37 34 33 30 29 +36 33 30 29 28 26 23 21 +84 87 90 91 94 95 96 +57 55 52 51 50 49 47 +83 86 87 88 89 92 94 96 +56 58 59 62 63 64 67 70 +62 65 66 68 69 72 74 +52 54 57 59 60 63 +46 43 40 39 37 +70 69 68 65 63 60 +72 73 76 78 79 81 +23 24 25 26 29 +69 66 65 62 59 +49 50 53 54 56 58 +39 40 43 44 46 49 +50 48 47 45 42 41 +21 18 15 14 13 11 8 7 +66 68 69 70 72 75 +64 61 59 57 55 54 53 +22 25 26 29 30 33 36 +35 38 41 43 46 +22 21 19 17 14 12 10 7 +35 33 30 28 25 24 +81 79 76 75 73 +48 45 42 41 38 37 +24 25 27 29 31 32 +18 21 22 24 26 28 31 32 +21 24 25 26 29 30 32 +87 85 83 81 80 77 74 71 +35 32 29 27 24 22 19 16 +89 91 92 93 96 97 +37 35 34 33 32 31 29 +84 81 80 77 74 71 69 +38 35 32 29 26 25 +93 90 89 87 84 82 80 78 +88 85 83 81 79 78 76 73 +2 3 5 6 9 11 14 17 +31 30 27 25 23 20 +95 92 91 89 87 85 82 +6 7 9 12 13 15 17 20 +48 45 42 41 40 39 36 35 +76 73 72 69 66 64 +82 80 77 75 73 72 +67 69 71 72 75 76 78 81 +1 2 4 6 9 12 13 +21 20 19 16 13 11 9 8 +42 39 38 37 34 32 +21 22 25 27 30 33 36 +57 56 55 54 53 51 48 47 +37 35 33 30 27 25 23 +14 17 18 21 23 26 27 29 +43 45 48 50 51 52 53 55 +15 14 13 10 8 +17 18 21 22 25 26 +13 10 9 8 6 5 4 +84 86 88 91 93 +91 90 87 84 83 +35 32 30 29 28 26 +56 59 61 62 65 +20 22 24 27 28 +32 33 35 36 39 +48 49 50 51 53 54 56 58 +60 62 64 67 69 71 +25 22 19 17 14 12 11 +25 28 30 31 33 35 37 38 +56 54 51 50 47 46 43 +31 32 33 35 38 +59 58 56 54 52 50 47 46 +86 89 90 93 94 95 96 99 +95 93 92 91 88 85 +65 64 63 60 58 57 54 +74 76 77 80 82 +76 78 79 81 82 +12 11 10 7 6 4 2 +90 87 86 83 82 +16 13 12 11 9 8 7 +41 38 36 35 32 31 28 26 +43 45 46 48 51 52 54 55 +94 91 88 85 82 81 +77 74 72 69 68 66 65 63 +30 32 35 36 37 40 42 +82 83 85 87 88 90 +67 64 62 60 59 57 54 +92 90 89 88 87 84 83 82 +21 22 25 27 30 +63 65 68 69 71 +6 9 11 12 13 16 +92 89 88 86 83 80 +92 91 89 87 86 85 84 82 +18 16 13 11 9 +52 50 47 44 41 39 38 +10 11 13 15 18 +46 44 41 39 38 37 34 +27 30 31 33 36 +65 67 69 72 73 75 76 77 +40 43 46 47 50 +88 85 82 79 77 76 74 +87 89 91 94 95 +88 86 83 80 79 76 73 70 +41 43 45 48 51 52 55 +87 90 91 93 95 +79 82 85 88 89 91 92 +7 10 11 14 16 17 19 +46 47 48 50 51 52 +95 93 90 88 86 84 83 82 +68 70 71 73 76 +80 79 76 73 71 69 +80 83 84 87 89 90 +94 93 92 91 88 87 +85 82 80 77 74 71 68 +32 29 28 25 24 22 20 +45 42 40 37 35 33 +51 48 47 44 41 39 +33 36 38 41 42 45 +84 82 81 78 76 75 72 69 +24 25 28 29 30 32 33 36 +75 77 79 81 82 85 88 +2 5 6 9 10 +73 75 77 80 82 84 86 +69 68 65 62 59 +82 81 78 77 75 74 +69 71 72 73 76 77 79 80 +78 80 82 85 87 +95 94 91 90 88 85 84 81 +65 68 70 71 72 75 77 +80 81 83 85 86 87 +42 39 36 34 31 29 +82 85 87 88 90 91 92 93 +44 41 40 37 36 35 32 +71 69 67 65 62 60 58 56 +92 89 87 84 81 80 77 +31 30 28 26 23 22 19 17 +14 16 19 22 23 26 +84 86 88 90 91 +37 34 33 32 29 +75 76 79 82 85 86 87 90 +63 66 69 70 73 75 +26 27 28 31 33 34 37 39 +46 43 40 37 34 32 +28 26 25 23 21 19 +67 65 63 60 57 55 52 +33 35 36 39 42 43 45 46 +58 55 52 49 46 45 +99 98 97 95 92 90 88 +27 30 32 35 36 39 41 43 +59 58 57 56 54 53 50 47 +31 29 27 25 24 22 21 18 +35 33 32 29 28 25 23 20 +66 65 62 60 58 56 53 50 +50 51 54 55 58 61 +71 68 65 63 62 +47 48 51 53 55 58 59 61 +10 12 14 16 19 21 +33 35 37 38 39 41 44 45 +94 92 91 90 89 +10 12 15 17 19 22 +83 86 87 89 91 93 95 98 +27 24 22 21 18 15 13 +97 95 92 89 88 87 +20 21 24 25 28 29 31 +72 71 70 69 67 65 64 +65 62 59 56 55 52 51 48 +79 77 75 72 71 69 +70 67 65 63 61 59 56 +9 10 12 14 16 17 18 21 +9 10 13 15 17 19 +49 50 53 56 57 +51 54 56 57 58 61 63 66 +86 88 90 92 93 +37 38 40 42 43 +32 33 35 37 38 39 +77 75 72 69 68 65 63 60 +10 13 15 17 19 +29 31 34 35 36 38 +61 63 64 67 69 71 74 +86 84 82 81 79 76 74 +51 48 47 45 44 42 39 37 +37 39 42 45 46 49 50 +54 57 59 60 62 63 65 66 +43 45 48 49 51 52 +57 56 55 54 52 50 47 +13 15 18 19 20 23 26 +4 7 9 12 13 14 +24 23 20 19 16 15 +53 52 50 49 47 44 43 +11 13 15 17 20 22 24 +27 26 24 23 22 20 +4 5 6 9 11 +26 23 21 19 17 14 13 10 +34 35 37 39 41 44 46 +59 61 63 65 68 71 +50 47 46 44 42 41 39 36 +23 20 17 15 13 +28 25 23 20 17 14 12 +2 5 7 10 13 16 +16 18 19 20 23 25 +5 6 7 8 11 14 +44 47 48 50 53 54 +43 42 40 39 36 35 34 31 +57 59 61 62 65 66 67 +37 36 35 33 30 29 28 26 +80 79 78 76 73 70 +93 92 90 87 86 84 +54 52 49 47 46 44 43 41 +27 25 22 19 18 15 +76 78 80 81 83 85 +79 77 74 71 69 67 66 +29 28 25 24 21 18 16 +2 3 6 9 10 +12 9 6 3 2 +55 58 60 61 62 63 64 66 +16 17 18 20 21 22 25 28 +62 63 64 66 68 71 74 +17 20 21 23 26 27 29 +22 19 18 17 16 +44 47 48 51 52 54 56 +36 38 41 42 44 46 48 50 +28 27 24 23 20 19 17 +20 17 15 13 11 +65 64 61 60 58 55 +49 46 44 43 42 39 37 34 +75 73 72 71 68 +50 51 53 54 56 57 +73 72 69 68 66 63 61 +44 45 48 51 52 53 +66 65 63 60 59 57 +48 49 50 51 54 57 58 59 +71 74 77 79 82 84 86 87 +60 58 55 53 51 49 +12 14 15 16 19 +35 36 37 38 40 43 46 +20 19 18 17 15 13 12 9 +92 89 88 85 83 81 +14 15 17 20 21 22 24 27 +74 76 78 79 80 82 83 86 +61 58 55 52 50 49 46 +48 49 50 51 54 57 58 60 +86 87 88 90 93 95 +49 47 44 41 39 37 +10 9 8 7 5 +78 80 81 82 83 85 88 91 +51 50 48 45 44 41 40 +52 50 48 46 44 +88 89 90 91 94 95 96 +91 89 87 86 84 +26 24 23 21 20 18 17 +61 60 59 58 57 54 51 50 +20 23 25 28 30 +39 42 45 46 48 51 +49 51 53 55 58 61 +20 22 23 24 25 28 30 33 +50 52 54 56 59 +83 82 81 80 78 +66 63 62 60 57 +60 58 57 54 51 48 46 45 +86 87 90 92 93 95 97 98 +14 16 17 19 21 +42 41 40 38 35 +63 66 68 69 71 +78 79 81 84 85 86 87 89 +18 17 16 13 11 8 +66 68 71 74 77 79 +79 81 84 87 88 91 +45 46 47 48 50 51 +25 26 29 30 31 32 35 36 +59 60 63 64 66 +89 86 85 83 80 77 75 +31 29 27 26 23 21 +29 31 34 37 38 +78 79 80 82 84 86 89 90 +66 64 63 61 58 +53 56 58 59 62 64 67 68 +14 11 8 7 4 +57 59 61 63 65 +30 29 27 25 24 +29 27 26 23 21 19 16 +38 37 36 33 30 28 +19 21 24 27 29 32 33 35 +69 68 65 64 63 61 59 +84 83 82 81 80 79 +10 12 14 16 18 21 24 +40 41 42 44 47 50 52 +30 29 28 27 24 23 +62 60 59 57 54 +53 52 50 49 48 45 44 41 +28 26 25 22 20 +64 61 58 55 54 53 51 +63 65 66 69 70 +52 50 49 47 44 43 40 39 +25 27 28 30 31 33 36 37 +87 89 92 93 94 96 99 +94 91 88 87 85 82 79 76 +66 64 63 61 58 57 +60 58 57 55 52 49 48 +2 3 6 8 11 12 15 +34 33 31 30 29 26 24 +70 71 73 74 76 78 79 +19 22 23 26 29 31 32 +68 69 70 72 74 77 +73 71 69 68 65 +23 24 27 29 32 33 +57 56 55 52 51 50 48 46 +20 22 24 26 27 29 +78 81 84 87 89 91 94 +74 75 78 79 81 84 87 +48 47 45 44 41 38 35 +33 34 37 40 43 45 +74 76 79 80 82 84 +15 17 20 21 22 25 28 29 +7 10 12 14 15 16 19 20 +51 48 45 42 39 38 37 +1 4 7 9 12 14 +82 81 80 78 75 74 73 72 +39 37 36 34 32 29 +9 11 14 16 18 20 +8 9 10 11 13 15 17 20 +20 22 23 25 28 29 30 +87 84 83 80 79 77 74 72 +50 52 55 57 60 62 64 67 +75 72 71 69 66 65 62 +35 33 31 29 27 24 22 +78 79 82 84 86 87 90 +16 15 14 11 9 8 6 5 +56 58 59 61 64 66 69 +37 35 33 31 30 +14 16 18 19 22 +14 15 18 21 22 25 +83 84 86 87 90 92 95 +78 80 81 83 85 86 +3 4 5 8 9 +68 70 73 75 76 77 +65 63 62 59 56 +18 19 20 21 24 27 29 31 +45 47 49 50 53 55 58 +45 43 41 38 35 32 30 +53 54 55 57 58 +90 88 86 85 84 81 78 +6 8 10 11 14 15 +18 21 23 26 29 31 34 +51 50 47 46 43 41 39 37 +82 81 78 75 72 71 68 +98 95 94 93 90 88 85 +20 19 16 14 12 +11 14 16 18 19 22 24 27 +29 27 24 23 22 +19 18 16 13 10 7 5 4 +44 41 38 36 34 +45 44 42 40 39 37 +38 36 35 32 30 29 26 +27 28 29 30 33 36 +68 69 70 72 73 74 +89 90 93 94 96 +44 42 41 39 38 35 +85 82 81 80 77 +32 34 35 36 37 39 41 +44 43 42 40 37 36 +84 82 80 79 78 75 74 72 +40 42 45 48 49 51 52 +77 78 80 81 82 84 87 90 +37 40 42 43 46 +92 90 88 87 84 +37 39 40 41 44 45 46 +72 75 78 81 83 86 88 91 +66 67 69 70 73 +40 41 42 44 45 +92 90 87 86 83 82 79 +33 34 37 38 41 +75 77 78 81 83 84 87 90 +66 65 63 60 59 +69 68 66 65 62 +68 71 73 75 76 +79 82 85 87 90 +61 58 56 55 54 52 +6 7 9 12 13 14 +25 24 22 20 18 17 14 13 +48 51 52 53 56 59 +50 48 47 46 43 41 39 +3 5 6 9 10 +44 42 40 39 38 +47 46 43 40 39 +24 26 29 31 34 37 40 41 +13 15 18 21 22 23 25 28 +52 51 50 49 47 46 45 43 +48 47 44 42 39 36 34 +60 58 56 53 50 49 +26 23 20 17 16 15 +77 74 72 71 68 67 65 62 +9 10 12 13 16 17 19 21 +51 54 56 57 58 59 60 +54 57 59 61 64 65 +35 38 40 42 44 +37 38 40 43 45 48 +37 38 40 43 45 47 48 +80 81 83 84 87 +35 37 40 41 43 +80 78 75 74 71 68 66 +46 48 49 52 53 55 56 +53 54 57 58 59 61 64 67 +51 54 56 59 62 65 66 67 +21 24 26 27 28 30 +27 26 24 22 20 19 16 +19 21 23 25 28 29 31 32 +10 9 8 7 5 4 +32 35 36 39 40 42 44 46 +51 49 48 46 45 42 +51 48 46 45 43 +52 55 56 59 61 63 66 +19 17 15 12 10 9 6 5 +5 6 7 10 13 +46 44 43 40 38 36 33 +24 22 21 18 15 14 12 +50 53 54 57 59 +78 80 82 83 85 +14 15 16 17 18 21 +37 34 33 32 31 28 26 +55 57 59 62 65 66 69 +87 90 93 95 96 99 +37 39 42 44 45 +1 4 5 6 8 +24 21 20 19 16 15 13 +75 73 72 71 69 67 +77 79 82 85 87 90 +45 42 39 38 35 33 31 +34 31 30 27 25 23 +40 39 36 33 30 +77 80 82 85 87 90 91 +76 74 72 70 67 +58 60 63 66 69 +43 41 40 39 38 +46 44 42 40 39 +96 94 93 91 88 +90 89 88 86 83 80 77 +68 67 66 64 62 60 58 +87 90 93 94 95 96 99 +30 32 33 35 37 +41 44 45 46 47 +44 43 41 40 37 +16 14 11 9 6 +97 95 93 91 89 87 +23 21 19 16 15 +63 60 57 55 53 51 50 47 +60 62 65 67 70 73 +6 8 10 11 12 15 16 +79 78 77 74 71 70 +56 57 59 62 63 66 +46 43 42 40 38 37 35 32 +87 85 83 81 79 77 76 75 +74 72 70 69 66 +17 14 13 12 9 +74 76 77 78 79 81 +18 21 23 25 27 29 32 +34 31 29 27 25 23 20 +86 84 83 82 80 78 75 +41 42 44 45 48 51 54 57 +36 34 32 31 30 27 24 +42 39 37 36 35 32 30 28 +84 82 79 78 76 74 +42 40 37 36 35 34 31 +57 56 54 52 50 48 46 +20 21 24 26 27 +37 40 41 44 46 48 50 51 +28 29 30 31 34 +12 14 16 18 21 +69 70 73 75 76 77 +40 39 36 34 32 30 29 26 +57 59 61 64 66 69 70 +35 36 37 39 42 +56 55 54 53 50 49 48 +60 59 58 57 55 +33 30 29 27 26 24 22 +85 82 81 80 78 76 75 +67 64 61 60 57 54 52 +86 85 84 81 78 +47 45 43 42 41 +25 24 23 20 19 18 17 15 +58 57 54 53 50 49 +88 90 91 92 93 96 99 +46 43 41 38 35 +20 18 15 13 12 9 7 +81 79 77 74 73 72 69 67 +61 58 57 54 52 49 48 +93 91 90 87 85 84 81 79 +9 10 12 13 15 18 19 21 +66 69 72 75 77 79 82 83 +73 74 76 79 80 81 84 +61 59 57 56 55 +18 15 12 10 9 8 5 +85 82 79 76 74 +40 38 36 34 33 +69 72 74 77 80 82 83 85 +70 71 73 75 77 80 82 +78 77 75 73 71 70 69 68 +3 6 8 9 10 11 14 +5 6 9 12 14 +60 58 55 54 52 49 48 +8 11 14 15 16 +65 66 69 70 72 73 74 77 +79 82 84 87 88 +61 59 58 55 52 51 +44 41 40 39 37 34 32 +23 25 28 29 31 32 35 +33 36 37 39 41 42 44 46 +51 48 45 42 41 +62 59 58 56 55 52 49 +28 30 32 33 34 35 37 40 +52 54 55 57 58 59 62 +20 19 16 14 13 10 8 5 +60 61 64 67 69 +71 69 67 66 63 +98 96 95 92 90 +6 9 12 13 15 18 19 21 +35 36 38 41 43 45 48 50 +91 88 85 84 81 78 76 +83 85 87 90 91 94 97 98 +64 66 69 70 71 72 75 76 +57 55 52 51 49 +15 17 20 23 25 \ No newline at end of file diff --git a/day_2/solve_1.ts b/day_2/solve_1.ts new file mode 100644 index 0000000..1262f21 --- /dev/null +++ b/day_2/solve_1.ts @@ -0,0 +1,35 @@ +const txt = await Deno.readTextFile("input.txt"); +const lst = txt.split("\r\n").map((x) => x.split(" ") + .filter((x) => x.length > 0)) + .map(x=> x.map(x => parseInt(x))); + +function isSafeReport( + arr: number[] +){ + let isIncreasing = true; + let isDecreasing = true; + for(let i = 1; i < arr.length; i++){ + const diff = arr[i] - arr[i - 1]; + if (Math.abs(diff) > 3){ + return false; + } + if (diff === 0) { + // if the difference is 0, the array is neither increasing nor decreasing + return false; + } + if(arr[i] > arr[i - 1]){ + isDecreasing = false; + } else { + isIncreasing = false; + } + } + if (isIncreasing || isDecreasing){ + return true; + } + // if the array is neither increasing nor decreasing + return false; +} + +const safeReports = lst.filter(isSafeReport); +console.log(safeReports); +console.log(lst.length,safeReports.length); \ No newline at end of file diff --git a/day_2/solve_2.ts b/day_2/solve_2.ts new file mode 100644 index 0000000..217c108 --- /dev/null +++ b/day_2/solve_2.ts @@ -0,0 +1,122 @@ +const txt = await Deno.readTextFile("input.txt"); +const lst = txt.split("\r\n").map((x) => x.split(" ") + .filter((x) => x.length > 0)) + .map(x=> x.map(x => parseInt(x))); + + +function isSafeReport( + arr: number[] +){ + let isIncreasing = true; + let isDecreasing = true; + for(let i = 1; i < arr.length; i++){ + const diff = arr[i] - arr[i - 1]; + if (Math.abs(diff) > 3){ + return false; + } + if (diff === 0) { + // if the difference is 0, the array is neither increasing nor decreasing + return false; + } + if(arr[i] > arr[i - 1]){ + isDecreasing = false; + } else { + isIncreasing = false; + } + } + if (isIncreasing || isDecreasing){ + return true; + } + // if the array is neither increasing nor decreasing + return false; +} + + +function isSafeReportEr( + array: number[], + options = { + errorMargin: 3, + errorThreshold: 1 + } +){ + if (array.length < 2){ + throw new Error("Array must have at least 2 elements"); + } + const arr = array.slice(); + const isIncreasingCount = arr.reduce((acc, x, i) => { + if (i === 0){ + return acc; + } + if (x > arr[i - 1]){ + return acc + 1; + } + return acc; + }, 0); + const isDecreasingCount = arr.reduce((acc, x, i) => { + if (i === 0){ + return acc; + } + if (x < arr[i - 1]){ + return acc + 1; + } + return acc; + }, 0); + const isIncreasingMostly = isIncreasingCount > isDecreasingCount; + const errorMargin = options.errorMargin; + let errorThreshold = options.errorThreshold; + + for (let i = 1; i < arr.length; i++){ + const diff = arr[i] - arr[i - 1]; + const overErrorMargin = Math.abs(diff) > errorMargin; + const isZero = diff === 0; + const orderMismatch = isIncreasingMostly ? diff < 0 : diff > 0; + if (overErrorMargin + || isZero + || orderMismatch){ + // return false; + if (errorThreshold === 0){ + console.log(`Error threshold reached`); + console.log(arr); + return false; + } + errorThreshold--; + console.log(arr); + console.log(`Removing ${arr[i]} at index ${i}`); + arr.splice(i, 1); + console.log(arr); + i--; + } + } + return true; +} +// console.log(isSafeReportEr([4,6,7,9,11,12,12])) + +const safeReports = lst.filter(x=> isSafeReportEr(x)); +// console.log(safeReports.length); +// const safeReports2 = lst.filter(x=> isSafeReport(x)); +// console.log( +// new Set(safeReports.map(x => x.join(","))).difference(new Set(safeReports2.map(x => x.join(",")))) +// ); + +const safeReports3 = lst.filter(x=> { + const safe = isSafeReport(x); + if (!safe){ + // remove one element at a time + for (let i = 0; i < x.length; i++){ + const copy = x.slice(); + copy.splice(i, 1); + if (isSafeReport(copy)){ + // console.log(`Removed ${x[i]} at index ${i}`); + return true; + } + } + return false; + } + return safe; +}) + +console.log(safeReports3.length); +console.log(safeReports.length); +console.log( + new Set(safeReports3.map(x => x.join(","))).difference(new Set(safeReports.map(x => x.join(",")))) +); \ No newline at end of file diff --git a/day_3/example.txt b/day_3/example.txt new file mode 100644 index 0000000..2e1a90a --- /dev/null +++ b/day_3/example.txt @@ -0,0 +1 @@ +xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) \ No newline at end of file diff --git a/day_3/example2.txt b/day_3/example2.txt new file mode 100644 index 0000000..b774ec9 --- /dev/null +++ b/day_3/example2.txt @@ -0,0 +1 @@ +xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)) \ No newline at end of file diff --git a/day_3/input.txt b/day_3/input.txt new file mode 100644 index 0000000..82f8857 --- /dev/null +++ b/day_3/input.txt @@ -0,0 +1,6 @@ +where())what()@)select()why()?mul(371,776)/%how()'~+:how()mul(977,266)@$@mul(749,170)how()<;$^#what()select()mul(338,975)>from()+,{select()!!mul(626,938)%/>^{((}]mul(733,977)>)() +$)mul(695,376)!%#how()mul(767,788)<(mul(876,501)mul(18,72)[*when(625,65)*('what()mul(491,884)from()?{>how()mul(645,385)/[when(){what()why()mul(802,476)#'select()who(327,719)+-,##mul(103,807)#(mul(192,909):@'^where(247,392)!who()^mul(875,344)why()mul(205,505)?;?when()!],mul(165,670),#$++'>)'mul(503,815):mul(483,302)~+*}!$where()why()&mul(785,794)/,{why();where(218,722)}when()don't();!mul(405,577)where()@mul(521,472){how()what()'what() where(55,484)mul(360,384)%mul(176,384)}%when()-$%what(436,501)mul(652,387)mul(758,52)-~@,*-@mul(343,835)when()select()](;#mul(76,425)from()>})]mul(720,464)#~)why()why()mul(619,682))mul(15,67)mul(569,569)]where()++&@:[#mul(844,620)select()+^*what()why(197,509) mul(280,807)%^mul(233,435)}?*:+^^what()!when()mul(69,464)& )]$mul(393,827)@]^mul(64,552):^)*<&where()?#mul(51,727)mul(159,242),+what())>+mul(140,116)do()~?mul(590,950)};[*;;when()mul(186,556)]&;#&##*!mul(806,651)^select()who()[mul(820,386);?from()mul(771,404)-$+#]&where()}mul(473,823)don't()when(874,250)'}mul(916,835)mul(432,92)how(), :mul(2,546)who(61,440), -mul(486,858)where(869,462)do()'select()&?+&why()where()>>mul(796,512){~(when():^>*&'mul(927,22)%;where()who()^$mul(203,851)%how()mul(820,954)from())~#mul(741,967)select()what()+[[why()&]mul(42,517)>]why(),select(297,821):mul(324,191);%{->:!#mul(567,73)don't()?why():^{$*]why()mul(504,229)'mul(40,787)/select()?who();[who()where();$mul(537,42)[#@&*~<@mul(418,58);{}how()*-don't()[<'@from() mul(38,329)-*mul(381,685)what()?+,,*%)mul(740,7)#)#)?^mul(211,355){~#who()<]who()@>~mul(135,667)-^)]'mul(165,161)<;,mul(350,311);%?~}$how(768,325)*mul(773,359)~!(select()?{why()mul(269,149)when()}*who()}mul(536,90)don't()>$ &!where()*who()&mul(405,425)!+mul(304,694)'<#$<<,#select()):%:* -why()#mul[who()when(918,883){ ^''mul(907,968)what()when()[who()>mul(81'how()+what()select();&'']+how()mul(745,379)]^-mul(403,82)mul(840,830)when()+what()how()[!select()mul(827,564)?:]mul(602,333){what()[[mul(606,272) +,who()>}who():#from()mul(960,322)where()')?,+when() mul(59,855)'mul(308,433)~[;$;:mul(486@!>mul(508,605)what()from()mul(597,956)>#' *mul(834,240)}![{who(983,119)]#what()where()mul(533,711))}what()'/-mul(189,207)^*--$?mul(424,618)mul(407,288)why()<[+mul(170,906)&select()[,#who()+,mul(508,516)?who()!}+select()mul(963,397)*/]mul(129,895)$select()'when()^?mul(604,838)>mul(38,524)?why()~)[#*+:mul(793,697))what();}who())]mul(286,779)--where()![@(/}:mul(156-<%mul(862,26)select()mul(679,658);+mul(492,253)/;?$&}#mul(761&'[/*?mul(31,877)^where()mul(366,701)#mul(519,128)what()select():when()* mul](mul(46,247);mul(864,153)*mul(93,786)[$&&+mul(349,493,'~mul(161,724)~+$what():mul(326,607)what()select()mul(108,288)@(where(287,297)~how()mul(15,832)select()!%( mul(233,322*;%],&@why(660,737)mul(47,778)?mul(68,311)}do()^/>[mul(572,909)^(,$,*~?mul(550,192){select()$${mul(949,906)?[^]@@^what()do()'mul(581,669)who()how()$~;(where())how()what();<>^mul(859,756)mul(323,125%?}%where()mul(694,499),[mul(290,758)how()from()-/*who()&'where()what()where()when()mul(286,592);: how(824,40)^mul(341,311)'&how()};^how()mul(479,155)-&when()%>!from() mul(743,297)/+% mul(785,803)~&/}#($?select()from()mul(378,606)/%when()mul(304,253)who())mul(19 mul(358,187)!/mul(61,423):%: )mul(773,349)select()mul(380,503)where()#%;do()who()$!(:&where()where()mul(25,688who()mul(539,689)?[/(>mul(915,247)how()@ when()why();;from()mul(192,625)?how()who()why()+<~where()!mul(922,457)how()@:+}[&{don't()mul(663,641)& :*]select()from()^>who(646,961)mul(302,499)mul(779,59)#+ /~;}mul(489]mul(883,556)from()#what()#:when():@$^mul(857,680)why(836,2)[mul(815,638)&why()~:why()~mul(960,833)<>from()where()where()$:who()mul(853,356)%;)+ where()from())do()<]mul(139,315){&+why(765,155),what()>@mul(281,247)mul(797,456) <>/:mul(785,173)when()$~-?:select()when()&mul(185,8)mul(510,671)%,when()how()where()from()who()mul(654,885)*who()mul(227,178)} !mul(256,394) +mul(888,165);]~mul(93,961)do();where(449,598)*-& #mul(364,267)how()what()where()&@%mul(173,845)+?>({]^-}!mul(500,764)why() , ;where()}mul(509,958)~#when()&'^(#*}mul(567,675)!why()%:(~where(){mul(659,362/<@+mul(442,603)where(232,716)!how()!;)$what()mul(47,742)don't()&{ what()mul(201,59)-how()where()&select()mul(564,724)&when(){><{who(56,63)>#mul(750,782)$,mul(713,443)(^>*who()mul(255,743)+< what()mul(13,455^when()%';how()<<&'%mul(909,623)[?%when()~[$mul(647,666)+why()mul(303,514)mul(866,565)why()*@what()(mul(528,440)mul(580,935)mul(621,192)(from()?who(),!*-mul(834,426),!]/)how()]why()do()how()}!{why()'@~^who()mul(114,512[#^~ select()*who(){^;mul(813,830)+;[#/[do()select()}/^(@!;*mul(667,761;#why()!(+(mul(427,964)why()^where()!;mul(816,813)&select()what()why()$>from()mul(204,891)*#^[-how()how(275,54)mul(862,293)^^/~>,*)mul(858,212)[how()?>where()mul(45,936)select())select() <)where()how()mul(617,746)/ ~%from()~mul(466,629)mul(604,220)why(235,921)^what()^select()who(540,898)what()>mul(893,561),%~(who()how())#+#mul(845};mul(795,975)who(),',mul(988,400)/$+,!$~mul(931,322)( <:%+when()mul+%<&mul#'mul(892,416)what()why()mul(369,579)''mul(384,303)when()where()[what()-?$[when()mul(179,420):?:select()}when()when();,mul(246,209)select()mul(966,243)[mul(153,599)when()mul(914,433)[from()when()[--#;'!mul(810,766)select()why()$>!when()mul(931,687);select()how()@&mul(98,464)]mul(652,409)#:mul(516,121){<{() @~;how()mul(123,360))^](mul(277,239)mul(840,613)what()%mul(586,205)^]@#/don't()'[;^,$ from()mul(628,557)<)>];+who()mul(878,975from()mul(143,987)+when()*])%what()mul(603,174-from()~?mul(943,847)where(170,904)&#%]who(888,776)mul(302,183)mul(443,591),why():]~:%mul(77,426)when()where()mul(950,995)&mul(274,396)?[from()where()from()mul(409,518)$do()#^{why()mul(613,963)&^ >>;^how()mul(925,923);}mul(852,446*;& mul(743,312)do()%/who()*$]?mul(475,555)(>select();when()[mul(976,68)select()]what() +when()from()>why()mul(976#>>how():''%what()mul(828,766)!@(mul(798,719)$]*mul(646,954)@why()}from():$why()%/select()mul(741,161)+mul(91,115)^-}when()%++mul(933,749)from()<{when()(mul(909,579)#>;where()mul(211,740)$where()from()who()&mul(255,95)mul(511,373)&@!who()when()$@$?select()mul(2,521)^{)#mul(294,886)why()(!@mul(7,438)%*~(#{'$mul(234,87){+,how()how()mul(890,233)mul(801,729),;&(&mul(421@/+/from()when()/don't()/mul(672,498)what()mul(14,796)^![*what()when()# mul{!where()$where(871,580)}mul(717,476)&)'%?why(905,632)when()what()mul(815,617),how()mul(827,71)>?mul(837,520)*how()select()what())select(),how()$from()mul(952,273 &@mul(106,964)-[where()mul(778,265)}$'mul(947,970)who()?>mul(780,897) +/,mul(904,917)how()from()] :%where()why(824,519)$}mul(433,689)-/{where()%>how()mul(232,555)&'@mul(170,145)?-{#?[mul(130?from()mul(575,167;~,${;-/)what()when()mul(688,24)&)#^*mul(251,895)(>from()#}]select()?}%mul(583,40)@what()!-mul(396',)!>%%when()}mul(127,975)#mul(986,310)what();from() <{'?from()[&who()when()when()[mul(910,515)$mul(261,324)~-mul(124,305)~select()mul(323,359)*~~mul(524}(;mul(145,708) %}what(487,689)%from()mul(371,88)~!)mul(883,681)why(621,555)from()-mul(175,888)&{];-what(569,630):?mul(229,850)&>'where()'mul(269,654]-why()//from()select()}mul(545,830)[?:}mul(849,642)/;(:)}<~mul(928,739)mul(216,77)select():;(when()@(}*]mul(113,497)(!~~;^[!mul(447,997);select()~[>]}~who()don't());}#why(326,879)+)-<(mul(581,152)> ;mul+how(771,784)+&why(582,346)'select()~what()<,mul(239,575)<(]+*from()]~'<}@who()<-mul(473,971),:($when()from(41,290)what()];do())@^[@ from()mul(603,541)}mul(811,508)*?/!what()[-{mul(994,800 ?/!where()who()where()what()}:what(){^[do()when(284,569)}>mul(150,172,]/when()^mul(231,419)/do()select() }-#mul(671,892)<>/how(789,349)from()@what()#@)mul(315,222)from()}when()/}mul(930,682)>'where()?who()mul(132,978);;:@/#^}do()+mul(447,390): mul(723,622)?(how();$select()mul(980,864);>^why()[?#mul(734,179)# where(),@how()mul(838,788)/{++%mul(272,849):*%/^%mul(466,441how()who()who()'@(mul(692,669)#&mul(39,354)-where()from()who()~don't()*( {where();what()#mul(526,300)select(552,879), when()where()select()&-mul(283,140)&&?^ mul(243,254)how()/}who()mul(282,199)select()!](?'what()@&+mul(31,366)}who()mul(640,530)mul(565,470)mul(290,665){what(445,299)}<#%~ ][mul(320,303)-~from()(who()>[('why()don't()~&{)]mul(720,131)#~!!select()mul(3,408)-[where()from()who()}&}mul(558,189)!?[&(do()-^>mul(429,22)$!:>how()<,select()select(629,810)mul(748,450)(/<]?select()!//mul(679,551)how()who();?what()from()-mul(225,868)@{why()mul(177,830),{?^what())mul(229,827)~what()]'how(958,802)?who() (mul(676,215)[)mul(999,210)?]$*,?]-$,mul(661,825) +from()<#from()[@>?$(mul(631,608),+mul(946,420),( (^[^+/{mul(569,409),what()who()~mul(702,265);mul(88,623)}who()what()&mul(676,744)from() !+[do():who()^?mul(336,740)?mulwhy()from()!}where()%%mul(571,353)>$,& }>{*mul(276,415)><-do()~(]}mul(308,489)/from()when(579,867)what()~when()?&mul(633,256)how(){?~mul^why()who()>mul(223,473);why()when(),mul(722,306)from()^mul(200,701)!select()?,mul(711,878)how()where())##'+}#@mul(56,894)@[what()mul&-who()when()when()[%>?mul(281,311)where()where()how(){select()'%mul(949#[?:mul(895,313)/mul(25,736)mul*&):-/%who())mul(301,39)what()(mul(767,317)&!what()mul(271,721)(:where() :*&/mul(881,552)mul(117,678)> #),where()%)&$mul(394,101)<)>&who()what()'+mul(496,283)mul*]@+mul(331,181)select()'?:how()!what()-how()]mul(629,183){{(mul(980,656)! when()@{'-,what(),mul(93,847)++where();@select()when()mul(544,305)'#'<,from()>why()>mul(219,755)what(){ ~]}don't()-when();^^when())?~how()mul(590,547)(!from()when()[?}where()mul(930,301)where()^+when()what(733,168){>mul(899,94);:?mul(928,368)mul'what()how() >($mul(625,960)%'&where()select()~mul(584,72)^!mul(55,527);mul(492,224)?($:,',*select()mul(180,326)select():{where()mul(824,130)what()mul(683,478)from(918,839)what()mul(582,660)<@*how()*(mul(681,373)(~~>@::]$mul(873,698)<@+when()-^mul(100,128)[^+:where()how(542,879)&{mul(327,603) $+!when()$mul(505,966) ,$~)>mul(193,642){!/,}* mul(784,245)}?what()when()#mul(4,692)<+&%!)mul(184,826)+mul(469,907)from()how(601,83)mul(307,230),@}where(318,472)from()}:})-mul(898,829?$^@where();what()(mul(258,499)mul(212,108){{!&what()who()who()mul(983,25)*);who()!, [don't()select();-%*@mul(798,455)when()$>from()where():do()mul(707,598)how())!:select()how()#do()mul(81,685)who()+where()mul(292,774)?/mul(80,716who()*{#;;*do()&%why()+mul(554,30)!select()],{%/what()mul(600,514)#when())do()@what()'%when()mul(955,368)[#/>:?-how() select()mul(170@?)mul(584,682)what()^,?]#@mul(623,37) ;mul(650,391)/%mul(535,768)how()when()mulwhere()when()when()*(mul(193,547)$)[why()'select()$$who()]mul(446,367),what()~@%*mul(675,581)mul(637,187){mul(727,146)}where())mul(896,767)select()'-mul(980,725)select()[ *#mul(159,247)!what()who(560,832){-why()what()~&#mul(567,372)-:!]?/why()+:{mul(277,161)-where()'-who()$how()who()from()'how(),$$when()mul(429,870):@;<#mul(587,942*&;*do()$$select()mul(3,25)when(),-%+:# from(872,943)}mul(782,821) +!>mul(851,461)+!where()$!{@!:)mul(93,494):!mul(951,143)+>)why()-{from()what()mul(988,791)mul(931,510)(:where(245,25){'mul(117,354)'what(); [[@how()select()do()when()?:from()mul(778,261):,+,mul(314,222);,^what(190,985)select() ?*,[who()+:-mul(796,495)~/>do()<,}who()^mul(187,492)>'*$!what()mul(991,172)^&}:-mul(458,567)?mul(883,842)mul(755,150),!:%why()}mul(428,866)why()%why()where() (~:mul(352,708)what(370,596)$mul(898select()$why()~from()select()-when()mul(160,761)who(700,128)*mul(944,190)*#}^}from()where()mul(530,978):,+where()[?>mul(553,289)*$@/mul(286,141)what()@':~mulhow(116,291)%[mul(151,627)mul(362,891)~ %-/:%mul(275,35)@?&mul(276,797)who()/;who())why()when() ~)mul(400,219)where(757,508)}+'+>do()~?from()]~?why()${mul(674,313)]/!#select()^>how()&[do()mul(763,291)[?}>$:;]/ @]mul(923,77)+:/,mul(974,68)}^<}*?(mul(573,391)?^mul(882,854)what()(from(){%!@+when()mul(263,665)'%/<[who(257,651)mul(131,306)#+[why()&,@{who()!mul(378,207)mul(830,423)how(180,743)[<$-)}-don't()mul(104,63)'$~+)/!(do()(?*when()/<:mul(184,312)-mul(457,714)?how()&where():!<(who()mul(832,385)?;&>select(),'[}-mul(409,111)<'who()who()}what(39,120)!<(@mul(466,625))from()'{:;what(),mul(833,127)$+!]mul(107,815)/ {what()what()mul(37,91)[-, what(812,83)?&mul(376,103)};-mul(640,727)select()[$-mul(64,181)mul(734,97)&@why()<#select()/?/mul(164,82)mul(786,473)@{'}mul(206,560)&~mul(784,62)@*^+what():!from()^[mul(206,626)what()[(,{where()from()why()?who()mul(533,212)#where()+how()']}where()((mul(301,424):what()#what()@ >'!do()@what()mul(965,812)mul(3,550)from()who()!mul(965,728)#>#!)where()*)mul(497,530):when()#mul(352,808)!~{how()*!&mul(552,920)/where()+where()@-#/?mul(896,130)mul(347,579)~@ /^mul(727,709)#-how()&!&&@why()]mul(475,103)*how()/)~who()mul(542,160)mul(743,692)mul(561,997)why()mul(124,866)+}{why() mul(278,696)how()'what()$;?//where()when()mul(17,188)-+where()why();don't()--%<@why()+mul(356,107)%what()^,select()select(607,736):how()-mul(633,572)who()from()/;}select()mul(772,944)]@+/<]select()*?where()mul(858,850)(select()select()where()mul(181,712)~mul(979,178)#?}%?%do():who(268,689)*mul(941,59))-{&&(mul(296,702):@)where()don't()why()when(),mul(405,639)~$),who(575,232),%mul(671,828) \ No newline at end of file diff --git a/day_3/lexer.ts b/day_3/lexer.ts new file mode 100644 index 0000000..802a5d1 --- /dev/null +++ b/day_3/lexer.ts @@ -0,0 +1,50 @@ +export class Lexer { + str: string; + pos: number; + + constructor(str: string) { + this.str = str; + this.pos = 0; + } + + next(): string { + return this.str[this.pos++]; + } + peek(): string { + return this.str[this.pos]; + } + match(str: string): boolean { + if (this.str.slice(this.pos, this.pos + str.length) === str) { + this.pos += str.length; + return true; + } + return false; + } + matchDigit(): string { + if (/\d/.test(this.peek())) { + return this.next(); + } + return ""; + } + skipN(n: number) { + this.pos += n; + } + matchDigitN(min: number, max: number) { + const originalPos = this.pos; + let digits = ""; + for (let i = 0; i < min; i++) { + if (!/\d/.test(this.peek())) { + this.pos = originalPos; + return false; + } + digits += this.next(); + } + for (let i = 0; i < max - min; i++) { + if (!/\d/.test(this.peek())) { + break; + } + digits += this.next(); + } + return digits; + } +} \ No newline at end of file diff --git a/day_3/solve_1.ts b/day_3/solve_1.ts new file mode 100644 index 0000000..f2bf6fb --- /dev/null +++ b/day_3/solve_1.ts @@ -0,0 +1,54 @@ +import { Lexer } from "./lexer.ts"; + +const txt = await Deno.readTextFile("input.txt"); + + +const lexer = new Lexer(txt); + +function parseMulExpr( + lexer: Lexer, +){ + if (!lexer.match("mul(")) { + return null; + } + const left = lexer.matchDigitN(1,3); + if (!left) { + return null; + } + if (!lexer.match(",")) { + return null; + } + const right = lexer.matchDigitN(1,3); + if (!right) { + return null; + } + if (!lexer.match(")")) { + return null; + } + return { + type: "mul", + left: parseInt(left), + right: parseInt(right), + }; +} + +const exprs: { + type: string; + left: number; + right: number; +}[] = []; +while (lexer.pos < lexer.str.length) { + const expr = parseMulExpr(lexer); + if (expr) { + exprs.push(expr); + } + else { + lexer.next(); + } +} + +let sum = 0; +for (const expr of exprs) { + sum += expr.left * expr.right; +} +console.log(sum); \ No newline at end of file diff --git a/day_3/solve_2.ts b/day_3/solve_2.ts new file mode 100644 index 0000000..063aeb0 --- /dev/null +++ b/day_3/solve_2.ts @@ -0,0 +1,96 @@ +import { Lexer } from "./lexer.ts"; + +const txt = await Deno.readTextFile("input.txt"); + +const lexer = new Lexer(txt); + +type Expr = { + type: "mul"; + left: number; + right: number; +} | { + type: "do"; +} | { + type: "don't"; +} + +function parseMulExpr( + lexer: Lexer, +): Expr | null { + if (!lexer.match("mul(")) { + return null; + } + const left = lexer.matchDigitN(1,3); + if (!left) { + return null; + } + if (!lexer.match(",")) { + return null; + } + const right = lexer.matchDigitN(1,3); + if (!right) { + return null; + } + if (!lexer.match(")")) { + return null; + } + return { + type: "mul", + left: parseInt(left), + right: parseInt(right), + }; +} + +function parseDoExpr( + lexer: Lexer, +): Expr | null { + if (!lexer.match("do()")) { + return null; + } + return { + type: "do", + }; +} + +function parseDontExpr( + lexer: Lexer, +): Expr | null { + if (!lexer.match("don't()")) { + return null; + } + return { + type: "don't", + }; +} + +function parseExpr( + lexer: Lexer, +): Expr | null { + return parseDoExpr(lexer) ?? parseDontExpr(lexer) ?? parseMulExpr(lexer); +} + +const exprs: Expr[] = []; +while (lexer.pos < lexer.str.length) { + const expr = parseExpr(lexer); + if (expr) { + exprs.push(expr); + } + else { + lexer.next(); + } +} + +let sum = 0; +let enabled = true; +for (const expr of exprs) { + if (expr.type === "do") { + enabled = true; + } + else if (expr.type === "don't") { + enabled = false; + } + else if (enabled && expr.type === "mul") { + sum += expr.left * expr.right; + } +} +console.log(sum); \ No newline at end of file diff --git a/day_4/example.txt b/day_4/example.txt new file mode 100644 index 0000000..c41c5ea --- /dev/null +++ b/day_4/example.txt @@ -0,0 +1,10 @@ +MMMSXXMASM +MSAMXMSMSA +AMXSXMAAMM +MSAMASMSMX +XMASAMXAMM +XXAMMXXAMA +SMSMSASXSS +SAXAMASAAA +MAMMMXMMMM +MXMXAXMASX \ No newline at end of file diff --git a/day_4/example2.txt b/day_4/example2.txt new file mode 100644 index 0000000..a14c76e --- /dev/null +++ b/day_4/example2.txt @@ -0,0 +1,10 @@ +.M.S...... +..A..MSMS. +.M.S.MAA.. +..A.ASMSM. +.M.S.M.... +.......... +S.S.S.S.S. +.A.A.A.A.. +M.M.M.M.M. +.......... \ No newline at end of file diff --git a/day_4/input.txt b/day_4/input.txt new file mode 100644 index 0000000..ca9521b --- /dev/null +++ b/day_4/input.txt @@ -0,0 +1,140 @@ +MXMXMAMXAXMSMMMSSSXSSSMXXMSSXSMSASXSMXSAMXSMMMSMSMMSSXMSMSMSMMMSSMAAXSAMXSMSSMASAMMMSAMXSSSSSSSSXSAXMMMAXMMSSXMASXXSAXSXXAMXSSMSXMSAMXMAMAMX +SMMAMXMSAMXAAAAAXMAMXAMAASAMSXXXAXAXAASAMAAAAAAXMAAAMAMXAAMAAAAAAMMXMSXMASAAAMXMAMAMSAMXXAMAAAAAXMAMSASMXSAASASAXMAMXMASMASASAMXASXMSMSMSSSM +AMSMSMXXAAXXSMSSMMAMSXMASMASAMXMMMMMMMXAMASMMSSSSMMSSMMMSMSSSMMSSMXAASXMASMSMMASMMXXXMASMAMSMMMMMMXMSASMAMMSSXMSXMXMAMAMSAMXSAMSXMAMAAAAAAAA +MMMAAAMMSSSMXAXMAXAMXMXSAMXMAMSAAAAASMSSMMAAAAAAAMAMAMAAAAXMAMAMXMSMXSASMXXMASASAMXMASASMSMMAXXXMASMMMMMAASAXXXXMSAMASAXMXSXMAXMASXXASMSMMMS +XMMSMMAXAAAASAMASMMSMSMMMSSSXMAMXMMMSAAXAMXMMMSMMMASAMMMSSMXXMXXAXAMXSAMXXASAMXSAMAMMMMSAMASMMSMXMAXAAXMASMMMMSSMSASASMSMAMMAMMMAAMSMMAMXXXX +MXMXMASMMSMMMAMAMAAXAAAMAAMXMSSSSXSAXMASXMAXXAXXXXXMMSSXMAXAASMSMSASAMAMAMXMMMXSXSAMMMAMAMAMMAAASMMSSSSMXMASMMAAXSAMXS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AAMAMXMMMMSMXMXAMXAASMMMMMSASXSMSMMSASMMSMAXAMAMMMAXSAMSAMX +SASASXMMXAXXMXSSMXMAXSAMXMXMAMMSAMXXXXXSAMAAAMXMASAXAXSSSXSAMXSXAMMMMXSXXMXMMSSSSXSMSSXXAAAXAASMSMSMXMMMXAAMXMAXAAAAAMXAASMMSSMMMAMMXSAMMAMM +SASASMSSSMMSMMMAMMSAMAMSAMXSASAAASMMAXAMMSXMASAMAMMSSMMAAAMASAXMASAMSAMMSMMAAXAAAAXAMXMMSSSMXMSAAAXMXAAMSSXSSXAMSMMMSSSMMMMAAMASASMMAMSMXAMX +MAMMMAAAAXAAAASAMAMSSXMAXXMSASXMSAASAMXMASAXXAAMXSAAAAMMMMSAMXSAXSASMAMSAASMMSMMMMMAMXAAXAAAXXMMMSMSSMMMAMXXAMMXAAMAAXAXMAMMMSAMAXAMXSAMSXSX +MXMSMSMSMMSSSMSASAMXMASMXSXMAMXXMXXMXXMAMSAMXSMMMMMSSXMXXMAMXXSAMMMMMXMMSXMAMSXXMMSSMXSSMSMMXXSSXXAXAMXMASXMASXSSSMMSSSMSASAXMASXSSMMSXMSAMX \ No newline at end of file diff --git a/day_4/small_example.txt b/day_4/small_example.txt new file mode 100644 index 0000000..0a908e1 --- /dev/null +++ b/day_4/small_example.txt @@ -0,0 +1,5 @@ +..X... +.SAMX. +.A..A. +XMAS.S +.X.... \ No newline at end of file diff --git a/day_4/solve_1.ts b/day_4/solve_1.ts new file mode 100644 index 0000000..c0d14b6 --- /dev/null +++ b/day_4/solve_1.ts @@ -0,0 +1,57 @@ +const txt = await Deno.readTextFile("input.txt"); +const map = txt.split("\n").map((row) => row.trim().split("")); + +const dirs = [-1, 0, 1].flatMap((x) => ( + [-1, 0, 1].map((y) => [x, y]) +)).filter(([x, y]) => x != 0 || y != 0); + +function findXMASInPosDir( + map: string[][], + [x, y]: [number, number], + [dx, dy]: [number, number], +) { + const w = map[0].length; + const h = map.length; + const str = "XMAS"; + for (let i = 0; i < str.length; i++) { + // out of bounds + if (x < 0 || x >= w || y < 0 || y >= h) { + return false; + } + if (map[y][x] != str[i]) { + return false; + } + y += dy; + x += dx; + } + return true; +} + +function findXMASInPos(map: string[][], [x, y]: [number, number]) { + let count = 0; + for (const [dx, dy] of dirs) { + if ( + findXMASInPosDir(map, [x, y], [dx, dy]) + ) { + count++; + } + } + return count; +} + +function findXMAS(map: string[][]) { + const w = map[0].length; + const h = map.length; + + let count = 0; + for (let i = 0; i < h; i++) { + for (let j = 0; j < w; j++) { + if (map[i][j] == "X") { + count += findXMASInPos(map, [j, i]); + } + } + } + return count; +} + +console.log(findXMAS(map)); diff --git a/day_4/solve_2.ts b/day_4/solve_2.ts new file mode 100644 index 0000000..67ae9aa --- /dev/null +++ b/day_4/solve_2.ts @@ -0,0 +1,53 @@ +const txt = await Deno.readTextFile("input.txt"); +const map = txt.split("\n").map((row) => row.trim().split("")); + +function isOutOfBounds(map: string[][], [x, y]: [number, number]) { + const w = map[0].length; + const h = map.length; + return x < 0 || x >= w || y < 0 || y >= h; +} + +const patterns = [ + ["M", "M", "S", "S"], + ["M", "S", "M", "S"], + ["S", "M", "S", "M"], + ["S", "S", "M", "M"], +]; +const patternPositions = [ + [-1, -1], + [1, -1], + [-1, 1], + [1, 1], +]; + +function findXMasPatternInPos( + map: string[][], + [x, y]: [number, number], +) { + if (isOutOfBounds(map, [x, y])) { + return 0; + } + if (map[y][x] != "A") { + return 0; + } + let count = 0; + patterns.forEach((pattern) => { + for (let i = 0; i < pattern.length; i++) { + const [dx, dy] = patternPositions[i]; + const [nx, ny] = [x + dx, y + dy]; + if (isOutOfBounds(map, [nx, ny]) || map[ny][nx] != pattern[i]) { + return; + } + } + count++; + }); + return count; +} + +let count = 0; +for (let i = 0; i < map.length; i++) { + for (let j = 0; j < map[0].length; j++) { + count += findXMasPatternInPos(map, [j, i]); + } +} +console.log(count);