diff --git a/2024/.mise.toml b/2024/.mise.toml new file mode 100644 index 0000000..847297b --- /dev/null +++ b/2024/.mise.toml @@ -0,0 +1,2 @@ +[tools] +python = "3.11" diff --git a/2024/full/day01.txt b/2024/full/day01.txt new file mode 100644 index 0000000..07185fe --- /dev/null +++ b/2024/full/day01.txt @@ -0,0 +1,1000 @@ +47078 87818 +99261 15906 +44723 23473 +87598 26876 +82172 24873 +92690 35957 +46104 92718 +17300 92112 +67643 56714 +81513 83498 +29550 67133 +41437 40271 +50927 30853 +59085 99760 +70043 30853 +60337 32788 +96311 84959 +84634 52702 +52702 63846 +24182 51218 +73443 69884 +72022 58536 +62248 41011 +41418 82128 +92718 37057 +95875 57364 +84233 38993 +49551 99582 +77689 64457 +21344 56714 +45466 41011 +13812 15968 +57869 45306 +78200 77689 +44981 43653 +35500 66963 +27169 56950 +48956 39884 +44999 26876 +87641 65881 +97594 77367 +26029 41783 +56082 48615 +37413 49812 +16310 58965 +36134 33967 +40339 69074 +87392 73592 +85426 41011 +50693 79721 +72999 51667 +37541 99170 +33772 59608 +94796 61699 +90202 55953 +38330 73424 +39478 85890 +76029 81665 +65969 11359 +63748 77256 +45284 67606 +80539 58100 +39367 92755 +81324 71861 +39057 32788 +78121 40271 +66791 59743 +15405 11016 +26614 40271 +74178 92718 +58206 56714 +58390 25035 +59886 15968 +58977 76787 +44549 27027 +43761 39854 +41990 11589 +89748 92718 +37102 72199 +74662 40220 +63702 73406 +68866 31235 +37664 40271 +21120 83642 +37562 84394 +96696 52702 +15695 57691 +77133 21919 +27827 73852 +16989 40271 +24826 63907 +37931 43112 +22793 52702 +87720 55514 +19896 40271 +35602 15968 +84179 64941 +18369 25377 +94694 26917 +59042 63583 +72595 38723 +70765 72595 +17730 85810 +14237 63353 +43121 63327 +71146 20668 +70924 73750 +35978 62758 +71771 30853 +31366 19077 +46799 46080 +17728 84290 +73057 40271 +74265 26876 +20692 70845 +98146 52702 +11555 33496 +23856 26826 +37347 89364 +71336 16570 +52686 95991 +46027 52702 +35514 15202 +83891 10187 +93746 70911 +26934 58536 +11606 15968 +90273 58100 +45589 87216 +34588 85214 +90198 40865 +99412 18291 +73574 92718 +21438 61699 +75457 85579 +64991 59375 +17631 19103 +77182 20233 +78920 28543 +81239 86731 +22547 63907 +51155 32788 +79249 58100 +90671 90991 +85690 78392 +58921 70144 +21070 44410 +62699 72595 +49573 69124 +73725 73849 +88221 94676 +51718 99007 +99760 31236 +95185 94160 +87111 57839 +28467 15202 +42315 76351 +77827 79354 +95219 99760 +38147 30853 +64826 63321 +25471 16587 +10927 81296 +41546 41011 +37315 69111 +99327 38377 +85336 84238 +40804 30853 +53516 30853 +27810 70144 +69577 70694 +25624 38809 +49041 69884 +21503 74953 +73554 57055 +75671 69264 +35839 92687 +62809 49927 +38952 71861 +47433 94883 +83751 84179 +96703 59295 +14937 71861 +88960 47466 +95895 44999 +10816 92718 +53349 58536 +78701 15202 +88121 40271 +34593 68809 +54762 81665 +43571 77689 +55916 40089 +40645 36311 +31607 40497 +81871 58536 +59108 11885 +51170 81665 +92491 50670 +52658 58212 +23221 90728 +66538 78414 +15397 96177 +44490 63907 +74261 61699 +52527 52702 +54092 12090 +85887 44240 +81916 81665 +52917 24491 +63064 19043 +67656 60571 +46500 63907 +23513 83663 +89284 54975 +70144 28556 +99155 41011 +50425 84179 +68018 61813 +63893 32788 +63846 49310 +40331 85906 +37888 52413 +64681 15202 +18619 94298 +29923 95681 +31156 72616 +70630 33220 +46149 29460 +79706 59024 +15202 58100 +38450 55528 +38540 64168 +44172 15202 +83218 29596 +87956 75221 +74674 29596 +32969 27529 +75354 70584 +80869 39769 +78375 79326 +26720 80104 +59064 93076 +17369 26876 +71018 28093 +62410 94862 +34117 13591 +84414 77689 +72343 44999 +63907 66141 +71144 81665 +29415 66425 +88830 11982 +70188 22280 +53282 99760 +18318 63138 +60397 57539 +65195 41822 +24016 13700 +88135 74622 +14071 47193 +14685 98095 +95982 91801 +33811 72723 +29333 88953 +34084 86155 +56453 62127 +10338 90318 +42757 19402 +93976 63907 +76120 83403 +30463 94304 +13958 40271 +84845 99760 +64272 57736 +57418 35445 +77223 56497 +33423 75411 +41030 19106 +82698 15202 +29524 74256 +87764 77689 +86912 10187 +68742 59684 +76640 23589 +31500 17713 +23412 99007 +22908 58536 +56584 96889 +24442 83833 +19446 56714 +59337 72595 +60529 79345 +18771 52637 +69780 50379 +45080 41011 +90135 23400 +25259 15202 +16305 29881 +84260 41011 +90895 72595 +12543 38607 +11665 63907 +96978 81665 +52028 61190 +67233 52702 +20481 81204 +12111 70144 +20206 46595 +43424 69196 +29231 58536 +98098 55798 +60225 51890 +81665 97950 +50519 90597 +10405 75939 +67815 74916 +44903 61313 +57482 93791 +24477 85715 +47814 43158 +30230 15202 +62375 26876 +94004 70796 +75531 11460 +18327 71267 +52363 44947 +86594 44999 +46404 92745 +90532 39065 +64807 30853 +24401 52702 +91341 52563 +84207 62127 +71087 73532 +63113 44999 +43813 74297 +59883 66327 +32173 91360 +18376 64927 +13447 26876 +20860 73532 +90448 22528 +61857 59032 +98601 77689 +48533 95904 +43074 80112 +77210 40271 +30853 77689 +66535 90757 +73022 24042 +40271 58513 +83490 84179 +34711 19907 +93977 90225 +48807 56714 +54844 81665 +32392 26876 +96732 99760 +97627 25611 +60706 72595 +80954 56714 +85719 84179 +72831 16614 +31090 27039 +33058 29333 +63877 29596 +72421 90853 +15747 77367 +40917 32788 +81013 17450 +89899 99199 +30106 71861 +25280 44999 +55196 62277 +70682 33511 +82706 15417 +32623 56714 +71868 95563 +31828 15968 +13986 44897 +42490 77695 +97842 11333 +47535 51124 +92501 58848 +23972 80539 +90629 35766 +99801 13773 +97880 10299 +67699 77976 +44374 68427 +12199 77367 +71056 15202 +76588 44999 +73579 57631 +99007 77689 +81619 53485 +31191 62127 +80056 84625 +64180 23225 +54280 99760 +39351 48787 +33694 72481 +59589 20554 +95067 73532 +91316 40271 +73532 26451 +49527 93539 +46775 80376 +79815 59637 +35690 57057 +78276 95579 +64869 71861 +14150 36760 +36529 69884 +41203 84659 +42188 52872 +59342 26876 +13743 15791 +35869 82919 +56530 50033 +46284 15202 +61154 69884 +35696 86345 +15254 61699 +57134 71533 +70825 21595 +66588 34391 +82940 16813 +13492 15968 +96700 71218 +97141 52702 +61389 38118 +97291 69884 +60721 26377 +51117 83200 +98847 50875 +87646 22249 +62478 14669 +79243 66768 +40877 30705 +85374 99760 +26483 97357 +50799 72595 +31201 63907 +69859 67933 +10162 97886 +65187 73532 +51941 99007 +61601 68668 +88266 71861 +77196 44999 +92169 26447 +35540 30408 +37333 96467 +91358 64059 +25360 25918 +79252 41453 +90858 95320 +29099 89894 +42949 57509 +44235 61265 +76836 30756 +58622 32788 +52544 88998 +83243 61839 +11550 81665 +75353 90674 +18733 49200 +44857 99760 +47917 18551 +46902 94882 +67800 50385 +66456 27826 +54772 35730 +29893 52702 +93137 69884 +78826 81665 +28223 22708 +54686 31988 +69884 31020 +65815 22691 +54404 68691 +33098 61699 +31777 87837 +55080 92718 +52404 17012 +78426 99007 +86123 33334 +38248 21362 +18775 92718 +18300 84179 +68027 26566 +26944 58509 +96983 49850 +16112 73532 +22976 69884 +70019 58536 +99156 56912 +18554 56714 +34219 59289 +75604 46931 +93676 99760 +80075 44664 +61524 71190 +48559 83823 +79042 15968 +10187 63907 +81634 99760 +98757 45694 +95160 32788 +49758 62127 +34595 69729 +79509 75616 +70849 70765 +19823 99007 +11674 63907 +80688 26876 +68689 44999 +99145 30681 +29803 77689 +11195 26876 +39142 78046 +89735 99760 +17954 56702 +35483 24463 +24596 55483 +29573 86792 +40311 69884 +36696 79954 +71770 84179 +48235 40271 +64473 98643 +10835 29037 +87315 40271 +82881 60460 +62963 22798 +26876 15558 +23333 51990 +12241 33180 +77191 81665 +51847 62738 +29391 44999 +67769 59925 +86133 26025 +11156 56714 +78912 42186 +68345 58100 +33464 82105 +66618 63907 +48407 63946 +18442 81320 +88673 52220 +46467 84179 +75390 34795 +39665 26232 +38181 34226 +39508 21595 +99046 41455 +99124 58536 +10567 98228 +60543 71569 +43020 97889 +38858 40271 +29190 80539 +34739 62127 +89621 69560 +30771 58536 +57289 81665 +25790 99007 +75082 40873 +48883 77898 +84768 43568 +37225 52172 +69182 21856 +56054 15202 +88455 11998 +12595 81665 +42875 54145 +73926 44999 +36122 52702 +46708 99007 +29997 15202 +42745 98773 +42375 56714 +75274 20728 +88736 72595 +62127 56145 +26385 20846 +60047 26876 +73700 63508 +99967 56386 +91205 55219 +72084 17536 +11100 30853 +86461 63549 +44630 77689 +85895 51919 +68759 33484 +74502 71645 +19619 25720 +51879 22939 +93529 28809 +95744 44892 +71040 69884 +92283 10187 +69503 52702 +69366 32834 +77924 97954 +29331 17904 +53839 32788 +39040 92718 +77367 73532 +80212 58100 +46701 15968 +81778 64498 +98144 43740 +57572 83339 +58954 63907 +43061 69884 +33284 41119 +52046 98936 +43374 52702 +45680 30069 +58466 63907 +38467 70067 +41669 15479 +97829 40271 +61699 63907 +67033 10670 +85926 72595 +81216 30476 +51978 63846 +79287 81665 +23180 36540 +25437 25410 +39375 39888 +83920 52583 +66350 84179 +71374 52702 +43715 26936 +63974 77367 +23571 69884 +43184 84982 +89441 42511 +81551 44999 +10922 71861 +31029 29596 +60099 25656 +84341 28350 +87757 99007 +23597 15202 +78234 26876 +56131 96770 +52135 97828 +26696 17764 +17491 99007 +86740 60265 +53289 77689 +60718 52171 +57714 87530 +65300 40271 +65053 19684 +97208 29064 +79814 15202 +25364 63442 +47637 39347 +96951 69884 +53474 62127 +46924 69884 +50969 52018 +37489 99007 +48578 62127 +61446 80919 +68586 34617 +49043 73532 +92466 82326 +24713 44999 +63343 55976 +35977 84179 +34245 33537 +51912 56714 +94801 52702 +43170 40215 +92867 77689 +70889 82782 +55715 32788 +58553 53227 +16471 23124 +87308 51281 +21869 75687 +42734 58536 +60655 15202 +85304 77668 +94528 10667 +52573 29966 +67022 91096 +56714 98154 +24181 10943 +72888 40347 +72526 73838 +35075 99760 +18297 77200 +33264 94679 +79398 56714 +96423 61699 +98761 99007 +47893 52463 +23998 29333 +73783 80539 +95656 85562 +39010 70144 +12750 50086 +37688 37813 +34615 99090 +89976 36475 +57208 81294 +77332 63554 +84748 77108 +91236 37247 +95049 38795 +37167 87150 +75938 81744 +13240 60220 +98249 81665 +57711 82510 +48345 50410 +34247 55076 +63735 56714 +49753 72955 +42491 57804 +95228 62498 +49153 69884 +48475 81665 +51080 16072 +99335 26876 +76428 71861 +87840 87762 +90879 63708 +78241 94882 +44228 70144 +14939 81681 +91560 72595 +60633 61699 +87704 14607 +93639 44999 +56105 29596 +32508 73607 +12567 33468 +97216 21595 +50798 92962 +22716 94002 +14778 56597 +85689 26890 +44077 99719 +19295 43088 +95073 89224 +66049 74142 +13636 55544 +14788 46689 +50539 94586 +76711 12338 +68845 99007 +58084 56714 +81373 44999 +85290 52702 +74215 81665 +83877 42928 +72744 24041 +42339 44999 +90903 77689 +95473 77689 +15968 81665 +30119 70771 +67126 62242 +28005 43891 +83542 56246 +55690 61699 +86747 52702 +95312 76423 +71809 30853 +95342 86814 +35018 44999 +66726 88424 +88452 46221 +27429 40593 +55822 74366 +55664 17591 +52298 56714 +46184 12887 +83709 73532 +96569 52521 +94130 77689 +14616 90178 +54685 61908 +46980 56034 +97505 63846 +65102 40271 +27333 54978 +50829 12173 +22972 75288 +82623 52859 +38551 43499 +93146 26876 +75782 44999 +58483 90566 +25714 14324 +93683 12547 +13255 41011 +17050 77689 +99987 69884 +87610 98164 +32788 79689 +88659 72069 +75294 77367 +83641 61674 +78128 15202 +77913 58536 +18091 56438 +44772 38894 +18123 63907 +14757 22903 +86063 10369 +58790 13571 +96646 73532 +17441 37016 +62735 79008 +19676 58536 +53952 21281 +96037 78166 +56324 41924 +91420 92847 +32075 80539 +88097 93787 +64557 77689 +86964 87922 +54705 63907 +39832 87431 +26744 29333 +94719 35503 +15467 75955 +41780 56714 +68740 33686 +78413 28597 +22458 82789 +32380 70070 +58856 66092 +31400 68116 +29596 92821 +74434 36862 +56903 60867 +68537 62762 +73882 52702 +50795 41011 +92978 80539 +15419 63907 +30824 73027 +87167 66219 +30311 23071 +69915 65438 +13875 10846 +25150 58100 +71794 69045 +67187 22217 +88571 99345 +52691 99760 +58484 65806 +55576 15217 +70871 58536 +83674 61363 +21595 43759 +62939 84792 +19915 21720 +87126 59116 +37323 97948 +16743 81665 +76646 30581 +32715 62127 +27800 67124 +50506 13412 +41711 41011 +69510 49308 +64796 44463 +72579 12149 +69190 16493 +54418 23411 +22487 58536 +99378 63907 +12668 69884 +83089 54374 +49382 69884 +97939 18992 +55613 49971 +30391 71962 +99867 86926 +22464 58536 +62800 69400 +60452 30181 +28236 41011 +19971 99007 +97670 69480 +14241 19344 +53561 61699 +62921 99007 +56358 35755 +62754 34787 +58536 99007 +30001 53814 +74539 12679 +64108 42344 +10964 15202 +31620 12133 +63140 29642 +56181 75252 +24997 77689 +83375 30853 +58316 70611 +37598 86581 +53492 55238 +94882 53526 +49886 98524 +34832 40271 +51601 96816 +86836 76006 +98028 49086 +81264 92718 +88107 99760 +92986 22844 +15192 58536 +33858 31074 +47939 51733 +11400 64586 +41733 45362 +72781 74505 +99442 42256 +33819 73532 +42475 78227 +71861 63009 +16910 77689 +66841 55855 +82076 47569 +23970 77297 +50621 30972 +82188 65987 +52027 21595 +65978 41011 +76860 73419 +33128 23741 +56773 78528 +74030 40271 +83925 56714 +19663 10575 +45965 52702 +79913 99007 +24014 73532 +82291 30853 +55050 77689 +17469 77689 +89161 32788 +77583 72595 +63786 77015 +34030 25130 +31825 11803 +58100 29596 +31899 30853 +49755 72595 +27015 71793 +26065 14784 +56821 42394 +32804 26876 +41011 73532 +89019 62241 +67037 12599 +30561 21210 +64503 38086 +99814 92718 +62163 44999 +41339 56714 +48486 24365 +73474 84198 +12943 85353 +53346 76552 +65110 10187 +14424 99714 +77324 44999 +68183 99007 +62112 97792 +91712 78301 +30715 41011 +80210 76343 +48330 99007 +46680 96360 +89265 21171 +78498 67808 +95594 60377 +81820 84843 +17509 85554 +47369 11182 +34359 84179 +45592 15347 diff --git a/2024/python/day01.py b/2024/python/day01.py new file mode 100644 index 0000000..f66d000 --- /dev/null +++ b/2024/python/day01.py @@ -0,0 +1,54 @@ +import shared +import itertools +import functools +from collections import defaultdict + + +# @shared.profile +def part1(rows): + left = [] + right = [] + for row in rows: + r = row.split() + left.append(int(r[0])) + right.append(int(r[1])) + left = list(sorted(left)) + right = list(sorted(right)) + pairs = list(zip(left,right)) + diffs = [] + for l, r in pairs: + diffs.append(abs(r - l)) + print(sum(diffs)) + + +# @shared.profile +def part2(rows): + left = [] + right = [] + for row in rows: + r = row.split() + left.append(int(r[0])) + right.append(int(r[1])) + right_hist = defaultdict(int) + for r in right: + right_hist[r] += 1 + tot = 0 + for l in left: + tot += l * right_hist[l] + print(tot) + + +def main(): + rows = [row for row in shared.load_rows(1)] + with shared.elapsed_timer() as elapsed: + part1(rows) + print("🕒", elapsed()) + + rows = [row for row in shared.load_rows(1, True)] + with shared.elapsed_timer() as elapsed: + part2(rows) + print("🕒", elapsed()) + + +if __name__ == "__main__": + main() diff --git a/2024/samples/day01.txt b/2024/samples/day01.txt new file mode 100644 index 0000000..b8af9ad --- /dev/null +++ b/2024/samples/day01.txt @@ -0,0 +1,6 @@ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3