From f4846f72f750aa41cfe736cb720ee185298753b2 Mon Sep 17 00:00:00 2001 From: Steph Date: Sun, 1 Dec 2024 15:33:55 +0100 Subject: [PATCH] Day 1 --- 2024/.gitignore | 1 + 2024/app/Day1-example.txt | 6 + 2024/app/Day1-input.txt | 1000 +++++++++++++++++++++++++++++++++++++ 2024/app/Day1.hs | 54 ++ 2024/app/Main.hs | 7 + 2024/app/Util.hs | 65 +++ 2024/flake.lock | 61 +++ 2024/flake.nix | 27 + 2024/x2024.cabal | 17 + 9 files changed, 1238 insertions(+) create mode 100644 2024/.gitignore create mode 100644 2024/app/Day1-example.txt create mode 100644 2024/app/Day1-input.txt create mode 100644 2024/app/Day1.hs create mode 100644 2024/app/Main.hs create mode 100644 2024/app/Util.hs create mode 100644 2024/flake.lock create mode 100644 2024/flake.nix create mode 100644 2024/x2024.cabal diff --git a/2024/.gitignore b/2024/.gitignore new file mode 100644 index 0000000..daa9e81 --- /dev/null +++ b/2024/.gitignore @@ -0,0 +1 @@ +dist-newstyle/ \ No newline at end of file diff --git a/2024/app/Day1-example.txt b/2024/app/Day1-example.txt new file mode 100644 index 0000000..b8af9ad --- /dev/null +++ b/2024/app/Day1-example.txt @@ -0,0 +1,6 @@ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 diff --git a/2024/app/Day1-input.txt b/2024/app/Day1-input.txt new file mode 100644 index 0000000..cb6af3c --- /dev/null +++ b/2024/app/Day1-input.txt @@ -0,0 +1,1000 @@ +14764 28773 +59598 86587 +63147 83451 +40514 98156 +87534 16479 +45973 70030 +54965 61736 +74648 96398 +74806 54303 +59928 90661 +20699 66537 +78761 92340 +98940 65476 +80802 95605 +60992 14776 +50682 24755 +50058 93707 +94284 24755 +12156 11378 +12570 11246 +80932 42425 +43285 34499 +12178 60368 +42769 14776 +84125 76989 +96147 56013 +59913 97498 +96516 73501 +50544 14989 +61563 30781 +77558 24755 +42975 16439 +15144 48888 +58682 54556 +26702 28773 +70122 84904 +63011 21879 +35169 61029 +24755 17273 +82821 84904 +72828 31150 +79206 14776 +33200 20410 +60784 31612 +83670 47240 +34804 33091 +60626 38038 +86976 14776 +52742 73610 +14475 89997 +38361 86278 +13676 47791 +55862 38300 +49359 88343 +65399 50107 +37680 70002 +18748 70030 +18194 60295 +47721 87961 +88751 81703 +43668 87575 +98122 81412 +40374 59406 +10728 70002 +16342 87961 +39219 60134 +49679 38882 +60516 42195 +24012 66048 +25680 58634 +43100 28773 +25474 63592 +96520 14989 +57777 48481 +79027 93493 +11616 31094 +78378 70069 +84632 41501 +56086 13252 +42233 14000 +91310 34109 +30039 70635 +51428 33091 +74252 27409 +47188 50437 +67840 82887 +51822 38041 +61288 11754 +28673 95998 +84464 18379 +19745 14989 +76538 69263 +48693 48158 +25824 26564 +47422 26702 +63260 55162 +50610 20088 +11246 14776 +36616 96398 +48715 37866 +40501 87961 +84018 11246 +11235 95605 +60766 84099 +56833 10632 +26052 24115 +86850 63187 +96807 97498 +36028 14776 +28835 44350 +80413 14989 +23361 94328 +73994 70570 +95782 14989 +50992 96398 +16452 24559 +23476 26026 +48928 20088 +65743 30914 +23934 97498 +44641 85863 +19631 73108 +95142 58795 +98765 54626 +63049 20977 +18870 96398 +39312 32124 +19723 24115 +75131 99521 +15390 25186 +73207 10585 +14040 51560 +29954 68086 +38712 70030 +85468 86587 +95155 85042 +67412 98156 +41035 94284 +83320 48158 +90483 86587 +56827 49101 +75118 26702 +41487 57022 +46320 14776 +66537 87961 +52715 83100 +38882 26936 +70814 43122 +70750 64345 +29589 44580 +37398 26936 +40837 70002 +16771 11659 +94208 28773 +87906 97482 +74664 86587 +90116 87961 +99992 14989 +34113 81703 +89349 24115 +98148 62403 +42448 66537 +96296 28773 +57152 68961 +11277 42577 +36095 95605 +74684 28773 +33845 70570 +38158 14989 +15582 49424 +43600 11804 +63053 13761 +24342 76970 +92512 70030 +54252 30763 +73129 84904 +28773 12682 +32819 91123 +49835 86136 +16933 48639 +33213 12919 +10645 57366 +98251 65105 +52576 92477 +69406 30133 +67892 97797 +72483 26702 +17769 33091 +56789 53884 +14989 98156 +24140 97478 +18359 90471 +12073 91310 +38574 55162 +33091 74847 +89381 14213 +49449 91310 +64091 70030 +39247 42425 +25923 14989 +71251 68086 +24345 96398 +51558 79525 +96411 47119 +89958 70570 +76933 62218 +55949 70002 +43038 17285 +28551 26702 +95390 18863 +14866 46054 +88996 66537 +26075 21233 +39333 24115 +76335 97498 +99707 53061 +42177 90193 +14331 14776 +50227 38217 +78702 65884 +68910 87030 +46977 11246 +48214 96398 +51071 63952 +10391 33023 +46218 70030 +87713 79687 +57826 54282 +39480 97498 +64702 58553 +30861 51958 +22562 20088 +87627 28773 +68916 98156 +57407 88060 +29689 23857 +65454 98968 +15700 37327 +26803 95605 +15017 29068 +40380 60403 +69860 26248 +66059 88561 +58318 38541 +17839 28773 +79014 14989 +33520 24755 +81719 99646 +97850 30945 +89786 33091 +38928 38882 +93407 94284 +69408 48928 +37881 70002 +32254 43523 +68247 28773 +54752 89267 +29214 20088 +98248 98156 +58405 14989 +19932 93969 +95299 11246 +34948 70635 +35574 70002 +61738 80387 +98156 84904 +70128 66075 +44319 37979 +24280 27624 +36470 47223 +62315 42425 +32292 56201 +52245 45780 +70839 32043 +34787 78810 +67967 21147 +47767 86498 +88861 60623 +81588 82803 +57939 81703 +31732 94284 +46639 74596 +39121 76377 +10454 94284 +46701 27665 +80935 48158 +93418 99233 +86078 49136 +55356 72518 +51235 48158 +94312 89985 +18379 76636 +82631 46202 +73383 72296 +30654 74007 +82162 80836 +81614 56019 +26936 14776 +64866 64944 +10826 89173 +85362 73676 +39371 46554 +68384 28773 +87889 38587 +14856 56658 +99573 51530 +91777 78669 +95150 97498 +49111 26038 +60208 97704 +69664 24755 +27678 84904 +48916 78231 +15557 89973 +90782 20088 +87961 84904 +42368 26702 +40844 81703 +40750 66537 +13745 87961 +20088 24115 +31234 63276 +17198 25020 +67865 53558 +16266 19730 +64250 15511 +34405 95190 +69368 81775 +90053 31704 +65374 97498 +91614 69998 +70733 62921 +48158 92224 +99303 26702 +51318 20088 +24507 70570 +21139 24682 +62476 16854 +35217 94943 +38613 85127 +65794 23397 +43762 98156 +38914 26702 +93827 95605 +18121 83482 +44552 70570 +94358 70635 +44248 87279 +93340 91862 +47094 80019 +12115 22286 +61446 66475 +22034 81703 +13882 64607 +42845 56734 +14983 98703 +42881 38664 +69071 58912 +84078 87961 +77528 28773 +65018 26702 +80503 27258 +40534 98156 +97419 27317 +61450 61386 +44217 78513 +35342 55289 +60439 70002 +72059 70570 +76006 70570 +86878 40854 +58404 38860 +49034 23075 +55592 38032 +38344 16697 +53897 33091 +72649 18979 +59214 18944 +92474 69727 +56370 36522 +20573 20088 +26285 11559 +15809 43925 +56727 92121 +84539 96398 +55090 41104 +77753 83370 +78169 44330 +62175 84776 +61410 67693 +26872 94284 +80145 33677 +63895 27014 +54436 94284 +27551 52234 +70275 97498 +83218 84328 +76355 42630 +47953 29593 +40172 70635 +29988 57720 +84694 45868 +14741 84904 +78418 32122 +19787 96398 +97191 75785 +62241 14110 +38111 49908 +16878 95565 +65882 87961 +27528 30687 +24926 66537 +66319 86032 +71326 82785 +33060 79631 +80025 17963 +73714 96398 +33135 74777 +68453 48928 +97498 24115 +86671 18667 +71089 40231 +88441 26416 +69505 18247 +84654 87513 +68724 98903 +89841 28773 +56212 21616 +17426 80476 +44666 38523 +91211 26702 +26105 70635 +21759 14776 +98944 26362 +71236 38797 +42913 58775 +88578 14776 +72715 43283 +28967 20088 +84103 76725 +99695 48928 +64085 28773 +73316 33493 +72198 48928 +49559 70002 +38910 48928 +17599 42425 +84904 78946 +22276 55162 +58705 96924 +49033 55841 +57127 69408 +14022 70002 +64371 26702 +97436 54477 +30953 95848 +52677 10733 +62159 48928 +88481 55753 +81171 66537 +57638 46475 +61383 79886 +88427 24420 +96594 50213 +11462 90266 +67963 73678 +17744 66537 +79612 95605 +93100 30264 +32749 20088 +94436 75277 +45034 39394 +51810 84904 +43770 87961 +59487 84904 +73654 20088 +76244 39669 +93096 41969 +61078 18532 +64038 68086 +80823 20926 +24219 33166 +64789 47154 +45656 59480 +96245 26702 +46975 96398 +21791 21720 +36832 25932 +40413 90256 +35647 56771 +85109 69081 +96428 95605 +63398 98448 +86469 81278 +34738 54568 +58332 69690 +29366 38882 +43612 26582 +20715 13081 +13296 22608 +73338 65201 +39693 75574 +55258 87961 +72724 68868 +78654 50140 +85411 31891 +60178 64075 +67363 80960 +37379 96429 +40440 52965 +82070 48657 +22042 17036 +77928 49874 +16662 96398 +39080 72090 +36754 90110 +52253 13816 +63630 48928 +68957 70819 +45100 25633 +82085 27847 +17126 28773 +37291 97173 +57062 11246 +12567 71707 +51113 75861 +89899 26702 +99628 26702 +75520 81811 +93558 13940 +49113 62910 +20958 87961 +77841 87019 +75297 48928 +57790 48928 +32002 77033 +42282 94284 +43678 84904 +31604 49493 +74565 28773 +22599 31143 +82887 59506 +39004 54574 +78978 79120 +90292 39855 +95502 99786 +21111 70626 +56784 92396 +13139 80974 +92819 25441 +73536 87961 +29862 24755 +99684 73955 +72968 89889 +13389 24733 +11304 81703 +21283 96196 +29316 10170 +39855 52810 +87865 93597 +97638 24115 +65813 70719 +60400 31888 +28931 32564 +39635 69408 +53198 87575 +26868 87575 +76903 38317 +65814 97018 +30920 33091 +17272 86587 +36064 40874 +60497 86587 +52751 94284 +98146 20555 +82591 71240 +80940 94284 +58866 60084 +19528 96398 +50171 42425 +83139 14776 +54987 84299 +86114 91310 +95215 20088 +33676 91776 +33258 84904 +94339 14989 +93998 30882 +12128 48129 +70002 20088 +17360 55991 +53459 95355 +86002 70002 +82138 79394 +77891 97498 +97857 56980 +80792 63735 +25421 58294 +35922 12614 +81854 32809 +53275 35517 +57944 58635 +87461 63921 +18830 65741 +71991 21238 +20578 14989 +30318 93736 +47800 78875 +70513 70570 +19497 23690 +85084 95631 +22048 86587 +81414 55666 +80731 69207 +18973 59682 +94485 48928 +77316 13319 +12204 51966 +70689 33091 +34924 22911 +96610 19455 +55203 24115 +75093 48158 +87356 14999 +18221 33578 +73385 48928 +81742 58221 +99442 82887 +28678 80624 +35197 87961 +35467 94284 +18508 51523 +14264 54207 +31053 40807 +64587 56579 +31857 72079 +80498 95581 +73182 87575 +38534 55162 +19889 76201 +62987 35692 +28009 48158 +62366 13329 +67690 14228 +87575 13596 +75924 66537 +43917 48158 +85815 28141 +12195 66537 +28926 26936 +28067 11246 +10649 83782 +90300 37607 +26829 33091 +97237 61393 +28274 87961 +81949 69715 +10148 86587 +20782 82454 +65121 86587 +35048 25761 +42425 98156 +49562 26702 +62240 64020 +97292 25754 +77339 95190 +96171 69408 +78515 44047 +23269 81703 +86257 11890 +53795 31884 +47860 69457 +27030 81703 +95995 46031 +88330 14776 +36227 95605 +71611 49839 +41787 68086 +98937 95605 +15634 78884 +38019 25226 +40301 68031 +64868 55162 +20353 28773 +52004 20088 +33605 36752 +52954 97498 +22677 92974 +35007 86399 +16229 14776 +92840 67007 +53192 70030 +14342 89825 +83874 20965 +67836 23984 +13168 89395 +45532 99100 +28527 26702 +11652 24115 +65046 72711 +24115 22371 +15313 14989 +46692 26702 +55036 14776 +47509 96398 +79999 58058 +75429 27911 +86289 83776 +40994 86587 +23698 49671 +60630 70567 +39923 14340 +41480 56160 +50015 85965 +20119 27795 +54647 79989 +32724 20334 +34408 48928 +13854 58826 +75114 43950 +45654 66537 +35904 14776 +97510 94203 +94288 70002 +62816 86587 +52333 95190 +56575 33091 +16125 96398 +72085 22071 +79557 70570 +88132 51844 +13717 72028 +59557 48158 +21409 10973 +84192 80904 +55868 24115 +84432 44699 +36959 87575 +76847 55162 +22567 24115 +67194 20088 +10465 86045 +30706 90300 +90253 64531 +75677 70115 +90677 80124 +16022 37893 +35712 73458 +49005 66248 +63561 62138 +39451 26233 +23062 75780 +88457 16642 +60392 76302 +10273 86587 +21677 70570 +36650 95605 +99569 14989 +70030 94284 +17260 81703 +26866 97440 +96514 96034 +96398 85529 +28702 79102 +79651 61560 +94067 31196 +71869 73932 +57996 50145 +35350 89987 +74905 77610 +42941 11246 +87385 28773 +32235 86698 +33758 84904 +75879 56926 +22019 92584 +21649 37986 +55926 84525 +74822 21112 +37702 70635 +62444 94284 +17072 12964 +80776 14776 +86143 84904 +90967 59199 +82007 95190 +61344 94380 +23060 62759 +71836 29181 +16696 86051 +23602 70030 +61274 61768 +35327 94433 +48285 55162 +19775 18482 +79268 18379 +66437 24755 +66155 44810 +54687 47121 +47590 10505 +49604 87575 +39448 14989 +70866 91310 +40876 88016 +38356 82887 +78821 87795 +60336 84904 +95020 18379 +92719 38882 +44432 70635 +55162 20864 +20330 57239 +68086 28020 +27630 63281 +86610 69601 +11026 90977 +88395 58295 +51282 39771 +27597 95605 +92765 48928 +75775 87961 +70635 94284 +24241 87961 +61618 20088 +16337 50458 +98080 39551 +28091 48158 +65880 66493 +24832 48928 +32253 27393 +27035 41482 +34239 96262 +31294 26702 +10102 12198 +36743 78333 +23284 75787 +87169 75720 +84151 87961 +26666 79650 +89818 40672 +70570 65623 +81552 84522 +56875 78429 +15373 28773 +77993 34110 +36591 96398 +61768 42887 +71478 68504 +25433 96100 +98896 81958 +93352 28773 +43847 93400 +60150 66441 +80559 70002 +45453 60573 +11057 26011 +40296 63705 +30537 95605 +95190 10399 +58593 11246 +23634 58654 +19831 48928 +60897 52279 +98886 87961 +18897 52942 +53785 10405 +58898 24115 +58346 24755 +42098 31963 +83994 80991 +22205 55162 +74702 66537 +95807 26702 +23781 92776 +49996 66296 +72776 81703 +31849 70570 +52068 87294 +98819 59638 +32585 48158 +51597 85464 +85824 75556 +27722 57980 +71157 14989 +43341 46516 +45946 45375 +20545 48928 +73393 32160 +13910 97316 +79218 96398 +44035 88007 +15597 79600 +15662 70002 +34269 49123 +37898 98156 +40216 26702 +92831 87961 +77463 70570 +89751 84904 +56728 88267 +55828 45038 +99410 96962 +27691 22801 +10416 70570 +47279 91310 +50204 14776 +56597 40834 +77705 43023 +72403 33091 +36921 51477 +62196 36387 +39460 42518 +86502 37844 +88097 38882 +62899 57280 +63482 20088 +51582 24115 +82873 70570 +81897 84904 +70932 24115 +47617 78694 +17894 48126 +66191 20440 +11809 14989 +28873 70002 +26808 98156 +57387 79775 +54906 33091 +51853 14776 +48424 84904 +62763 27546 +73121 54587 +95605 48158 +61687 86587 +31005 97498 +78477 78372 +35623 84904 +20589 77307 +78283 40059 +94194 43725 +44078 67834 +81703 31282 +99920 59468 +22742 37828 +55795 12750 +27345 14989 +91944 45458 +30545 19535 +20030 70570 +25018 69169 +12044 13251 +91516 82887 +91683 16178 +27731 86587 +80834 21540 +56421 26695 +60139 70002 +28612 95499 +75264 11246 +64380 66537 +56560 26702 +18126 47523 +71350 31211 +25426 65619 +24228 83125 +45887 70570 +10621 11246 +89105 70570 +53390 49454 +57017 81703 +76370 94284 +60258 85023 +51705 96398 +15492 37504 +55450 96398 +65708 91167 +37078 83486 +14776 10500 +99794 86587 +50029 87365 +47006 35798 +87658 85900 +80839 90300 +88943 94078 +33451 28773 +91207 86587 +33560 48158 +80832 43682 +86587 16558 +34637 42425 +40252 22905 +94463 63284 +13247 72402 +14825 48158 +60196 91310 +45730 14776 +85407 18493 +19771 50847 +30506 24755 +32174 68086 diff --git a/2024/app/Day1.hs b/2024/app/Day1.hs new file mode 100644 index 0000000..cf80034 --- /dev/null +++ b/2024/app/Day1.hs @@ -0,0 +1,54 @@ +module Day1 where + +import Data.List +import ParseLib +import Util + +main :: IO () +main = do + example <- getFileContents "app/Day1-example.txt" + input <- getFileContents "app/Day1-input.txt" + + putStrLn "Part 1" + putStrLn $ "Example: " ++ show (part1 example) + putStrLn $ "Input: " ++ show (part1 input) + putStrLn "" + putStrLn "Part 2" + putStrLn $ "Example: " ++ show (part2 example) + putStrLn $ "Input: " ++ show (part2 input) + +part1 :: String -> Int +part1 input = sum + $ fmap (unwrap . foldMap Difference) + $ getPairwise + $ traverse (Pairwise . sort) + $ sequenceA + $ tryparse lexer input + +part2 :: String -> Int +part2 input = sum $ fmap (\x -> x * count list2 x) list1 + where Line list1 list2 = sequenceA (tryparse lexer input) + + +data Line a = Line a a deriving (Show) + +-- Parser code + +lexer :: Parser Char [Line Int] +lexer = greedy parseLine + +parseLine :: Parser Char (Line Int) +parseLine = Line <$$> natural <$* token " " <$*> natural <$* token "\n" + +instance Functor Line where + fmap f (Line x y) = Line (f x) (f y) + +instance Applicative Line where + pure x = Line x x + (<*>) (Line fx fy) (Line x y) = Line (fx x) (fy y) + +instance Foldable Line where + foldMap f (Line x y) = f x `mappend` f y + +instance Traversable Line where + traverse f (Line x y) = liftA2 Line (f x) (f y) \ No newline at end of file diff --git a/2024/app/Main.hs b/2024/app/Main.hs new file mode 100644 index 0000000..3de888c --- /dev/null +++ b/2024/app/Main.hs @@ -0,0 +1,7 @@ +module Main where + +import Day1 + +main :: IO () +main = do + Day1.main diff --git a/2024/app/Util.hs b/2024/app/Util.hs new file mode 100644 index 0000000..39eadef --- /dev/null +++ b/2024/app/Util.hs @@ -0,0 +1,65 @@ +module Util where + +import ParseLib ( (<$>), (<*>), (<*), (*>), (<$), Parser, parse ) +import System.IO ( IOMode(ReadMode), openFile, hGetContents ) + +-- Functions on lists + +count :: Eq a => [a] -> a -> Int +count xs find = length (filter (== find) xs) + +-- Helper IO functions + +getFileContents :: FilePath -> IO String +getFileContents filename = do + handle <- openFile filename ReadMode + hGetContents handle + +-- Helper functions for the utrecht parser combinator lib +-- Rename operators + +(<$$>) :: (a -> b) -> Parser s a -> Parser s b +(<$$>) = (ParseLib.<$>) + +(<$$) :: b -> Parser s a -> Parser s b +(<$$) = (ParseLib.<$) + +(<$*>) :: Parser s (b -> a) -> Parser s b -> Parser s a +(<$*>) = (ParseLib.<*>) + +(<$*) :: Parser s a -> Parser s b -> Parser s a +(<$*) = (ParseLib.<*) + +($*>) :: Parser s a -> Parser s b -> Parser s b +($*>) = (ParseLib.*>) + +tryparse :: Parser s a -> [s] -> a +tryparse lexer input = case parse lexer input of + (ls : _) -> fst ls + _ -> error "Parsing failed" + + +-- A monoid that calculates the difference between two numbers + +newtype Difference a = Difference {unwrap :: a} deriving (Show) + +instance (Num a) => Semigroup (Difference a) where + (<>) (Difference a) (Difference b) = Difference (abs $ b - a) + +instance (Num a) => Monoid (Difference a) where + mempty = Difference 0 + + +-- List's applicative fmap creates a "cartesian" product. +-- This applies the functor pairwise (which is what you usually want?) + +newtype Pairwise a = Pairwise {getPairwise :: [a]} deriving (Show) + +instance Functor (Pairwise) where + fmap f (Pairwise as) = Pairwise $ fmap f as + +instance Applicative (Pairwise) where + pure x = Pairwise (pure x) + + (<*>) (Pairwise fs) (Pairwise xs) = + Pairwise (zipWith ($) fs xs) \ No newline at end of file diff --git a/2024/flake.lock b/2024/flake.lock new file mode 100644 index 0000000..ac3782c --- /dev/null +++ b/2024/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1732837521, + "narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/2024/flake.nix b/2024/flake.nix new file mode 100644 index 0000000..9e320bf --- /dev/null +++ b/2024/flake.nix @@ -0,0 +1,27 @@ +{ + description = ""; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + }; + + outputs = { nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + packages = { default = { }; }; + + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + git + gcc11 + cabal-install + ghc + haskellPackages.haskell-language-server + ]; + }; + }); +} + diff --git a/2024/x2024.cabal b/2024/x2024.cabal new file mode 100644 index 0000000..f44f3c7 --- /dev/null +++ b/2024/x2024.cabal @@ -0,0 +1,17 @@ +cabal-version: 3.4 +name: x2024 +version: 0.1.0.0 +build-type: Simple +extra-doc-files: CHANGELOG.md + +common warnings + ghc-options: -Wall + +executable x2024 + import: warnings + main-is: Main.hs + other-modules: Util, Day1 + -- other-extensions: + build-depends: base ^>=4.18.2.1, uu-tc, containers + hs-source-dirs: app + default-language: Haskell2010