diff --git a/2024/day1/day1.py b/2024/day1/day1.py new file mode 100644 index 0000000..6f5bc01 --- /dev/null +++ b/2024/day1/day1.py @@ -0,0 +1,23 @@ +from collections import Counter + + +def main(lines): + firsts, seconds = list(sorted(x[0] for x in lines)), list(sorted(x[1] for x in lines)) + total = sum(abs(a - b) for (a, b) in zip(firsts, seconds)) + print("Part 1: ", total) + + counts = Counter(seconds) + total = sum(x * counts[x] for x in firsts) + print("Part 2: ", total) + + +if __name__ == "__main__": + + import sys + infile = sys.argv[1] + + with open(infile) as f: + lines = f.readlines() + lines = [list(map(int, x.rstrip().split())) for x in lines] + main(lines) + diff --git a/2024/day1/input.txt b/2024/day1/input.txt new file mode 100644 index 0000000..e142947 --- /dev/null +++ b/2024/day1/input.txt @@ -0,0 +1,1000 @@ +62619 25903 +30326 94750 +84092 60901 +37915 71402 +15035 84878 +18777 73294 +95618 11556 +40228 14340 +64337 95628 +74895 95628 +60933 57743 +63659 71402 +96094 71097 +83473 16153 +37963 81398 +28922 62792 +33312 56198 +33041 32752 +42401 98096 +91919 15189 +90401 91974 +59102 81363 +36684 83913 +77675 26541 +20021 57743 +60735 67798 +23105 29010 +86145 20180 +34121 42958 +45549 94750 +21335 97630 +30251 83564 +98372 27653 +60916 15189 +81588 93448 +31108 43699 +57324 77707 +62333 95456 +63344 70149 +18409 84619 +39611 51457 +60844 56450 +24661 20851 +83216 54572 +26451 13071 +40779 25903 +69948 80817 +80307 79233 +74779 15189 +51254 25615 +78563 21903 +44445 11964 +19525 66306 +59383 24932 +51882 27120 +15214 94897 +25903 62440 +19142 37258 +89958 55770 +93819 95582 +92302 60901 +92207 21547 +46605 72682 +47019 87607 +91181 18344 +33427 58733 +63738 67384 +58722 92349 +68791 62680 +37498 71342 +42522 37702 +36868 17661 +93701 66457 +59077 81363 +29985 32727 +97380 39888 +91074 51996 +34578 43591 +36474 76040 +83694 30713 +23025 21910 +65352 18691 +26765 46401 +29699 58503 +22892 42958 +33183 14340 +93681 94750 +87781 44627 +73912 61890 +69862 47551 +83666 50441 +14505 93279 +76546 60901 +85046 15189 +96647 63933 +20361 60901 +54414 74008 +73807 42958 +88028 37620 +47837 67798 +39975 79734 +59258 37388 +30532 95336 +63303 99491 +29900 77971 +18886 30672 +69149 16262 +71315 12428 +92786 77707 +81870 71402 +28377 80029 +38482 83084 +42311 43457 +40133 67348 +47350 58722 +94899 39437 +80383 73056 +50777 29099 +82097 66680 +57866 94991 +93259 95336 +83163 66970 +12322 68796 +86718 60901 +62860 16276 +61538 74693 +78862 71402 +71051 79270 +65274 94750 +95081 95454 +35994 69752 +23142 21903 +41794 28870 +81143 82713 +98552 53936 +42716 27120 +31949 81363 +24961 69060 +37205 12866 +53468 93380 +56879 73099 +68473 63243 +25609 86891 +63903 58722 +42541 42958 +95908 40858 +80056 74693 +23919 68796 +88345 37620 +47504 51825 +63031 43591 +83304 92302 +44174 18382 +53110 27120 +92382 57743 +95060 74693 +20870 31509 +38624 73935 +23048 21277 +71387 51004 +94750 71744 +86172 42002 +66293 20509 +17059 42958 +67035 10373 +75394 37620 +41855 43093 +23490 70386 +14833 60901 +17857 59270 +48666 62028 +19457 15189 +97382 74244 +59739 52959 +45275 92302 +15577 57743 +87651 18920 +98358 58538 +56785 68796 +17775 94456 +68554 36320 +85702 54050 +12351 64531 +75012 73099 +24159 72040 +14167 95347 +90037 27340 +57691 43591 +47008 18691 +10950 69642 +57987 23221 +77285 25903 +54353 19109 +75869 79832 +50446 46147 +84638 42958 +17751 60901 +67211 58733 +44169 48158 +91044 38933 +79885 11964 +78386 67798 +69398 72938 +21600 84819 +50224 81272 +78056 88646 +56837 31411 +39171 61608 +78080 43591 +54257 92150 +82021 15189 +19615 98246 +24648 76873 +45477 11964 +59179 59232 +66194 25903 +40847 58733 +34375 33041 +11740 67798 +94666 55770 +68611 91621 +91769 13515 +35492 58722 +84448 92302 +56613 62766 +99254 74693 +96650 10088 +39437 51388 +33069 91054 +52418 71402 +75251 80449 +31445 36392 +71195 53910 +72666 41650 +17608 95908 +12078 45665 +17604 64904 +78291 34090 +57437 57743 +91805 96758 +99250 95908 +64757 58722 +87843 64996 +88951 45003 +74539 77911 +58846 18920 +16307 94750 +69837 95908 +76898 40815 +16205 71402 +98688 46854 +69901 42958 +53438 34139 +19832 60901 +71402 55957 +38182 59508 +75973 52291 +63146 58733 +38891 52963 +83937 42855 +13073 58733 +25736 58733 +25961 91001 +98087 36622 +62673 45577 +81720 30395 +42981 58722 +99960 94750 +89819 73483 +46042 93254 +94494 58722 +90404 16308 +88078 95908 +59505 94750 +94839 18691 +51439 60901 +45408 94213 +46301 96771 +82342 95336 +87415 50494 +68995 18920 +69097 57463 +52090 76541 +57743 71402 +92558 26149 +33393 14340 +17956 77707 +93740 44925 +84324 81363 +99452 11104 +77578 58733 +23972 67830 +95336 94750 +96712 98246 +41647 76926 +74996 47307 +31798 81363 +84956 55640 +33185 57743 +74028 83220 +12168 40375 +27300 95908 +73132 82757 +11593 37620 +76794 99477 +53045 67798 +16203 67839 +43013 30796 +21653 66822 +99785 60901 +41534 99505 +34746 98777 +91326 15189 +41238 10056 +27120 89435 +61455 55770 +32332 12560 +74212 58722 +79815 43591 +51266 24297 +29290 42582 +32564 81503 +33451 58722 +74693 44992 +90825 95908 +18434 37620 +51381 69567 +51357 80756 +41367 42958 +18034 87111 +35090 48309 +52050 19848 +31615 18691 +26163 55382 +54155 98380 +32766 95628 +66811 70762 +56835 74954 +68966 98773 +64000 80941 +17133 28149 +46113 11964 +44129 95908 +75450 11493 +33226 67397 +61957 64071 +75928 43095 +93920 67730 +65403 24083 +43381 95908 +81291 46446 +41878 68263 +92914 41085 +34436 57743 +79389 40570 +56226 23464 +79465 94750 +30601 22367 +74416 85052 +69119 20905 +78029 31117 +56600 20434 +88792 76040 +70653 15946 +26166 44783 +29517 60996 +85852 80100 +39106 11294 +77438 83568 +37856 46541 +58097 37572 +83261 77394 +71449 21903 +15327 71144 +66853 18920 +76787 51780 +62338 39437 +97231 72705 +93048 20279 +45014 58733 +48454 25802 +16977 52014 +24139 15189 +97186 68796 +63132 55770 +28951 95908 +52068 94750 +92193 25450 +94762 68225 +94439 75090 +49183 76040 +15650 72780 +43617 25654 +48000 57743 +44802 20665 +69533 40698 +99506 71402 +10188 81093 +45642 12405 +41525 95628 +63406 58722 +38086 82686 +78248 92302 +35534 25903 +40908 60096 +34570 54450 +50290 20272 +49022 76863 +69525 15189 +77707 77671 +72455 71402 +26834 55770 +68910 42924 +54344 16132 +67895 92302 +74034 55770 +29963 11964 +28687 48072 +47125 58722 +15698 23211 +25279 33041 +35856 58733 +29506 92630 +83164 58503 +25652 43591 +10150 60901 +68681 75492 +25928 62173 +90996 60901 +34150 25903 +45505 24919 +32302 16979 +70135 60901 +47220 38697 +66939 18691 +60367 74693 +46402 54059 +37333 38708 +15675 56777 +94947 64270 +92421 64575 +18644 18920 +85453 55949 +24398 25465 +51537 60901 +73029 18691 +10372 21582 +13221 60772 +96312 48448 +41962 18894 +95628 25903 +86774 67798 +97328 94768 +12739 83965 +35805 55770 +71377 51057 +27624 21704 +47608 15189 +33867 40404 +97161 68446 +20645 11768 +14224 78983 +62080 95908 +19102 75534 +63525 59254 +17179 68796 +98286 45885 +34018 97839 +99672 15422 +76115 25674 +51884 85901 +34047 27120 +29743 21903 +93768 76389 +97460 34263 +19836 94750 +83921 86722 +65076 81363 +79604 45182 +73999 95908 +51995 44729 +46824 23356 +76384 95908 +45206 95435 +48366 72348 +37898 82291 +31126 58733 +22018 83516 +12071 67798 +83202 27120 +56135 58733 +75630 37620 +14382 65093 +45237 50541 +25430 29954 +28105 70054 +67794 58722 +35237 21506 +38802 62056 +60276 31607 +35441 47957 +16202 21963 +86355 16631 +73689 21903 +69007 30198 +45510 98246 +85154 11881 +62930 58733 +70284 37620 +49335 84284 +81363 88599 +59481 25903 +45212 47786 +15302 95908 +45855 37620 +88386 92865 +11859 37620 +73264 60901 +83068 42996 +84915 76266 +17696 95628 +14367 52703 +30852 76040 +71184 78571 +42578 22158 +41197 33041 +96461 98246 +97118 60120 +77919 13391 +11964 71571 +75993 93850 +76867 23238 +22690 95908 +23262 37620 +25242 25903 +73440 44034 +98379 41045 +15645 53820 +55979 45441 +98508 64885 +34278 91871 +92424 21903 +99804 27550 +98275 39480 +77311 66522 +71457 71402 +45125 58722 +46725 31005 +11667 35829 +88568 38127 +84705 93869 +49426 58722 +95141 37826 +60901 17434 +51036 13775 +66121 55476 +99712 76291 +64183 76040 +14340 42364 +41256 42609 +88529 38809 +24137 86477 +50030 84350 +28692 39437 +76103 18691 +55768 95504 +81529 82684 +32989 68796 +62430 57117 +47161 95628 +98041 77707 +17293 60901 +26322 25201 +18691 68796 +53748 27211 +79920 61870 +13414 98246 +37753 42958 +99192 43795 +47951 78295 +65705 80132 +93270 18691 +49617 22313 +58116 68802 +41599 77917 +88070 73053 +57636 74708 +61320 55770 +28126 68211 +45326 68796 +83242 78622 +64432 95336 +66184 14776 +79662 78288 +31559 31202 +55770 37957 +23887 14766 +42104 12084 +86533 73495 +66370 77751 +90530 95628 +95401 43591 +43376 95257 +70768 58733 +12478 71571 +15957 17223 +81250 57743 +60475 10079 +40232 74136 +19774 97772 +18621 16958 +14875 76440 +90673 30928 +23096 58503 +97595 45435 +73191 42958 +81767 97406 +54334 56241 +27617 47748 +74196 73890 +83232 16958 +75027 74693 +80951 58733 +34912 42958 +85763 46782 +46474 94750 +66031 90078 +84048 71118 +94904 37620 +65760 66261 +85805 41397 +71175 16972 +48344 75703 +13102 88952 +42495 95358 +26249 18691 +19568 58733 +31959 55770 +55075 71571 +32241 88856 +94349 14340 +15189 16227 +28021 74374 +13676 33041 +59997 24406 +54305 41257 +37110 55770 +35881 32739 +21529 12177 +79138 42450 +29787 24438 +34894 68796 +21203 81363 +56933 66257 +95760 97152 +60050 94750 +41753 34287 +39341 95186 +49927 42958 +74695 31124 +57847 92741 +20288 98129 +51699 52019 +19072 68796 +82231 43640 +60534 20761 +10461 58503 +36149 27120 +96959 79965 +77827 60351 +91876 56195 +25787 60363 +86997 67798 +68922 46729 +19622 81363 +66080 91186 +27682 55770 +25942 65557 +89459 14340 +79797 74254 +96138 98246 +33238 59314 +30173 67798 +95078 68796 +54586 39437 +75238 37620 +39202 29637 +16867 19899 +82302 53887 +45302 27732 +30954 95908 +83543 98246 +54381 95336 +34144 12236 +17402 90976 +92020 71571 +62781 15189 +29546 99770 +11926 90890 +69879 68796 +76480 16106 +33328 50342 +58455 58733 +86164 14225 +33489 92807 +76961 26383 +77335 89466 +26454 94750 +67798 52555 +92671 42002 +23218 60901 +58564 34904 +19943 11014 +16341 11964 +35741 37620 +25711 95628 +70338 23595 +73099 14679 +40606 57743 +79029 84965 +40776 84207 +57543 57743 +55122 67798 +54036 89387 +34686 95336 +78969 19676 +93072 27772 +81688 14502 +18807 15639 +70774 57743 +87430 74693 +91599 26911 +37620 39437 +61886 71402 +58325 62504 +42822 33723 +67981 95908 +48046 77843 +45220 45628 +78085 33041 +46449 58722 +98918 59087 +32267 76647 +31728 27120 +15735 10521 +57336 58733 +86936 74693 +73719 50149 +84110 74693 +31202 27513 +68796 77160 +58416 69672 +57865 37620 +71850 50968 +53522 77707 +21173 42834 +92464 92615 +29744 37620 +52306 22486 +98899 16166 +22476 91919 +59967 19305 +43591 36485 +31809 63171 +79033 56343 +67656 98246 +13587 95822 +27782 42530 +19352 22300 +96569 42958 +95188 73716 +85777 27120 +76336 25264 +11596 51174 +62131 35355 +32737 87896 +21792 94314 +97535 42958 +67772 30847 +23372 10581 +91532 33811 +55873 74693 +36678 12576 +45099 73044 +43192 55240 +21903 55521 +88321 67798 +24368 39437 +79046 21903 +22881 95336 +41519 18920 +33709 68796 +72476 25903 +58512 27120 +86413 14340 +72964 16152 +96531 19099 +98791 73099 +17155 90626 +42612 27830 +55602 12838 +25290 30145 +59246 42958 +66301 29947 +36333 96445 +24171 58722 +87662 10983 +42958 71773 +58636 68421 +98695 25903 +87852 33041 +74343 57743 +39643 33041 +85380 27500 +48388 42958 +37761 77707 +97130 37620 +43580 38826 +47926 98004 +90396 18691 +45920 71402 +81997 71402 +94726 94750 +48358 27344 +71254 22993 +80275 34237 +72241 72611 +34532 68796 +55121 34876 +29318 57743 +75556 21903 +91485 21903 +58503 37620 +76040 58722 +64723 58001 +66467 95336 +53823 12613 +48859 61366 +76368 18920 +26043 94750 +60819 43935 +49793 74693 +49787 20795 +23373 58699 +69380 73099 +75462 63798 +45493 77707 +33090 98246 +40903 27639 +96473 76040 +89947 55467 +97538 76040 +94950 97842 +83847 64791 +51408 85287 +90641 25175 +59205 68796 +37106 21903 +31891 69062 +52732 21031 +16958 21903 +12830 12782 +88886 21500 +96198 96776 +10176 25136 +71571 42958 +16588 60751 +49639 94413 +94373 37620 +57909 42958 +23337 70169 +40204 10854 +51290 89920 +57936 61689 +52963 95336 +78553 55770 +28898 94685 +56962 20975 +98246 27120 +13251 31202 +12386 16958 +44211 44328 +51354 95336 +51903 84162 +74681 67073 +78792 46321 +47448 76040 +54001 41269 +83049 71402 +18666 88848 +91604 77707 +18218 74693 +70012 74693 +64340 15653 +61733 94750 +53459 25903 +89495 48179 +50543 14337 +53778 68796 +19573 76040 +48966 37491 +79009 65520 +75853 64389 +72020 55770 +85683 36279 +14091 95628 +81225 85177 +20253 99653 +83272 12892 +80793 74693 +60228 51271 +25762 30744 +45133 41216 +20563 87233 +58733 68796 +18187 58733 +27577 74693 +19450 72555 +54043 43176 +48494 42958 +88375 99208 +72864 49040 +23351 45233 +89758 20480 +11846 71402 +71123 37789 +85916 73099 +26278 42958 +45147 40390 +47700 94750 +71287 43591 +21893 95628 +30860 91205 +88771 25107 +63695 15189 +54022 78028 +18920 18691 +54215 53466 +37444 55606 +33508 79502 +51867 25903 +11633 73099 +95809 57743 +59336 58775 +92131 73399 +80096 28127 +92889 37549 +58711 16441 +56446 95908 +78562 16751 +87872 94750 +81757 64583 +94079 25109 +57657 60516 +87129 85261 +24276 41375 +58930 42002 +99351 74693 +49268 42002 +42002 64504 +81164 30052 +33506 60901 +54186 99255 +84054 85285 +63793 71402 +84019 21903 +12310 27120 +37386 33041 +72232 52481 +50872 43591 +88150 39972 +36699 31090 +11657 88797 +66278 81363 +20963 61397 +12046 55357 +81706 82079 +39853 71402 +59229 21903 +29455 80276 +14789 15466 +51944 81395 +26965 60546 +74750 55770 +80093 74559 +40585 65129 +79995 14340 +91325 69036 +36866 32940 +96216 67016 +45649 43967 +63836 21903 +57153 67798 +65895 27120 +41014 58733 +81492 95336 +55192 94646 +74304 65351 +91142 74386 +61587 43591 diff --git a/2024/day2/day2.py b/2024/day2/day2.py new file mode 100644 index 0000000..56bd9fa --- /dev/null +++ b/2024/day2/day2.py @@ -0,0 +1,36 @@ +from itertools import pairwise + + +def is_safe(report): + diffs = [b - a for a, b in pairwise(report)] + return all(1 <= d <= 3 for d in diffs) or all(-3 <= d <= -1 for d in diffs) + + +def is_safe_with_problem_damper(report): + for i, _ in enumerate(report): + copy = report[::] + del copy[i] + if is_safe(copy): + return True + return False + + +def main(reports): + safe_reports = sum(1 for x in reports if is_safe(x)) + print("Part 1: ", safe_reports) + + safe_reports = 0 + for report in reports: + if is_safe_with_problem_damper(report): + safe_reports += 1 + print("Part 2: ", safe_reports) + + +if __name__ == "__main__": + import sys + infile = sys.argv[1] + with open(infile) as f: + lines = f.readlines() + lines = [list(map(int, x.rstrip().split())) for x in lines] + main(lines) + diff --git a/2024/day2/example.txt b/2024/day2/example.txt new file mode 100644 index 0000000..b49c10d --- /dev/null +++ b/2024/day2/example.txt @@ -0,0 +1,6 @@ +7 6 4 2 1 +1 2 7 8 9 +9 7 6 2 1 +1 3 2 4 5 +8 6 4 4 1 +1 3 6 7 9 diff --git a/2024/day2/input.txt b/2024/day2/input.txt new file mode 100644 index 0000000..a4d9c2f --- /dev/null +++ b/2024/day2/input.txt @@ -0,0 +1,1000 @@ +6 8 11 12 14 16 18 16 +73 76 79 80 81 84 86 86 +32 33 34 37 40 44 +9 11 13 14 17 24 +59 61 64 62 65 +33 36 37 39 36 35 +60 62 64 61 62 64 64 +12 15 16 15 17 18 22 +72 73 75 77 79 82 79 85 +60 61 64 64 67 69 +44 45 45 46 48 50 52 51 +9 11 11 13 14 14 +3 5 8 11 11 15 +48 51 52 52 53 54 59 +76 77 80 84 86 87 +30 32 33 35 38 42 41 +91 92 93 97 97 +59 61 63 67 69 73 +59 60 64 67 68 73 +28 30 31 36 39 42 +26 29 32 34 40 39 +64 65 67 74 75 78 79 79 +49 52 59 61 65 +34 35 42 43 44 51 +12 10 11 14 17 18 20 21 +68 67 70 73 71 +80 79 80 81 84 86 88 88 +60 58 60 61 62 66 +14 12 13 14 17 18 21 28 +24 21 24 26 25 26 +30 29 32 35 37 34 33 +45 42 41 44 44 +55 52 49 52 55 58 59 63 +10 9 11 14 16 14 17 24 +44 42 43 44 45 45 48 51 +53 52 52 55 53 +42 39 42 43 45 45 48 48 +86 83 83 86 90 +7 4 7 8 8 11 18 +58 55 56 59 63 66 68 70 +77 75 79 81 78 +93 90 93 97 97 +13 12 16 18 22 +42 40 42 45 46 47 51 58 +18 15 16 22 24 25 +22 20 26 27 30 33 35 33 +40 39 44 45 45 +36 34 39 42 45 46 50 +39 37 44 46 49 54 +31 31 32 33 36 39 40 42 +6 6 7 10 11 14 16 14 +20 20 22 23 26 28 30 30 +50 50 52 55 57 61 +11 11 14 15 20 +89 89 91 89 90 +38 38 41 43 44 47 44 41 +35 35 36 33 33 +76 76 79 82 85 82 85 89 +31 31 32 30 33 40 +38 38 40 40 41 +85 85 85 87 86 +44 44 45 48 51 51 52 52 +57 57 58 58 59 60 61 65 +22 22 24 24 27 32 +59 59 62 66 68 +17 17 20 24 27 30 28 +49 49 50 51 53 57 59 59 +48 48 49 53 57 +46 46 47 48 51 55 61 +51 51 57 59 61 64 67 70 +42 42 44 50 52 49 +75 75 80 81 81 +8 8 13 15 17 21 +22 22 23 24 27 34 37 44 +75 79 80 82 85 88 +67 71 73 75 77 76 +8 12 14 15 15 +17 21 24 25 27 31 +47 51 54 55 58 65 +66 70 72 71 72 +30 34 37 35 38 36 +60 64 65 64 65 67 67 +72 76 77 76 79 83 +20 24 25 28 29 31 29 36 +36 40 43 44 47 49 49 52 +15 19 21 24 24 22 +77 81 83 84 84 86 89 89 +46 50 52 52 56 +17 21 22 22 27 +75 79 81 85 87 90 +7 11 13 17 15 +27 31 33 37 37 +34 38 41 45 49 +69 73 74 78 85 +14 18 25 27 28 30 31 33 +24 28 29 34 37 36 +56 60 67 70 70 +35 39 42 48 51 52 56 +74 78 80 85 92 +47 54 55 58 60 63 65 67 +83 89 92 95 94 +32 38 41 43 43 +38 45 48 50 54 +54 61 62 65 67 69 76 +76 83 84 85 82 84 +69 75 78 81 78 75 +7 13 16 18 15 15 +46 52 55 57 56 60 +74 80 83 84 81 82 89 +43 49 49 51 53 +82 87 87 90 91 88 +42 49 49 51 51 +24 30 33 36 37 37 41 +37 42 43 43 45 46 51 +67 73 77 80 83 86 +29 34 37 41 42 44 46 45 +55 62 66 68 69 70 73 73 +20 26 28 32 36 +33 40 42 46 47 54 +58 65 68 69 76 78 +60 65 66 72 70 +46 52 59 62 63 65 65 +61 67 68 70 75 78 82 +52 58 60 67 73 +81 78 76 74 73 71 73 +78 75 72 71 70 67 67 +17 16 15 12 11 9 5 +53 50 48 45 44 41 38 31 +99 96 98 97 96 94 +39 37 35 33 32 31 34 36 +27 25 22 24 24 +48 47 45 42 43 42 38 +95 93 90 93 87 +92 89 88 85 85 82 80 78 +64 62 61 60 60 58 55 57 +79 77 75 74 71 71 71 +91 89 88 88 87 83 +36 34 34 32 27 +47 45 42 38 36 +68 67 63 62 59 57 56 57 +61 60 56 54 52 50 47 47 +40 39 35 33 29 +75 72 71 67 65 63 58 +93 90 84 82 79 76 74 71 +78 77 75 72 71 69 62 64 +44 41 36 33 30 28 28 +35 32 29 24 23 22 18 +60 57 52 51 45 +24 25 24 22 21 18 15 13 +43 45 42 39 36 33 34 +71 73 72 69 67 64 63 63 +19 22 20 19 16 12 +43 45 43 40 38 31 +38 39 38 36 37 36 34 33 +53 54 56 55 58 +76 78 75 78 76 73 73 +70 71 70 72 70 69 66 62 +73 74 72 70 68 69 64 +97 98 96 95 93 90 90 87 +42 44 41 40 39 39 37 40 +52 54 51 50 47 46 46 46 +85 88 86 86 83 82 79 75 +85 88 86 84 81 79 79 72 +75 78 76 72 71 68 66 +29 31 30 27 25 21 19 22 +47 48 47 44 40 40 +58 61 57 55 51 +68 70 68 64 61 56 +81 82 77 75 73 70 +53 56 53 50 43 41 38 39 +20 23 21 18 15 9 8 8 +66 69 66 60 56 +48 50 47 44 38 36 34 29 +67 67 66 64 63 60 +83 83 82 81 84 +63 63 61 59 59 +64 64 62 61 57 +75 75 74 73 72 70 69 62 +76 76 75 74 72 70 71 68 +70 70 68 69 67 65 62 64 +6 6 5 4 5 2 2 +16 16 19 16 14 13 9 +34 34 33 31 28 25 27 21 +28 28 28 26 23 21 20 +20 20 20 18 17 14 12 15 +63 63 60 60 60 +28 28 28 26 22 +36 36 36 35 33 28 +82 82 78 77 74 71 +62 62 59 57 55 51 52 +41 41 39 35 35 +34 34 30 27 24 20 +97 97 95 91 86 +79 79 72 69 68 65 64 +52 52 49 47 44 38 40 +56 56 50 49 48 45 45 +97 97 94 87 86 85 82 78 +97 97 95 89 86 83 82 76 +24 20 17 16 15 13 11 +52 48 47 46 48 +21 17 15 12 10 10 +27 23 20 18 17 13 +57 53 52 51 50 48 46 40 +87 83 82 83 80 +99 95 97 96 97 +97 93 91 88 90 90 +90 86 83 85 81 +49 45 42 44 41 38 31 +15 11 10 10 8 +96 92 92 90 89 87 86 88 +18 14 14 13 12 11 11 +21 17 15 14 13 12 12 8 +86 82 80 78 78 77 72 +74 70 67 64 60 57 54 53 +46 42 39 38 34 33 36 +52 48 46 44 40 40 +40 36 33 32 29 25 24 20 +92 88 84 82 77 +28 24 22 15 12 11 +71 67 66 65 58 55 58 +89 85 84 81 78 72 71 71 +42 38 32 31 28 26 24 20 +87 83 81 74 68 +69 62 59 58 55 52 +95 90 88 86 84 81 78 81 +45 39 38 36 34 33 33 +84 78 75 74 71 67 +61 55 54 52 51 48 46 40 +58 51 49 47 44 42 45 42 +37 32 29 30 28 29 +64 58 59 56 56 +76 70 68 67 65 66 62 +55 49 46 48 47 44 43 38 +88 82 81 81 78 +98 91 90 87 84 84 83 85 +95 88 85 85 85 +79 73 70 67 67 63 +50 43 41 38 38 36 29 +17 12 11 7 4 +31 25 21 18 15 13 16 +98 92 91 88 86 82 82 +61 54 51 47 43 +96 89 88 84 78 +44 38 36 34 29 26 +98 93 92 85 83 82 85 +73 67 66 65 59 58 58 +30 25 23 21 14 12 8 +68 62 59 53 48 +3 6 8 10 13 16 19 16 +48 51 53 54 57 60 60 +34 36 39 40 41 45 +2 3 5 7 8 11 16 +28 29 30 29 30 33 +43 44 47 50 49 47 +77 80 82 83 86 83 85 85 +50 52 54 56 58 57 59 63 +32 33 35 33 38 +67 68 69 69 70 +77 80 80 83 82 +69 71 74 76 76 78 79 79 +15 16 17 17 19 22 24 28 +50 52 53 56 58 58 64 +80 81 85 87 88 90 93 +42 44 45 48 52 50 +9 10 13 15 19 22 22 +34 36 40 41 44 47 50 54 +74 75 78 80 83 87 89 96 +78 81 87 89 91 +2 4 11 12 14 15 18 17 +57 58 59 60 62 63 70 70 +49 51 54 57 64 65 67 71 +8 9 15 16 21 +50 48 49 50 53 56 +97 94 97 98 95 +5 2 3 6 9 9 +12 9 11 13 14 18 +84 82 83 86 88 89 90 95 +83 80 81 84 87 86 88 +24 21 22 25 24 25 22 +99 97 96 97 97 +13 12 15 14 15 17 21 +87 85 88 86 93 +9 8 11 12 15 17 17 19 +31 28 30 32 32 29 +49 48 51 51 51 +62 60 60 63 66 70 +78 75 76 79 80 81 81 88 +39 36 38 41 43 45 49 51 +94 92 96 98 99 97 +75 74 78 81 84 84 +16 14 16 19 23 24 27 31 +51 48 49 53 55 60 +38 36 39 41 42 45 51 53 +68 65 66 73 74 72 +34 31 38 39 41 41 +25 24 29 31 33 36 40 +12 9 15 16 23 +21 21 22 23 25 +83 83 84 87 86 +76 76 78 80 83 85 86 86 +66 66 68 71 74 78 +86 86 88 91 97 +65 65 66 63 66 67 68 70 +76 76 74 77 80 79 +47 47 48 45 48 48 +37 37 38 41 40 44 +62 62 60 61 67 +57 57 57 60 61 64 66 68 +34 34 36 38 38 35 +31 31 32 34 37 37 38 38 +22 22 22 24 28 +71 71 71 73 74 80 +52 52 53 57 58 60 63 +42 42 45 46 50 48 +47 47 48 49 50 51 55 55 +46 46 49 51 55 57 60 64 +45 45 46 50 56 +60 60 66 68 70 73 +84 84 85 91 93 95 94 +11 11 12 17 18 18 +25 25 26 33 37 +29 29 36 38 45 +41 45 46 49 52 +13 17 19 21 23 26 28 26 +16 20 22 24 24 +82 86 88 89 90 94 +28 32 33 36 37 39 44 +33 37 38 37 39 +24 28 27 29 26 +11 15 18 19 17 19 21 21 +65 69 70 73 72 74 78 +64 68 66 67 70 73 80 +63 67 70 70 71 73 76 +74 78 80 80 82 79 +46 50 52 52 55 56 56 +14 18 21 21 22 26 +15 19 20 23 23 28 +45 49 50 52 56 59 62 65 +12 16 19 23 21 +38 42 43 47 50 50 +60 64 67 70 74 75 79 +49 53 56 57 59 62 66 73 +54 58 64 65 68 69 70 +47 51 57 59 58 +17 21 28 29 31 34 34 +9 13 19 22 25 27 30 34 +22 26 27 29 31 36 37 43 +71 76 78 80 83 84 86 87 +43 49 52 54 55 56 53 +27 32 33 36 38 41 43 43 +7 13 16 17 21 +41 47 50 51 57 +45 51 52 53 54 55 53 56 +78 83 85 87 86 89 86 +15 22 23 25 24 24 +56 62 65 63 64 68 +3 10 12 14 11 18 +52 58 58 59 60 63 65 +80 85 88 89 89 91 92 91 +35 41 41 43 46 46 +2 8 10 13 13 16 17 21 +52 59 59 61 64 66 67 72 +42 47 50 51 52 56 59 62 +3 10 13 15 16 20 18 +59 66 70 72 75 78 78 +27 33 35 38 40 44 48 +35 40 43 47 53 +49 54 57 63 65 68 71 +40 47 50 56 57 60 57 +9 16 17 20 23 29 29 +9 14 17 18 24 25 26 30 +49 56 58 59 61 68 70 75 +31 28 25 23 20 18 20 +44 42 39 36 33 31 29 29 +16 15 14 12 9 7 3 +35 34 32 30 28 27 22 +98 96 94 97 94 93 +82 80 79 82 80 79 82 +80 78 81 80 80 +39 36 37 36 32 +24 22 20 19 18 19 16 10 +71 69 66 63 61 61 58 56 +72 71 68 67 66 66 68 +99 97 94 91 90 90 88 88 +90 87 84 83 83 80 79 75 +73 70 67 66 64 61 61 56 +20 18 17 15 12 8 6 +66 63 60 59 55 58 +30 27 24 21 17 17 +90 88 87 86 82 80 76 +76 74 72 68 67 64 57 +90 89 88 83 82 +64 61 59 56 54 47 48 +23 20 19 17 16 10 7 7 +44 42 36 35 31 +52 51 50 44 37 +56 58 57 55 54 52 +5 8 7 6 5 7 +26 28 27 25 23 21 19 19 +30 32 29 26 24 22 21 17 +29 30 29 26 23 22 17 +80 81 80 81 80 78 76 75 +85 87 85 83 85 86 +70 72 70 68 69 68 68 +45 48 51 48 44 +43 46 44 45 44 41 39 34 +40 42 39 36 34 34 33 32 +73 75 75 74 71 70 71 +29 31 29 28 28 28 +18 19 16 16 12 +11 14 13 11 11 8 1 +91 92 88 86 85 82 81 +59 62 58 56 57 +8 10 9 5 5 +96 99 97 95 93 91 87 83 +22 23 19 18 16 15 8 +65 66 64 59 58 56 54 52 +18 21 18 15 9 8 5 8 +53 54 49 48 47 46 46 +53 54 47 45 41 +73 75 74 73 72 66 65 60 +16 16 14 11 8 5 +43 43 40 38 37 36 38 +19 19 17 14 14 +85 85 82 81 79 75 +83 83 81 78 75 72 66 +45 45 43 46 43 40 +9 9 6 7 10 +93 93 92 91 90 93 93 +16 16 17 14 13 12 10 6 +12 12 9 8 7 9 7 2 +88 88 87 87 85 83 80 77 +9 9 6 5 4 2 2 3 +99 99 99 97 95 95 +56 56 54 52 49 49 48 44 +56 56 56 53 46 +52 52 49 45 43 40 39 +99 99 97 95 91 90 87 89 +46 46 45 43 42 40 36 36 +87 87 84 80 76 +72 72 69 65 59 +44 44 42 37 34 31 30 +90 90 87 85 79 82 +56 56 55 49 46 43 42 42 +16 16 13 7 3 +52 52 51 49 46 43 36 30 +73 69 67 65 63 62 61 60 +36 32 30 28 31 +68 64 62 61 58 55 54 54 +14 10 8 7 5 1 +58 54 51 48 45 43 42 35 +34 30 27 30 29 26 24 +81 77 76 73 74 77 +32 28 25 23 24 24 +47 43 42 40 39 40 36 +18 14 15 14 9 +44 40 38 38 37 +84 80 77 77 79 +84 80 79 79 77 77 +18 14 14 13 10 6 +86 82 80 80 73 +80 76 72 70 67 66 +35 31 30 27 23 20 23 +79 75 72 68 66 66 +57 53 52 49 48 47 43 39 +65 61 59 56 52 47 +66 62 55 52 51 48 45 +35 31 30 28 21 20 18 21 +88 84 82 76 74 74 +88 84 82 79 72 70 69 65 +85 81 75 72 65 +18 13 10 9 7 6 +52 45 44 41 40 38 41 +76 71 69 67 65 65 +40 33 31 28 24 +99 92 89 86 83 81 74 +77 71 68 69 68 67 +72 65 62 65 63 61 62 +52 45 48 46 43 43 +97 91 92 91 87 +32 25 24 21 22 17 +89 84 81 79 76 74 74 73 +91 84 84 82 83 +90 84 84 82 82 +71 66 64 64 61 57 +35 28 25 23 21 21 20 15 +95 90 88 84 83 +34 27 24 22 19 15 17 +61 54 53 51 47 46 43 43 +36 29 27 25 22 21 17 13 +53 46 43 39 33 +33 27 25 18 16 13 10 8 +43 38 31 29 28 30 +81 74 68 66 63 63 +82 75 70 67 64 60 +34 27 26 21 14 +71 73 76 79 80 83 87 +39 43 43 46 48 47 +45 46 45 48 46 44 42 42 +78 73 72 70 66 64 63 64 +15 15 14 13 15 13 9 +86 86 90 92 93 94 97 97 +83 76 75 71 66 +77 81 82 85 87 84 +44 45 42 39 36 35 35 +34 31 29 26 23 24 +10 7 9 11 9 10 14 +21 16 9 8 6 9 +28 28 29 31 32 36 +81 77 76 71 70 69 68 61 +33 37 41 42 39 +68 62 59 55 52 +63 67 69 71 77 80 80 +54 54 51 48 47 45 42 +23 26 23 17 16 14 16 +87 90 89 87 87 80 +67 60 59 57 53 +80 81 78 74 71 +16 16 18 21 22 24 24 +1 1 4 10 14 +59 59 62 63 69 76 +63 67 69 70 72 78 82 +34 28 25 22 23 22 15 +31 25 24 24 23 21 24 +55 56 54 51 48 42 40 +82 80 84 86 93 +71 71 69 67 66 62 +81 85 88 91 93 96 93 96 +37 33 32 29 29 23 +79 86 88 91 98 +61 67 67 70 72 73 78 +55 51 48 43 45 +65 66 65 62 64 62 55 +57 53 51 50 53 55 +75 69 66 69 68 66 62 +45 47 48 48 49 51 53 53 +52 52 55 60 60 +69 65 62 62 61 58 55 51 +30 36 39 42 44 44 46 +16 16 14 13 11 12 +20 24 28 31 31 +92 88 82 81 79 75 +32 38 40 43 45 46 46 +55 54 53 56 55 51 +44 44 47 47 49 +83 83 79 78 77 73 +83 78 76 74 73 66 66 +61 62 63 64 69 76 +85 90 93 97 98 +19 22 20 19 18 +72 71 73 75 75 78 83 +25 28 26 25 24 19 +35 38 34 32 28 +74 77 79 82 81 82 +55 54 59 61 63 +72 73 70 67 65 64 67 +66 62 59 56 55 53 47 +71 71 74 74 76 77 82 +8 10 11 14 15 17 20 22 +41 43 44 47 49 51 53 56 +48 50 51 54 56 +77 74 71 69 68 +5 6 8 11 12 13 +41 40 37 36 34 31 28 +22 19 18 16 14 +60 58 57 56 54 52 51 50 +29 31 32 34 35 36 37 +15 18 21 22 25 +84 82 80 79 76 73 70 +40 37 34 31 29 27 26 24 +27 29 31 32 34 37 40 41 +98 97 95 92 89 86 85 +14 17 20 21 23 24 +15 16 19 20 21 23 25 28 +8 10 13 16 17 19 21 24 +58 59 62 63 66 69 72 +15 14 13 10 9 +36 37 40 42 44 46 49 52 +40 38 37 34 32 31 29 27 +1 2 4 5 8 +16 19 21 22 23 25 28 +6 9 11 14 15 17 19 21 +71 73 74 75 76 79 82 +74 72 70 67 64 +14 12 10 8 7 6 +85 86 88 90 92 94 95 +23 21 20 18 17 15 12 11 +30 33 35 37 39 42 +54 57 59 62 65 66 +83 85 87 89 92 94 96 98 +23 24 26 28 30 33 +87 88 91 94 96 99 +85 83 81 79 78 75 +99 97 96 95 93 90 89 88 +4 5 7 10 11 12 13 14 +67 69 71 74 77 +29 26 24 22 20 19 16 +15 14 13 11 9 7 +49 48 45 42 40 38 36 33 +98 96 93 90 87 85 84 83 +2 3 6 8 11 12 15 17 +73 72 70 68 67 66 65 +14 11 8 6 4 2 +18 19 20 23 24 25 26 28 +75 72 71 69 66 64 62 +17 18 21 22 25 +69 71 74 76 78 +51 49 48 45 43 41 39 37 +66 63 60 58 55 54 51 +91 93 95 97 98 +35 32 31 28 25 +43 41 40 37 34 32 30 28 +72 69 67 64 61 60 +80 82 83 86 87 90 +34 37 39 42 45 47 48 +38 40 43 45 48 49 +37 39 42 45 46 48 50 51 +91 93 96 97 99 +9 6 5 3 1 +63 64 66 68 71 74 77 +41 43 44 45 46 48 +3 5 7 8 10 13 14 17 +97 95 94 92 90 89 86 83 +10 9 7 4 1 +28 30 31 34 35 37 40 43 +42 44 45 48 50 51 52 53 +70 71 72 73 76 79 +28 29 31 32 34 +22 21 18 17 16 13 10 8 +84 81 78 75 73 71 +30 33 34 35 36 38 +57 58 61 64 67 68 71 +63 65 67 68 71 +41 39 38 35 32 29 28 27 +7 9 11 13 14 +27 25 23 22 21 20 +89 88 86 83 80 +32 30 27 26 25 +29 27 26 23 20 17 14 13 +92 91 89 88 87 85 +34 31 30 27 24 23 20 +73 70 68 65 62 +79 82 83 84 87 90 92 95 +11 14 17 20 21 24 27 29 +23 20 18 17 16 14 13 +7 9 10 12 15 +11 12 14 17 19 21 22 +27 26 24 21 20 18 +65 67 70 72 73 76 +22 23 25 26 29 31 33 +66 69 71 74 75 78 +44 47 50 53 54 56 59 +16 14 11 10 8 6 4 2 +49 50 51 53 55 58 +67 65 63 61 60 59 58 +98 95 94 91 89 +56 58 59 61 64 65 68 71 +74 72 71 70 67 65 64 +5 8 9 11 12 +51 49 48 46 45 43 40 +36 33 30 28 25 22 20 +59 61 62 63 65 68 69 70 +33 32 29 26 23 22 20 +27 28 31 33 34 36 39 +22 19 18 15 14 12 +40 42 43 45 46 48 +25 27 28 30 33 +6 8 9 12 15 17 18 +65 63 60 59 58 +99 98 97 94 92 90 89 87 +9 10 13 14 15 18 +11 14 17 20 21 23 25 28 +90 87 86 84 83 81 78 +47 44 43 42 40 37 35 33 +32 33 34 36 38 40 42 45 +61 62 65 68 70 72 +62 64 67 68 70 73 76 +51 49 48 47 44 41 +37 35 34 33 31 +32 35 38 39 41 42 +85 88 89 91 93 +29 32 34 36 38 41 +33 31 29 27 24 23 22 +21 22 23 24 25 26 27 30 +41 44 47 48 50 53 54 +47 46 43 42 41 39 36 33 +12 13 16 17 20 23 24 +11 13 16 19 20 23 25 +82 81 79 77 74 +33 35 36 37 40 42 +64 66 68 71 73 74 +61 58 55 53 51 50 48 +97 95 94 91 89 88 +75 76 79 80 81 83 +54 56 59 60 61 62 +94 91 90 89 88 +76 74 72 70 68 67 64 +24 27 28 31 34 35 37 +19 16 15 14 13 12 9 8 +54 56 57 58 61 63 +43 44 47 49 51 +52 49 47 46 43 41 38 +4 6 9 11 14 +41 43 44 47 48 51 54 57 +4 7 9 10 13 16 19 +60 61 63 66 69 70 +82 79 76 74 71 +61 63 65 68 69 71 74 +37 34 33 30 27 +23 26 28 29 31 32 34 36 +90 92 94 97 98 +54 57 59 60 62 65 +16 19 21 22 24 27 28 31 +64 63 62 60 57 54 +8 9 11 14 15 16 17 +32 30 28 26 24 23 20 +22 20 19 16 14 +53 51 48 45 43 42 39 36 +32 35 38 41 42 44 46 +40 41 42 45 46 49 52 +24 27 30 32 33 35 37 38 +15 16 17 19 22 +53 50 47 45 42 39 37 35 +55 58 61 64 67 70 72 +11 12 15 18 20 22 25 26 +42 40 39 36 35 33 +63 66 69 70 73 +83 84 87 89 91 92 94 95 +11 14 16 17 20 22 25 27 +40 42 45 48 49 52 +39 36 33 30 28 26 +75 74 73 70 67 65 63 61 +23 26 28 30 33 36 39 40 +36 38 40 41 44 46 48 50 +20 18 15 13 12 10 9 +78 75 73 70 68 67 +52 51 49 48 47 45 42 39 +93 91 89 88 85 82 +37 38 41 42 44 47 +13 12 9 8 6 3 +92 91 89 86 85 83 80 +49 46 43 42 40 39 37 +62 60 59 56 54 53 50 +59 58 57 54 53 51 49 48 +88 91 92 93 94 96 97 +29 30 32 34 37 40 41 43 +38 37 35 33 31 +82 79 78 75 72 71 68 +32 31 30 28 25 24 22 20 +91 88 85 83 81 78 77 +64 67 69 70 72 73 75 78 +3 4 5 7 10 13 +96 94 92 91 88 +57 54 52 49 46 +54 52 51 49 46 44 42 40 +68 66 65 63 61 58 55 52 +61 58 55 52 51 +55 58 60 62 65 67 69 71 +9 11 13 15 18 20 21 24 +31 28 26 25 23 20 19 16 +37 38 39 42 45 48 +34 35 38 40 43 46 +35 38 41 42 44 46 47 +81 80 78 75 72 70 68 65 +33 36 37 38 40 42 44 +59 57 54 53 50 49 48 45 +96 95 93 90 88 +82 85 87 89 90 +56 58 61 63 64 65 66 67 +42 39 37 34 32 +8 11 12 15 17 19 20 +36 38 40 42 45 +59 57 56 53 52 +20 21 24 26 28 30 32 33 +81 78 76 73 71 70 +57 60 63 65 66 67 69 +82 81 79 77 76 +63 64 67 68 70 73 75 +84 87 88 90 92 94 +42 40 39 36 35 32 +51 49 48 45 44 +21 23 24 27 28 29 +95 92 89 88 85 +51 48 46 43 41 38 35 +20 23 24 26 27 29 30 +25 27 29 32 33 35 36 +29 27 26 24 22 21 18 15 +24 25 26 27 30 32 +25 26 28 31 34 +33 35 37 38 40 41 44 +15 18 21 24 26 27 +50 47 46 43 40 37 +1 2 4 6 7 9 10 +24 21 19 16 14 11 +95 93 90 89 88 85 82 +24 21 18 15 14 12 9 +47 48 50 52 53 54 56 58 +99 97 96 95 93 90 87 84 +32 33 36 39 41 43 45 46 +72 70 68 67 64 61 +87 86 85 83 82 81 78 76 +57 59 61 64 65 67 +16 17 20 21 23 25 27 28 +12 15 18 21 23 +93 92 91 90 88 85 82 81 +39 38 35 32 30 28 27 25 +50 53 56 59 62 +66 65 64 62 61 59 +23 24 27 30 32 35 37 40 +7 9 12 15 17 19 21 22 +77 74 72 71 68 +56 53 50 48 46 +83 81 80 79 78 75 73 70 +49 51 54 57 58 59 +99 97 94 92 91 89 86 +23 25 28 31 33 34 37 +56 54 53 51 50 48 46 +93 92 90 88 87 84 83 +84 82 79 76 74 73 71 +67 64 62 60 59 +45 42 40 38 36 34 +99 96 93 91 90 +39 40 43 45 47 48 50 +83 80 77 76 75 74 73 +5 7 8 9 10 12 +67 69 71 72 73 +37 38 40 41 43 46 47 +30 33 36 39 41 44 45 48 +96 95 94 93 91 88 85 82 +61 63 64 65 68 +44 46 47 50 51 52 +72 74 77 80 83 84 85 +73 71 69 68 66 64 +47 44 42 41 40 38 +36 39 42 44 47 +92 91 88 87 86 84 82 +57 58 60 62 65 +61 63 65 68 69 72 +29 28 26 24 21 19 16 15 +77 80 81 83 86 87 88 91 +29 30 31 32 34 35 38 +40 42 43 45 47 +54 51 50 49 48 46 44 41 +46 48 49 50 53 +55 53 52 51 48 46 43 41 +64 63 62 59 58 +46 49 51 53 56 57 60 +98 97 94 92 90 87 86 +28 25 22 21 18 15 14 +25 22 21 20 17 16 +49 51 53 55 58 +34 32 29 27 25 24 21 +74 71 68 65 64 63 61 +26 29 31 32 34 35 37 +84 85 88 89 92 94 96 +22 19 17 14 13 +4 6 7 10 11 13 +69 67 66 63 62 59 +12 11 8 5 4 +1 4 6 8 9 11 14 15 +23 25 27 29 32 +68 70 72 73 74 +38 35 34 32 29 27 25 +72 69 66 65 63 62 59 56 +68 71 72 75 76 79 +39 41 42 43 44 47 50 +81 78 75 72 69 66 64 +82 85 86 89 92 93 95 97 +65 67 68 70 71 +93 91 90 87 85 83 82 +97 94 93 90 87 84 82 80 +65 67 70 71 74 77 +24 22 20 17 14 12 9 +34 31 29 26 25 24 +23 24 27 29 30 31 +65 68 71 72 74 +51 50 47 46 45 44 41 +92 90 87 86 85 +28 29 32 33 35 37 +30 28 26 23 22 20 19 +14 17 18 19 22 24 26 29 +49 51 54 55 56 58 +54 56 57 58 61 63 66 69 +31 33 36 38 41 +80 81 84 86 87 88 91 92 +60 58 57 56 53 50 49 +73 71 68 65 63 60 59 +49 51 53 54 57 60 61 64 +29 27 25 22 21 18 17 15 +73 70 67 64 63 62 +53 56 58 61 63 64 +41 39 36 34 32 29 28 26 +18 15 12 10 9 6 +17 18 21 23 25 28 31 34 +47 45 42 39 36 35 33 +90 88 85 82 81 78 76 74 +15 13 12 10 8 6 +66 65 64 62 61 +99 97 94 93 91 88 87 86 +62 59 57 55 53 +23 26 28 29 31 +71 70 68 65 62 59 58 +25 27 30 32 34 36 38 41 +75 78 81 82 83 84 +79 77 75 73 71 68 +87 84 81 80 77 76 75 74 +66 67 68 69 71 72 75 +6 9 11 12 13 15 +87 86 83 80 77 76 73 70 +28 27 25 23 20 19 18 +49 48 47 44 42 +15 14 12 11 10 7 5 +34 35 36 39 41 42 44 45 +58 57 55 52 51 +59 57 55 54 51 50 49 48 +19 16 15 13 10 8 +60 61 63 64 66 68 +48 51 53 55 56 58 60 63 +46 44 43 42 40 38 +97 96 93 91 88 85 82 81 +39 42 45 47 50 52 54 +15 12 9 7 6 3 +71 72 73 75 77 +64 63 62 59 57 56 +60 58 55 52 51 49 46 44 +63 66 68 70 73 74 75 77 +16 19 22 23 25 27 29 +55 56 59 60 61 62 63 +86 84 83 80 79 77 +32 34 37 39 40 41 44 45 +38 40 41 43 44 47 48 49 +19 18 15 14 11 +70 71 74 75 77 +28 25 22 21 20 19 16 +84 85 88 89 90 +85 88 89 91 93 94 97 +75 72 69 68 65 +37 35 34 32 29 28 27 26 +44 42 41 39 37 36 34 +13 11 9 8 6 4 +32 29 26 24 21 +60 59 58 55 52 49 +45 46 48 51 52 53 56 58 +35 38 41 44 46 +53 51 48 47 45 44 42 39 +94 91 90 87 84 82 +4 6 7 8 11 13 16 19 +94 92 90 87 86 83 81 79 +82 79 76 75 72 +87 90 91 93 95 96 98 +40 43 46 48 51 53 56 58 +23 22 21 18 16 15 13 10 +69 70 72 73 76 78 79 +73 72 70 67 64 63 +31 28 25 24 21 +73 75 78 81 84 +89 86 84 82 79 78 77 75 +33 35 37 40 42 45 47 49 +71 74 77 78 79 81 +44 46 48 51 54 +53 50 49 47 44 42 39 +39 40 42 45 46 +70 73 76 77 79 81 83 86 +3 5 8 10 13 14 15 +28 31 32 34 36 38 +65 63 62 60 59 56 +28 30 31 34 37 39 +82 80 77 75 73 72 69 67 +41 40 39 37 36 33 31 +93 91 89 87 86 +33 32 29 27 24 23 +65 67 68 71 72 73 74 75 +49 51 52 53 55 57 +2 3 5 7 9 10 12 +52 49 47 46 44 +66 67 68 70 73 74 +57 55 53 51 50 +32 33 36 38 39 42 +59 61 64 65 68 70 71 +33 34 36 37 38 39 42 +56 59 61 64 65 66 68 +36 33 30 28 26 +96 94 92 89 87 84 +50 48 45 43 40 38 +65 63 60 59 56 53 +69 71 72 75 76 77 80 +42 41 38 35 33 31 28 26 +67 65 62 60 58 55 +97 96 94 92 89 +11 12 15 16 19 20 22 25 +83 85 88 91 93 +87 85 83 80 77 75 +40 42 44 45 47 50 53 55 +86 83 81 78 76 74 71 68 +6 7 8 10 11 13 14 +83 82 81 80 78 76 +72 75 77 78 79 +93 90 89 88 85 82 79 +64 67 70 71 72 75 78 81 +11 12 13 15 18 diff --git a/2024/day3/day3.py b/2024/day3/day3.py new file mode 100644 index 0000000..01ce633 --- /dev/null +++ b/2024/day3/day3.py @@ -0,0 +1,39 @@ +import re + + +def main(content): + operations = re.findall(r"(?:mul\((\d+),(\d+)\))|(do\(\))|(don't\(\))", content) + + # filter only mul instructions for part1, format: ('498', '303', '', '') + mul_operations = [x for x in operations if x[0].isnumeric()] + total = sum(int(a) * int(b) for a, b, *_rest in mul_operations) + print("Part 1: ", total) + + do_mul = True + total = 0 + for op in operations: + token = "".join(op) + print(token) + if token.startswith("don't"): + do_mul = False + print("disable_mul") + elif token.startswith("do"): + do_mul = True + elif token.isnumeric(): + if do_mul: + a, b, *_rest = op + total += int(a) * int(b) + else: + raise RuntimeError(f"Invalid token {token}") + print("Part 2: ", total) + + +if __name__ == "__main__": + + import sys + infile = sys.argv[1] + + with open(infile) as f: + content = f.read() + main(content) + diff --git a/2024/day3/input.txt b/2024/day3/input.txt new file mode 100644 index 0000000..5e64f19 --- /dev/null +++ b/2024/day3/input.txt @@ -0,0 +1,6 @@ +mul(498,303);when()}!(%mul(846,233)-,what()($where()how():}mul(334,117)]~>?,<,%^,mul(886,213)/:from()?-how()~}mul(343,197) mul(33,616)~%*~why()^*-from()mul(757,847){{who()why()#mul(927,553)>-?&!-@[mul(589,387)what():[?mul(865,934)#/ (why()+from()when();mul(804,792)-where(144,652)(mul(620,348);];]$mul(584,827):who()^%from()mul(381,633)why()@ when()where()?<;@#do()'< mul(643,715)@@#/>&-@?when(295,120)mul(465,37))]#mul(742,669)?mul(519,650)mul(546,337)@what(),{'^mul(769,202)^mul(808,254)/#why()@~mul(71,204)from();mul(150,335)[mul(302,220)>[$*~don't()mul(385,231)what()?*mul(852,324)#$}<{mul(838,178)<;+}@/*mul(579,121)select()why()*{{:mul(810,214)don't(){what()/)who()*%mul(273,606)&]from()@:why()@mul(788,896) }& don't()select()mul(568,713)$$'from()@+mul(390,36):@who();&from()mul(984,787)/mul(209,744)why()%[:what()mul(929,15)+how() who()@what()$!mul(751,670)$]from()mul(821,742)why()}:/why()>mul(445,950)>:mul(174,953)-where()how()+:mul(529,661)+{+@@why()##mul(513,442)how(827,318)}~}where()#@-:mul(941,152)~[,+{&@why()+mul(468,787)how()!$from()^^>%~from()mul(497,717)mul(930,672)mul(313,480)^%where()~-))#^select()mul(407,85)<#who()mul(776,808)~select()$?@,@mul(420,163)mul(666,491)$:+do()mul(823,835){who()?,mul(728,808))[who()/^<;select()~:mul(38,577)+>mul(985,224):/what()where()[%*what()mul(31,270)<>when()[?!!mul(895,903)%who()select()>/when()!mul(367,623)'#+mul(362,189)&from()'#$':$?{mul(571,203)what()mul(615,719)what(),what() )^mul(663,163)$@;&'select()mul(93,614)~(from()mul(490,261)#mul(530,933)}[from()];don't()$%what()%~'&'what()mul(134,307)}from()%;&why(65,575)?/mul(657,957)where()mul(969,590))how()when()how(){mul(534,951)@},mul(141,80<'mul(573,576)why()mul(952,460from()+#;;mul(36,336)&don't()&}how()why()select()^mul(267:+(+#'~mul(654,481)--mul(17,334)'!*why())how();-$mul(886,695)mul(954,476)where()!mul(73,181)?@mul(326,125)!@{)*mul(945,965)what()-select()~^who(884,691)how(846,544)mul(346,328)!<^~+-when(871,168):-mul(653,891why()when()how()why()mul(603,626)~+when()where(639,311),#mul(527,536)how()]%{/!-do()'@mul(368,63) +how()@]]from()select(976,708)?;what())mul(649,499)}&?how(792,889)~who()why(){do()mul(569,139)^[mul(701,8)why()!#[>'who()from()%mul(288,867)mul(706&*~>?select()@mul(819,789)(@%mul(180,466)from()[why()}&}mul(766,269)}@mul(827,216);???!mul(670,899)!-[%(<@^do()*}mul(475*mul(462,887)'@[])[?&mul(754,83)%]%(~from()}when()?mul(379,965)@why()mul(63,665)+[-{mul(543,711);>?/)(&mul(535,403)?')(mul(603,306)* when())what()-*mul(22,75)#who()<:{where(780,74)]mulwho()'#from()~?how() ,{{+mul(576,621)why()why();mul^;+^'mul(977,718)}why()>'[~ mul(179,326)#[mul(735,639)where() when()/from()$mul(779,50)don't()'<:)'>:}mul(232,847){where()mul(63,282)>mul(737,540)why()+!>don't()when() ']what()#,mul(778,85)how()[mul(809,798)![ $where()%>' }]mul(587,975)-?# }-]mul(800,437)$mul{[mul(603,103)>-/#why()mul(285,453)who();+{@ when()]don't()+[what(730,765) mul(399,137)%]select()#<[^>mul(146,316)~][from() mul(687,295)mul(347,287)when()>!from()&mul);<when()+;{^mul(267,700){~,!]? how()mul(779,914)select()&>^/%?}>-$*^mul(387,58)^who()&mul(157,49)#?/mul(35,606)when()')from()?%mul(451,146)'(where()mul(977,491)mul(916,789))&#how()how()>don't()^*mul(437,605)[how() mul(626,940)^*%/mul(884,929)select()mul(84,192)mul(111,274)what()mul(95where()![[(who()[mul(593,249)]]@#when()why()-/mul(230,390)#~],(:mul(840,931)mul(421,658)from(653,680)>&mul(34,90)>when()&}:why()mul(956,881)!when())$^]@who()select()where()mul(94,737)from()who()mul(816,357)')^^mul(454,208)$&mul(136,496){$what()mul(897,490)>'mul(376,325){why(),%]#what()mul(953,618)+from()mul(378,46)mul(138,440)who()#where() >(from()#mul(708,59)&why()mul(830,439)mul(468,479)why()<$,~},mul(279,437)%([mul(276,252)-#$mul(596,842)from()mul(873,817)*{{from()#(%^mul(765,528)!<< what())^mul$how()}/what() +:mul(411,270,,({(]!mul(627,262)/how()**how()$''+mul(791,814);-;;:mul(990,764)}where())))&((!mul(5,111)~how()from()&,how()mul(492,492)from()[$,+) @(mul(999,416)$&who(959,257)&mul(722,457)@how()) ^>;)@{mul(221,679)?who()$+{-^*{mul(241,314)how()][!mul(940,32){$(~@'+>mul(453,515*;mul(215,275)~/[,why(21,55)(who()',>mul(567,83)mul(330,717)>#!mul(611,308)+&select()(})/mul(744what(424,184)?mul(377,16)):(<[@mul(757,897)#^mul(404,155)%don't()}what(573,178)what()+mul(204,894)%mul(34,307))mul(794,115) +)from()}mul(515,433)^mul(529,684)from()why()where()?mul(956,914)(])?[mul(645,179)+mul(400,263)from()select()&^*mul(422,526){~;what()/)#don't()*%!/(mul(326,211)*%@select()from()[~&mul(456{why()from(138,423)-^(&!?mul(995,210):;when()why()how()!mul(394,185)how()!~who() ^how()'where():mul(348,18)mul(194who()&~*~&{/%mul(505,325) *%mul(459,604)>)) ~ -where()~{mul(579,481)mul(135,794)-*mul(453,355)~/](![from()mul(443,346)mul*[,~%why()-{do()/when(43,713)mul(136,26){^when()why()'mul(108,341)[@?!',+@who()mul(195]{&@{?:how()what()select()don't():]]#mul;what()&?:mul(541,941),&;-what(75,560)who()what()?how()mul(314,260)!)mul(250,620)>#mul(612,209),#?;mul(661,597)/mul(563,594)when()!:!mul(683,595)*what()when())'how();@mul(287,255)how()/^mul(345,555) who()/when()mul(681,924) 'mul(189,542)'mul(102,360)why()!'how()-?;,mul(874,55)+:!>what()mul(538,354)**]~how()who()mul(277,851),where(802,203)<{(];'?mul(268,251)~{:]mul(139,820){^^[ /;when() what()mul(775,595)/,)^;&where(),mul(644,487)?(mul(590,599what()%-who(){mul(112,571){$mul'/#mul(835,137)$&(mul(201,460)how()from()*@where()mul(934,320),[what()where())? :don't()&+'mul(66,8)~ mul(465,911)]?how()what(),;/:*-don't()#:?where()$mul(951,775)from()%@{who()who()!mul(78,456)^[from(),mul(144,347)']where()#([ @[]mul(660,565)}}~mul(738,761)-mul(514,849)mul(648,439who()+<,*/when()!why()mul(904,440)^ select())!@-mul(442,126% #?{mul(47,20)%mul(113,81)/;&+{@mul(504,712);select() mul(720,642)when()*#who()<-'];;mul(821,613)?select()!>when(){mul ,mul(597,943)$-what()*when()where()-}select(){mul(999,17)select(230,593),% mul(920,227)>where()@!~(select()!*mul(301,278)mul(538,232*!/when()mul(283,204)'who() ]mul(861,903)what()? %{* <-mul(112,180)'?(!mul(121,398)']<~/mul(363,850)])from()mul<>?!!from()when()select()!mul(551,325)[where())-:{#)mul(114}}:,,mul(341,114)from()?why() from()# mul(611,400))what()% from()}/when()'mul(874,416)'@&~+]mul(916,295what()@why()how()>where()-^mul(988,626)select()#!)who()why()mul(597,791)};mul(160,184) from()~{;!where()mul(332,928)where()(#!/usr/bin/perl+^who()]:,~}select():mul(810,730)when()mul(312;&what(415,542)who(560,710)who()from()^mul(828,831)> }how(595,281)!why()*/:mul(70,967) +(do(){,-how()<(how()[{why()mul(16,675))+don't()!>-((&what()!mulwhere()+( mul(446,260)#+&how()}}when()who()/do()[,who()]>-~from(),mul(200,312);$mul(997,25);?where(203,706)&?}select(),mul(553,783)@^~mul(779,661)%)mul(252,997)what()from();%mul(439,801)select()#?')~;%}mul?why()+!mul(385,635)@)^):!*)how()mul(563,131)#&mul(720,10)~#<+]^!:@how()mul(24,633)~mul(103,646)mul(331,217)~#mulwhy()@-$> mul(288,357)how() when();;why()<+mul(513,580)?when(299,618)!<^-mul(318,287) }mul(88,924)mul(220,403mul(264,790)mul(78,811),,(/who()who()mul(978,770)[what()$)]#:%mul mul(57,890)'(mul(146,967)[<#%)^;how()]>mul(166,279)]mul(24,319)%;select()-!/don't()>:mul(858,696)mul(622,496)*{{-~why()how()what()-mul(973%}+> mul(904,891)*(:{%mul(618,932)&!~*mul(77,889)}%~{mul(206,797)select()what() who()+*what(499,999)?@@mul(114,405)(()where()}/){]}mul(841,73)@!where(581,676)]#from(879,459)}^mulhow()do()}select()~!~)[why(364,979)who(533,785)mul(839,475)[{;>)(@what()mul(597,209)-$-^select()mul(453+;:#:?&mul(972,784)what()#select()%/[select()[,how()mul(436,10)]!~)select() mul(982,995select()~/%(,do()#who()]!,/*mul(718,383)when()>^*mul(803,383)when(); mul(568,612)/from()from()}what(219,960)from()*don't()@@why();who()where()mul(222,279){ mul(758,766)what()who()!how(38,972)~;],select()/mul(974,879)!don't()mul(368,975)where()^$[^&] -{mul(153,172)what()&+)[mul(97,652)when(534,157)~,:where()do()%%@]?&when(435,925)what(){mul(155,627)?{;@#mul(466,775)(;mul(834,395)//>()-don't() $mul(329,300)<+&'@^mul(469,14)*&why(99,525)',mul(427who()*@< ?do()[>from()when()?#,'&:mul(585,898)mul(128,392)-(?[,where()'^where(575,788)+mul(378,473how() '$'#@who()from()how()?(//mul(768,590)when()-: ](where()who()(mul(716,399)/~)@mul(754,670)what()mul(656,266):(;%!]mul(595,874)why()%@<^?mul(702,835)(![&&/+%mul(421,278)}where()-%^'+mul(842,496)/?@:]mul(282,851)~@)how())mul(543,112))]+^)mul(133,862);#)when()who()why()when(58,966),,mul(513,202)@mul(716,648)(mul(793,735)what()]where()%+-/mul(359,127)-+}/mul(116,988)when()mul(153,16):'@$who():~-mul(441,603)'how(){ #why()%{{mul(877,856)select()who(777,457)select()from())how(345,367)from()mul(447,557)%/$-select(),when()+what()mul(189,616)what()}mul(822,616)mul(454,622)how()&who()&#do():> mul(353,679)^(@select()<;mul(414,440)why()+how()&,]#-&mul(402,532)-})~#$-!mul(883,415):<@]*from() mul(28,253){where()? what()select()~mul(259,972)-(]<}>when()from()$mul(650,381)~from()}from()who()>mul(72,307),who()where()?@{where()mul(706,447)from(671,711))~mul(601,925)} ;what()[mul(533,851~{&what()(@{<'where()mul(799,568)%where()mul$>select()[)#^:mul(414,93)]mul(16,757)&[who(),/mul(629,760)&''how(),from()mul(951,329)^mul(781,711):/',+'{%when();mul(661,844)/why()<^}#mul(337,134)!)mul(339,829)([how()+&~how(512,132)!;:mul(696,374))}/what()from()mul(640,944)'{*how()what(279,739)why(843,673)? &!where()mul(347,404)^?>!$&mul(316,524) when()]mul(875,937)$(@]$don't()/who():/]mul(833,846)who()mul(190,362))mul(183,740)how()}mul(14,502):why();why()'mul(341,888)mul(668,734)]/what())**&(do()how()*:select()}*:]mul(604{mul(123,983)#&why()mul(159,440)mul(437,830)~};'])[?mul(36,75)mul(836,766),?*select()who()mul(548,488)%--where(521,841))$]do():-from()*mul(355]<+>:mul(58,505)what()from(49,769)mul(108*]~>mul(131,644)?!from()mul(11,884):where()!;select();+[select()mul(358,741)(*?]do()(?{@^mul(117,14)^+;what()from()}mul(847,203)/who()where()from(567,960)when()how()%~'}mul(677,415)mul(91,507)when()*when()from()*(mul(935,477) from()@ mul(556,85)?)@mul(196,674)^;*+#$mul(531,124)!what()%select(){who()}';~mul(67,663)when()'?mul(205,527)@:+ ?:why() %mul(513,956/}:,'@+$who()-mul(963,914)@from()why()how(292,305)!from(980,892)mul(456,909)!who()<(*@select()&why()mul(947,805)who()how()^}mul(154,935)+?when()('};]>^mul(855,799){who()]+*{mul(823,352)*<$when()+)^&(do()mul(623,916)(['])^what(){select()mul(815,135)}mul(464,34)' ^)-^~where()where()mul(50,471)*{select()from() mul~:why()when()[why();%, }-where()#mul(184,632)~]+'select()}what()mul(675,164)mul(360,852)mul(875,801):where(811,851)mul(702,746)mul(29,632)[{^]-:!{ who(719,324)mul(720,687);:/[#*mul(431,415)mul(123,914]&?%$how()mul(655,184)]@?how()*$(-what()mul(323,687)mul(474,75);mul(846,335):%;do()~?where()~mul{}?%mul(446,300)^how(),<&from()#!#from()mul(423,746)how()what()don't()what()+*#:mul(268,185)@do()!>?~;@]mul(657,833) ,(who()-who()mul(415,876)]&#?@'!/&mul(437,971)^,+mul(884,392):mul(183,497)^from()mul(204,743)^'>}who()$;}mul(892,574)+ from()?$mul(922,854))select()#,+>where(),*mul(551,303)?}mul(261,657)?why()}why()when()%-mul(124,265!mul(979,380)/@select()}>why()+#mul(384,303)$,@@-mul[mul(479,548)-]#> ?:!do()how()@&mul(917,657{:$&mul(966,387)}what())[-]mul(183,849)^^who()&<,mul(669,375)mul(323,459)$%/from()~+}when()mul(789,390)'+mul(804,927)#who()mul(102,842)$$)how()from()select()][mul(380,252) )>when()where()how()who():#where(184,552)mul(244,943)$&$*}*-mul(727,613)(#why()}>mul(807,274)mul(577,489)mul(731,223)>where()/!]? %where()mul(359,604)/$;$+}mul(182,17)why()-how()mul(792,962)why()/{-(how()%'select()mul(997,718)/{mul(7,739)select();:mul(800,703)[when()' #~why()where()*mul(345,374)mul(308,927)how()%@how()mul(233,785)#{!select()mul(208,457)#from()}what()mul(347,911)where()from()@;(mul(492,896)&;?+, mul(948,682)+~when()}from()mul(930,691)[&]*((#mul(600,425){what()'{)@,where();:mul(844,671)~+)#,(mul(446,155)$%@/:mul(749,494)mul(24,97)where(6,997)&where()?why(449,637)mul(631,323))mul(192,700));/$]what()mul(820,765)who()(>%>mul(702,770)*-[;}(mul(438,245)@)]^/'#mul(554,294)!mul(34,410)where()$<#how(360,499)@#mul(585,680)<^};mul(295,437)where()] {+mul(607,28)why()#% do();mul(96,932)]why()+who(){<,[where()mul(271,645);^:{mul(411,161)]<>do()@';when() (mul(41,299)(!what()*select(387,698)$]mul(942,465)^?~what(),*?-'from()mul(70,415)why()'from()how()mul(682,699)!^-when()?when()#mul(473,999) {(~>^why()}mul(240,258)+why()&%mul(579,916)!(]((select(112,996)#($,mul(584,139)%