commit 7c23b60f4d29b120e6215097aae308399e66cb23 Author: Andreas Date: Tue Dec 3 08:53:22 2024 +0100 Added day1 diff --git a/day1/input.txt b/day1/input.txt new file mode 100644 index 0000000..efba5ed --- /dev/null +++ b/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 \ No newline at end of file diff --git a/day1/solution.py b/day1/solution.py new file mode 100644 index 0000000..d130846 --- /dev/null +++ b/day1/solution.py @@ -0,0 +1,34 @@ +example = """ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 +""" + + +parsed = [[],[]] + +for x in open('input.txt', 'r').readlines(): + if x: + a = [y for y in x.split(" ") if y] + + parsed[0].append(a[0]) + parsed[1].append(a[1]) + +parsed[0] = sorted(parsed[0]) +parsed[1] = sorted(parsed[1]) + +asd = [] + +for x, y in zip(parsed[0], parsed[1]): + x = int(x) + y = int(y) + if x > y: + asd.append(x-y) + else: + asd.append(y-x) + +num = sum(asd) +print(num) \ No newline at end of file diff --git a/day1/solution2.py b/day1/solution2.py new file mode 100644 index 0000000..fb28189 --- /dev/null +++ b/day1/solution2.py @@ -0,0 +1,34 @@ +example = """ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 +""" + + +parsed = [[],[]] + +for x in open('input.txt', 'r').readlines(): +# for x in example.splitlines(): + if x: + a = [y for y in x.split(" ") if y] + + parsed[0].append(a[0]) + parsed[1].append(a[1]) + +parsed[0] = sorted(parsed[0]) +parsed[1] = sorted(parsed[1]) + +parsed[0] = [int(x) for x in parsed[0]] +parsed[1] = [int(x) for x in parsed[1]] + +asd = [] + +for x in parsed[0]: + cnt = parsed[1].count(x) + asd.append(x*cnt) + +num = sum(asd) +print(num) \ No newline at end of file