diff options
author | Orangerot <purple@orangerot.dev> | 2024-05-17 15:41:55 +0200 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2024-12-01 05:55:27 +0100 |
commit | 347d2f1fbce2d3927a32b3af818ab67943628568 (patch) | |
tree | fae9181a8f69a7f26f9fec10bb0941ad4e0f1edd /2023 | |
parent | a1895fe157e06ee4d119576163ea76390b3d402c (diff) |
Diffstat (limited to '2023')
31 files changed, 3315 insertions, 0 deletions
diff --git a/2023/.gitignore b/2023/.gitignore new file mode 100644 index 0000000..4c9e245 --- /dev/null +++ b/2023/.gitignore @@ -0,0 +1,23 @@ +dist +dist-* +cabal-dev +*.o +*.hi +*.hie +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +cabal.project.local~ +.HTF/ +.ghc.environment.* diff --git a/2023/day01/Main.hs b/2023/day01/Main.hs new file mode 100644 index 0000000..5f31582 --- /dev/null +++ b/2023/day01/Main.hs @@ -0,0 +1,34 @@ +import Data.List +import Data.Char + +-- isDigit :: Char -> Bool +-- isDigit c = c >= '0' && c <= '9' + +wordDict = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] + +findFirst :: String -> [String] -> Int +findFirst [] _ = 0 +findFirst s@(x:xs) wordDict + | isDigit x = read [x] + | Just y <- elemIndex (take 3 s) wordDict = y + | Just y <- elemIndex (take 4 s) wordDict = y + | Just y <- elemIndex (take 5 s) wordDict = y + | otherwise = findFirst xs wordDict + +rev [] = [] +rev (x:xs) = rev xs ++ [x] + +main :: IO () +main = do + inputLines <- lines <$> getContents + + let filterLines = map (filter isDigit) inputLines + let outerChars = map (\x -> [head x, last x]) filterLines + mapM_ putStrLn outerChars + + let intList = map read outerChars :: [Int] + -- let intList = map (\x -> findFirst x wordDict * 10 + findFirst (rev x) (map rev wordDict)) inputLines + let result = sum intList + + putStrLn $ show result + diff --git a/2023/day01/Main_clean.hs b/2023/day01/Main_clean.hs new file mode 100644 index 0000000..21b18a3 --- /dev/null +++ b/2023/day01/Main_clean.hs @@ -0,0 +1,25 @@ +import Data.List +import Data.Char + +wordDict = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] + +findFirst :: String -> [String] -> Int +findFirst [] _ = 0 +findFirst s@(x:xs) wordDict + | isDigit x = read [x] + | Just y <- elemIndex (take 3 s) wordDict = y -- not needed for exercise 1 + | Just y <- elemIndex (take 4 s) wordDict = y -- not needed for exercise 1 + | Just y <- elemIndex (take 5 s) wordDict = y -- not needed for exercise 1 + | otherwise = findFirst xs wordDict + +findLast s wordDict = findFirst (reverse s) (map reverse wordDict) + +main :: IO () +main = do + inputLines <- lines <$> getContents + + let intList = map (\x -> findFirst x wordDict * 10 + findLast x wordDict) inputLines + let result = sum intList + + print result + diff --git a/2023/day01/daniel.txt b/2023/day01/daniel.txt new file mode 100644 index 0000000..4fb66fd --- /dev/null +++ b/2023/day01/daniel.txt @@ -0,0 +1,1000 @@ +ninefourone1
+53sevenvvqm
+kscpjfdxp895foureightckjjl1
+72fivebt9ndgq
+28gtbkszmrtmnineoneightmx
+four66jqrbtqcsxjtqjvfjhl1
+four8pzznjbhxlhtz6bhtzdxjlg1
+rgxjrsldrfmzq25szhbldzqhrhbjpkbjlsevenseven
+slkjvk4threesevenznjqmmfive
+61ppgrkmkfhteightone
+1threesix67px
+sxbjdbtlnjrmlzgxneightthreepmqxdxhfk8jfrheightwovp
+twofour2sevenk
+sevenonezknqnkfqbzffjvfivetwo94two
+45xj
+mp7one6eightvhfnmfive6
+fhtctftxm3threefour2b
+2dq7bdmhhs92
+pdnbqlbvtcxgpnfhmsfhzstgm173
+8fourvxkddsrlcvseveneight
+15zqpmsix77hlljgfive
+jzjv6seven
+eight1vbfive
+721sixsdzbqtskbpkqbcmgmlpk5psrhr
+pqxdxcx5
+twozsf2five
+7twosixthree775
+7xtxrch7six
+729twofourlqrxtwo
+qtvbgtclhnk4ninefourseven5one
+jvhngkcdjhnmqghdbqdzqssf5onegzjbbcchboneightn
+five8two14five2nine1
+one3twomddthree
+8nine9two
+7fiveeight9ninesix6fivethree
+254kcd61dc4two
+7sixonetxvthntlngtwobzkbz23
+8sixnine6
+threedqtgmv2skmvcd
+7ptdhpvr1
+lsvmzvzvd9mqxszjmbddkmxzdxsninedmglzlzphtwo
+kgdt12seven4xxtttr5
+nrdtgdftjmfour6fxjninenineblqlthvpcx
+ninezmstcdfchc11onebmmfdfhvdncrhc
+1fiveseven
+oneone26twoeight
+threefivenine98one9twotbbcq
+9cm7ninestc
+jcrbmcjtrlzvz7
+nine8nine22
+3nineoneseveneight
+58four2three
+stwonefourthree9twonine4six5bvxgkxf
+ninechzcz4seven
+2tgzgmtzzpjdqqz
+brsptjppb28qxcxxjbzpeighteight
+eightthree3ninejrft4
+sixqsgkzdjmgpfive4threemxltqdxsfive
+vxfd2q8
+khqhgqlxslkmbrvljcnineeight1gjgcqmnbdczqb8four
+mvbltrgpfourcclxftbb7gcbqcptvgfsevenrdm
+61eight
+six8fourthree6fourseven6three
+jqdfxvhjg3sflkn2sixptxxsqrfml
+6jtxs
+seven99threeone
+five6sevensmbbrjqvdbmkbsqtwonelg
+fdvfsndt32fourgllgfrninebhnzzczfive
+9hxp9srhjhjjvqljhzprcjpqreightzs1
+djldhkkcn55threethreefourflnxnbzhkzmx
+fourfive43chfvjnvjrkpxlgjrfnqbl
+fxjgtj4
+1sevenfour2fiveeight
+seven43rxxeightb1
+9sevensnxkp3lpzxfxnntkxzkrhk7jzhmtvn6
+25one
+threeone7
+1pkfvsxxthreeoneseven
+ztbvfqnpz2xdhgdjmgvfourtworqbxqsh47
+8four7sixninesix
+threedgl88cczqhqxjnc
+nineeightthree4sixfive3sixdqlmscqjk
+16crjsdl
+tgq2sixhc7three
+tzgsqspndt5xnqlthghzfvkkhone
+4fxdqrs64ninex34gd
+seven22
+kghfkrpvnppfncbhhqpt55bjf
+hjhb71bqdrrgsrkqdtsgrxgsscqjmtfzjkzsbp
+lgdnt9threeeighteight97
+pvjhnk83sixncvgmsjltwotdmmpxknhvntfndxr
+7449
+qdfzv9hkprplzkfh
+66three5five4zdsfrcnljqmsxf2
+veightwo27bdbsvseveneightrcqcjxsixeight
+1thvkkk
+8bnxqfsdhzppblzlzbkfsksfscmb
+zseventbdzlmhnnrfive1one
+sixxnmntrmp6srcsqbrqnjfiveeightfive
+4trnzlshnjtwo5twocxrvfssbj
+6two3twonetqt
+55qsnx43
+3three23tpctbkrnqv
+sixqk4cnfdmtltmlhqxtwo41glkhdhgnt
+35fivesevenpfournxzsbbgzthjvlvzrnine
+tworkzgkcvcone53nrvgdvgtc
+two9llkjbkz8pklrsgqqzr2four
+ninecgpbgcnine4tldjqsone4six
+2tfjhtfourfour
+onebhlhdvvqx1sevenmsixsix9
+pjgjt6jkrgshxltfnine8four45
+4vsqfljrfiveqeightnvbdb
+11nfslqvhm
+7crrhqxsfive8ctkzbhqnine
+vrvtglvthreettrkq5bdlrtpx718
+1btbxlthreedtrzgeightnineqczhqm3
+193
+fcbzxqxxjtmn47ffschdrbeight
+twoh1gqkrnm1
+7ninesixpzpsn7
+5kkvzpgqd
+three6nine
+32fdn
+22twoxgvktxpxmbjqtgtbckx
+1hdtftwosix
+2jfc
+six5nvzcgmrscjn5eight4
+nineqhtczsninetwosix4five
+9three6sj
+hntktlbqmldrphqzxkhfour193
+twotwo5259
+v7six1vtlxnpm
+rhsm2
+gprmtxbhlsv8onefournine
+2fsrbtdvft15six1kxpqbnqsxh9
+one5onemxthree8
+nineqbxdbznzktxsmstsntzffour3one
+9blhkhjsgsfgsblzdtqqfour8
+stz4889563cb
+vjrbs6threeptbbmncz7hqhqgfgldtseven5
+vbfs1
+zjqgczjsjpvzvjseven4
+sixfjzbrrhcfqvglxhnsxninedrvtvjbfqjdbrzblkq6three
+one3threegcdldjsrsssixonefiveonechngsl
+7srxv4hsgjqsqfvv1tdngkpjrczkl4
+5scgdglnjbnsix8fivesixtjccvmkfxfnzvhctgpncjc
+4eightfivefive1lgscbj7kpcr1
+eightknfssevenfive6jnpklczrpfeightwol
+37qccxllhzshninebvpc8
+1eightmmcthkhf
+seven8fourqn7tbgqnmzcc1
+sixsevenone4
+clhdvjnqnine9threesix
+onetwoeight9
+81z3threenjsdhnqxvtwonezv
+9hqtsb
+onekgnlbthreeg3
+eightspnrpjb65fivevzfpvjntbg7drbgjccneight
+ninerdlsix7285
+fournineninefive3vbnhmhdvjgdqcm
+njzspqxpxrone7four55
+nfdhlqcpvzrrtsmzhgq3
+fourmfdtnpsfbxkjtgtgx5sixrppsqplqdjvnsixdtqvtdm
+21onesix6sixnine2
+fffsmvtt8fivenineglrqrmktzzseven
+fivefoursevencjxmskrqclz2
+lgk27threefourfsqrbkntbkfourvflgrzhh9
+617hj9
+ninegcxninetwohpfdxrb3tjjjtxtnvtwo
+one1gnftc8onehtsxsmg
+foneight3fsbhdqzr5twojbsdnntwohd9seven
+zkzpfvcxqnbvrg1
+nine36cddqfvrf
+rdjlpfk2pschfsdrpz
+nine994three8six
+three3nvflpftf2eight4
+3nine2
+rxxjdk5354
+hf4eight8qjtcfldnkvtwofivetwothree
+7six3twodhnvmxj1nine
+57seven3six6
+qklbvzfhclfnllhhgeight8xtvld
+5fgzqhkssmkcfour1
+hhvjkdnlffnineeighttwo18twonecs
+sevenbfzrgfm1six1
+nine71cskklxvcbnxtskdbqnpgklrxklcgccxjnssksrlkx
+hmklhhjdthree77
+3vpxclbgkpone3ninesrclfive
+djfqkgjvqpfvdsix5sixtwoeightsix
+eightlt7csvgxpnslk
+sevenfoureightnld2mxtgpbzpthree1
+11sevenglfmsb6
+onetjjnxvssg1four4drxbxpnpv24
+2zdxs9mfnbgfmjln1threefive
+one186ltsbck
+6fsbpb9sixhc
+nine818
+xzqcpcdprsqjbgknkvztwo419q
+39qfdlcnkhg31
+9djnlcrxqxhrcb8mczrxrm
+nmb887525seven
+jhmv3
+zhvdbn1fivem8seven4sixoneighttsn
+6zmmjqmnftclqbcthree
+6cpzeight92
+onepqfhtsevencvlfvnczhb91mmtdprqxmcnine1
+tvqdfxn8eight
+five6fivercgrpbtjgv87jmcndclbk2six
+jgtmrbvl68lpqkpxddqqxvsixfivesix
+nine2nlffgkvmp
+1frdnhssftg4eightgclxsgqtn
+2sixblr94six
+94mlfv
+6vlqtcsmdd47hpfmlc7fiveeight2
+tklxghxv5bzc4hhcdcpmnine8
+four6one1zzgqghvs412
+xghjpblsfpg19ntpfmcfd
+471rbdblzs
+69fourhjxkvd7fourfour
+jmrscfqdfppfdjskpk61
+five5eightnqpd9ninezknztwo
+onelknchr7nrfprgmqzp
+svxlxrx9892five2
+3ntkbzzpxhdmrsix8ttgp
+ndh7zlnrzpvmnine
+one7xlnbmjjmfv62qvqjpfprbvjkpcnine
+99three5
+threetwotwo7dhtgtbchc7sixtwo
+tmfxxph3eightgdccscdsrkmnhbb75
+joneight4one5
+nine3six
+81tqzsqpkv99
+sixvjlq7
+five7bkc
+five3811threelfpzztxzk
+1fourkkpclqc3
+xgrpbmktcthree46g
+bgcp4two8
+jtgeightwo7nine
+bkmcrcq3eightrdtvrbglmxmmztqm
+7tscmg5one2jhhbfb1
+zt5khcrgqjg5nxxzxzd
+five85
+twothree1
+eightsixthreetwo6b3tnjmcqdjfive
+onefrlg7
+fivescbjxbdnvslqqsone5bdbvskpmksqmmfsncsmd
+two83fourthreefourseventhree
+dglrmbtkfltwofive8ninelzmrxvxoneeight
+8nine6sixsixtwo7
+sevennine4lbsevenkdnrhpltn
+h3fiveeight4cplrnd
+vhsgjbqm3ninedfhfsb
+93nine7jvjmlzgcztrqlxtwo
+zhhhdddbbgcssvfzdhmpone5fivefournine
+l9fourvjfbqpdslkmvxsdrnsgcvzpjxm
+kxlseven5two
+rbtwonegsdgvsjtpnnkone7mdz
+phffknvthree2threeqgvfqxgnine7
+2lgglnmthreeseven27three81
+lrgkrxx2
+seventwokxvzkvq6eightthree
+5fiveseven
+fstwonersngdlngx28nine
+49oneninesix8four2q
+hfvhzvmjgbfcbsevenrmhjhzkc3
+six84
+8eight2gzblldzvkjfive
+6fz3eightzmsqb4qsbbsnthm
+fcglpc2one51
+sevendqghclrpxt7pzone48two
+three5one
+5sevenfivebbzkjlcnxseven8fourmzqlxxgjvc
+xgg8one6782
+gggtljnnsix3lkhdqzzpdtdkmjtgjddkpgx4five
+qrmsfc13onevnhlbgs
+nrtwonethreerbbqffzh62
+5eight81gcdbrx3rlk
+mtdtxcmm2bgmqhgqrtxsn8
+onercx2
+9sixoneqgr4
+xmoneightfour2
+six85foursixninetwo
+ninetwo8four8six
+qchclfzq47
+khrll3two21
+seveneightnine8868four
+3rmbmtbxjp12seven
+3tsxgvqxmzvxbdvxtgrvdbzqbh
+eight7fourjtxx
+fmb4one7threekbxeightwoj
+vcsevensixseven577
+2dkhlrrtrnbgzrmxm5fiveclhgn1eight
+1sevenlmrbnfour17seven
+three5jtbvkseightoneseven4df
+fourrgqxplbpbxtsgkm7
+fourqdfxchlc371sc2
+fqxlmeighttwo1seven
+zvvlftlhfthreesix6three46qkstxvdt
+m74pjgccfour1four
+plphq933eighteight
+cdbqlhbhj3eight
+4onevgdkxhz799five9fbljhpqmvk
+two6qzgphxl
+two1eight
+onekxxghlonerqqlrs83threehvvdhsxmfour
+npmsvvrdl2673
+fivejthseightsixtwo9vgrvjzbzsrxjv
+eight2gqfive7mzjzpxqcvheightjfx
+1bxckdpt
+dngoneightbtdptfn85
+fourtwovfzgmxjseven935
+8onesix2drgjnlrxbtdlmlznine5
+five4mmpmqlttsx56ljdzldntdvthree
+1nxxgtwothree22twothreenine
+38eightsevennxctjfstp
+8fourvhnps3onellstpnztn6kvjccmv
+1bseven93eightfour
+5nphkdbhxqb2pqxtkvhxq
+nvvx6fourjgkdsczjv
+fourxrmq78
+8tjmnvthree3ninetwo2five
+p7cvtwoneq
+7thbggjbznrsixonethreeninej
+xdgm1crqfnklk
+onehmqqgh4ninenthjonegfjmvtfgd
+sevenbsqtlk9
+8seven9two9hdz29
+fbcjhzdgzdg8jgjvcrmgbcrsixnine
+3bssqrj44onedqxvhkfive1
+tmmxtz5dtxbbcjlfivesix
+pvfqzksgrs4khmlvtwoeightlsx
+psbttsmnpninefour42fivegsixfive
+sevenfiveqscr7dfxpninesix5
+xmsjddzfxftsjfq6four6eight6three
+seven42
+eighteight1nineeight9
+8c
+pmqljjjzvx5znxqnsfour8
+78zlpxnvsqpgmgmk
+four7fsgttnrgnlslr
+fourtwo3jg2
+qlz18three5lpxfjvnfppqjxh
+4fiveonetthree4eight
+7lzffxkxnzjrtr
+three7nineone46ksnshqgdpt
+8dntxkkkgdxggvhxh2onefour5gqzsqkm
+tjsixonedbklrxxk2twonxdpjzb8
+mfglbrjrq93
+seven37xhsrxrvcgninexbmdrzxthreeonethree
+fivegznvfztszqlhtrsslsmqq43212
+tdthjjjbkeighteightsevenpcbmpfq2
+five1eightq
+three13three4vrsrrtp
+cgztjgqgdths2
+dhxztfvlonetwokszrv8prdpm2
+dfkcklchjj8twonine52ppvndfcnf6
+three7ninenkxfourfive
+93sixlqxctdhmvssixone
+oneqbvfrvteightnineninefivethree9
+jskrtmvsrqnpvcgsmxbonecmlrjpdpc4three
+crpcfour54xxgzz
+9fivefhdpcqsd
+fivenineclfctjninefbsh2
+fivexhrzbqpfxl8sixtwoeightllzplcpllk
+zxgl5qneightsevenone
+sixpdc17thxfive
+1twolftpzbmnzvdlkvlsevenhdvgfrjhmthreethreeddkdvht
+67twotwo71
+oneeightcgnhtdxpfnsevenoneeight13
+eightthreervd5tnj17
+ssrsmhxrsixeight3gbqggcvfqg29
+6fivecvcdxnxhxxtlzthree
+fournrrsix595
+p2qchlvplzdvchkbdzzbnsix7ninefour
+fourthreefourtzvlrnr9m94seven
+4jxzkrfourvtjpsnrllkjcczmmqnsj4q1two
+4627qlpscgpjcnine539
+two6nineeight
+63five66fivethree1
+skndgzsbsntwoone1
+threerzgdxgtthree2three
+953lsdgn59
+27bk
+sixmfmbslpjjsixsvnqrvtxznffive5
+2ninenlgpggxm42six234
+fdzfvkjnchsevenfivethreetscllgjvrtqckfnmz3cszmt4
+7ninetlzsxjsl2nine3
+shsvptqngsevencjjthvfm9six5four
+7lsrq36threevzfjc62
+two59threedxmfourjfschvqvnine
+khfqjmksxhbvs8sevenhzrmjtkgm
+nine2stgflmsm8fkthhhjzlszdnmkmqpnjxrfc4
+twofourthree244nine
+eightvt978
+fivefiveninesixnine6513
+2lbtz19fourtshqsvblhrkhxbpfour
+ptt7bntxhdvl
+mskflsslvdlmndmmqmfourtczqlssnineseven5xxxkfvzd
+l329eightsevenfourfivethree
+rmlksxsixspp9fourhlcg
+8five9q
+hqoneightsix19nine6xmjbtgjzgrhmlrxq
+six38
+9eight2
+3sixbzhgfcg57sixsixjtqmknd
+9fchn58
+vrpftbnvonefour6
+vqgdtrvhnnxxsevenseven9eight
+56vnine5rdpsnlqcbq7three
+vncrjds2cmrg7
+213sixfivesix
+tzclpzdsthree4sxgjvrzcrzcndnfour
+4sixseven1three7
+8fbrggzmtqn8
+four79p
+twonineqonemfour3dq
+5fdgpmrghtksn5onesixtwo
+xseightwongqqsxtwo8jslclldvnb
+nine1one
+9gxjrfourvhqzcxdhrtpxgtwonine
+eighthfhtnvchtc7fjkrxsmhtm7rbk
+thqxcfjbksix32xqrgqsqtx
+6qjqql
+jgcreight7eight
+6onesix4threeseven
+5vcv1twoeight7
+fivesthreebvjntwo9jdxghmxvl
+632msc9threenineqfone
+dqxfourkb4eight
+6stsp3nine
+566sevenpdmg
+xprjdn55
+9mjtcmhjb
+twoninelkjznqztbc3twolnhjhdbfxmhfr
+twotczpxn6qlcfdlpnq
+4ninefive
+1rs44three2gzczjdgq7ssmtgjbgbb
+ggmzqbkgsix4five23bftjlmbfbd
+threehfcscmmlqvcjtpthree98
+7sixsixone4
+2fivefvrr9four4three
+1zt1seven
+9hsbthqvhhsnineone23tslqccg
+sixbqvd3
+22148four3
+ninejlpbtnfive41rtzqjgfmcbncrrlnn
+9sixfour
+qnhfivetwofjtqtlxd7lmrlfctq864
+69dqrzhlqssgcsxtz54cpmjvrkcfiveseven
+fiveqpv85frkmpgxgc
+xxqsscldeightone9ngqtkf1nine
+5sixgxbnnjsvhf5dgxgone7
+sixsevensqghlvkfxnfour7
+8gmgvjbfivesevennine
+qj796fourone9
+rmpfsppvzdtwo4threetwotwo9
+dqvtrhm3nhtrxxccmfiveonedfzfvcghr
+4threejxkhnxcxjoneightp
+sevenhkpfgdgsgnvseven3m
+qhrvjcnfdbqchrsvchcxfourbkhhq9six1eight
+29pqnd
+1oneonethree627
+5977rcr2threeeight1
+fournthpqbztrhnine64
+fjnjpgqxr86five4sixxhrtvbp2two
+7sdnvlb5two
+58vffgzcgx4nineoneeight3
+h1sjgqbhndbz1oneqgncmhnleightwos
+gjms21
+onetwodphfznine51
+gxpl3fourzfz3
+five46
+mqsixccffmc9gqk1
+5kvxpqrrpeightthree
+threefoursevenfive2dhtbrxlzzl
+shhczssbltllsmntntlqfqgnnl98rm
+5oneeight3vkqtwo29
+bv69fouronefourone6
+eight6five966
+4xnrtztgfgcmnmnsevensix
+gmsvtnjd1sevennine4xxhqfbrjjqbglqjngttc
+mdnxhhteightfive5onenineninegqjbqmfd
+xonefourtwo4
+onesix61
+sjmnjhkj2892eightnine9
+nzseven39
+99nnjjzdrfsnjhthree1sevenfive
+6xmggtbnblnbxdpkzblnvcvjqmhvntwoeightseven
+76five6six
+chdfjrlfhdzeight778
+xrvrck9five1hrvpfvkdcb7eightnine
+foureighttq5sgdfourl2
+4rnbxrhhboneonefournine
+5four3
+1b97eight
+hlcjghlhsf32tgknm565knxqr
+onecqgbgdcmlb2sixsix6nine
+kxdkz3
+seven5xvhrxdm
+xblqbgkqgsixvgrthreezxnzhknklxhbmgl4
+fvnkc7threethreeseven
+bmbqxv24jhdg
+97rfphlxvtx
+4pgblonelone
+ptdpllrddeight3
+9knpjzskrfd4
+twomjqdtbbvmj4shvsqrone3
+9zzh3pjsf6mhxlhm9glglfztjm
+cfconeight47fivetdsmndgvsmbqjvszb
+21vbqjz374
+sixeightqgfdjbhfd4oneeightone
+tbccqdpz78srmcdx4six2
+643gqtvhkljxt
+klfjf4qms
+zrnhkhqzpczzfqsgsrtxklpbtp72
+1cnqfltrmhphg832three
+twoseven5
+mxkmxlcgsixklclrkfr8638fourlrqpzgjq
+nkbfkh452pthree
+zvcktvd2485four88
+rfxj4
+three6jnr7
+two45rldjnmxkjphtwo7v
+fivelncjffdnkzqrshvthreeh3p
+ninejgrbmhrbqldeightnine6nine8one
+96lvpt2djrkc5
+7seveneightthcxgthreeseven5hpfddktpj
+6bvn
+sixbjxtphstzgspnmkcvc952one
+gmmslrndvltlthree394sevenoneightl
+threenine7onefourtwojxhzvqlseveneight
+5eightsix4txcczzmg
+84seven
+skjpkhxggsvjbprhllgjhninetwo6
+72bdpzccvone4zbdzlllnnonernlfvdpq
+bvrtmzmtwonine29
+mrlvmdnlxb2814five5fjxzlhpn
+lmrpf82rksix611
+tvq18oneqnmmzvtclnthree
+jrbjc1zbbpqbrddt26seven1
+lxfivenmdtnhdmf98ptpxsgmgrxkmmznlk
+zbmvchmxsevenddddthree2dxlddjp4
+three3onejg2fqgtjmpcgeighteight
+three2two9seightfjqtwo
+ninefive8sevenvnssix
+3cnbxxtgmf5
+kpmjcsfrjfgzhmbpnqmlvrhbhqs8
+3vvcone64
+fvqksdsixthreexbfivetwo3
+sevenseven5
+63twoone8vhbcpmmlfive1
+4ctwo17eightsixkpvlgpj1
+rsgsnone1
+kbvxonemcqfive3eightone
+ninenineone45threepvsmrtonejxmbnd
+37fklnjkslqk9th9
+fiveoneq8rcgdxtwo8jfkxq6
+rgd7
+7rgkdpvp7qrb
+7crtxfmslxxtcxsv
+mqdnltb23fiveqcdqtonethree
+8seven7
+8cqhqlhndqjznqhdbld2nspnxbj99tqqhp
+onelqn7
+bvbjfour7
+ldqzhvhrbgsrrkh5j
+kjsjxdcqgjztldjvxxgr9twoxfknxrrrphkdzdl8
+rvscnztblp56ljqtwompclcf
+2dbtdgsevenhzctckvkvxvjljz
+tvmhhxbbxvvsnlnineqsltjd92one
+9twoqdmtvbxhpcthreeeight
+81dvnkd87xbct
+6mnxqnndcjfivefdckzmppfsevenmqvvvbnrgs
+lvl3qjk5
+3fivefive
+ktvsqzrf14eightmtnqbcktk5
+sevencdknznbxseventwo8rzggmvpbvlrs
+hkhhrdxlml1xzbshninejzqc
+eightseven23shkgzdgvvcxxfdv5
+14five1sevenxfmhtptwo3seven
+47one
+2three3
+f5dszzs2
+xmxffxkxpkninethree8x6seven
+glzoneighteightrnjqgjznjm9
+63fznqxdfqt8
+33nine
+4vrbmthreefbdzf
+fourninethreesixnine9fourlvbgqhjbqncnlbjbz
+two848dbvbninenine17
+pqzqgone1two
+eight7lmxbhcsix
+szr2fcvkljctlghhthree
+sk81pxqhhhhvnjvgzfiveseven
+cgqqkrz2vpdpzrthqssg7nineeight
+498eightfournine
+eight85onesvxnineone53
+ninevmchpkcg2
+six2shsvqfivefourtwo
+mdzckfvr72cv
+twotwo7onethreefourdjtgjg
+tworfclmm3
+5sfvnkrmrptsix7four6kzlmclm
+1onedkqgzbr89kphvc8
+5seventhree8eight9eight
+kvjpgjgrcmpdscbfthreethree4mjqjnnzceightwohh
+kjbmh1fdkdtznmsznvlconeznineseven
+1fmgpxhxpqznqscvbszhhcmglvtnzhbbjjbzg
+1mfqzkfnine5
+rrflkqslxztdlqxqkdnhqd7ps
+39123thhsmscbpxr
+8vnine4jgqrvqtshg3jhhdnbsrxneight4
+xkqgnfour87
+lsbnjqtzqz7ninenineone73lmkbnkhs
+9fiveqqgqblfivehttxk
+8twotwognd
+4xknbheightfour6358
+4cqtpfjpf72eight3
+ninemjpqpqg8foureightsevenfcvpnrnnpzhcgkm
+37twofivedsxrzbpchnkgxqx
+oneone57one2k92
+mckoneight9threefour1onefourhdrcrvhqcmngkjnsthree
+945
+tmmtwo7
+57
+6twoxzbfftnr27
+threenine4bqpztsixfour
+84eight
+3jpbnjrqhqfnxckqkqdvls
+9gzzjzz
+374nine
+ninembxeight4sevent
+threecq3
+cvn6cvqmpmfflkzphndjnggtktwosn
+pgz7four5nineeightsixqrnfkdkgh
+6one781vstwothreef
+one617fourthreefourxqxnpv
+8eightsqmkjkkf5xckcvd4lfnnfour
+seven23qhntfmg56onexkjxh
+f5s56rfltx282
+twosixninefive1tlzq
+threetdhghclfsksql5oneninetwoseven
+zbqzxmpb9pxlrthree
+r4gxdzjnvzfonejnpmfcpgvxjjvkh8
+five338threejkk67seven
+twolntxcnzvfr55sixtwofivesevennine
+xhlppbqfr71brvppsixthreefddlgpfslqmdv
+kxsklgonefjfpkd4threefive9six4
+6srphqmtdoneh3glthreefour8
+rjzdmj1cqvxnx1nvcvbfctft9
+3fqjdgbpggthreesix53
+9fivesndgmkvckblktzkshglqgdl4ztwoseven
+qqrxkqhnzb23two34nine9
+8hrmffgstqpsixeightx1six
+jngcsjnrhn2zsvcjmjg
+9zfdmhzxdnfour272dcrqgk
+lbjbrfhjxhxjphzxsjsix4
+fourthree2seven1two
+twosix87
+vrlqqkctddggcvcjcpk6hxbqvbxmtsix
+mrcgbpc6dthzqmmthreefour6two
+r2zntjxgpfqfmqh
+fourseven3
+6nfnsgchjdffttmgfnbvlxzoneseven8
+8sevenqqfiveseven5twojvgk
+4rmtkvml4
+bprnine85
+sevenmfpcvlblcnine485fourseven4
+sevenseventhree68fivelhqgjqvcdqkvds
+3fourxsgghqnvtssnvfs7nine7
+1fiveone5hpfdgvxb
+eight2eight42twotwoonenine
+lpdeightxcgpxkkeighthtjpsninemjlxrxtg31
+4smqpjzsixonethree
+mr6csbmgrdrjj3onelqd4four1
+5sixvbscchd3
+384sps
+4qzgsvmfx4ninevcclvcfrfp6tckcpvj5s
+8l5glclltgcjgbhcg6
+3ldtdmjc6threeone
+hsrtzl521nine5qqrtpdsp
+z4v8threejdsmbfjpbj
+9sixln26eightwovmh
+848
+kndxtqpfrqxdxtfnqrqznpgvp9ninerlzcdvdtwo84
+kmqs84775seven
+5threefourzkg
+43five8cq2kprvdqrmxr1
+three4ttjqdh
+48nine7sixfive
+22x
+sixrgtwo3rnbzkrztkdkg
+4t
+29bjpskmxneightppvthree
+zmlzxvtlkt4seveneightbxseven
+5two5eightnpszzmbkncnstx4
+9vk98sevenhznkxmlrlk7vdbqgvfjdk
+1sixb8sjkvdhfld
+one42eight4mrsdnpfjpvdtq
+76fourntsrfllxkdfqvm6seven
+skqndhr3nm4776
+4xpmfxmvj633eight
+83ninecmpt
+fourdthree9
+9eightjqnnmthcrseven
+7threekgtf1
+xscj7threenmhsixseven5s3
+cqlzjt41
+855threemlmmqkgtfk
+ninefzmvjjtvbmgf8nineninetwonegcn
+ccpkzcldfourkdtfkjxvfb9fourhbtwonsoneightnl
+pkeightwo5seven88rdnzzsdkbjeight9
+threen2fjsfivesix26nine
+nine4rz8nine7bglpcmkqfzpseven
+eight94six8dpgrv
+twodfctf278
+fltqtmdkgjsvf72three
+llrtzsixsix4fivetwosixone
+qjhtjqjhgkjkzlpxxclsrdnzk1gbqt
+sixeight1sixtwo
+one5413nkmqjtlbdkz22
+bhtwoneonemzpzkqeighttwooneqkmcmsbq4
+sevensix3three2sixprcqcvm
+25tjffdrtwohfqlkhzxlhb
+97gcgqgjnpsthfjfdv636jsxq
+zggjmjone1297six8drzs
+jbpvnineeightntkkshbjvr3nshnqzdlkjmkfive
+5four2gkkbxmpthreefour6
+5two15sixfivetzpg
+one4fouronemfpvnqseven
+9fnlbljdnzzfournine78
+djfljccrtvvqktzzvk61onesd
+7twohbkeight
+seven1eighttwothreet
+4mdcljknhpqgxffqpj5
+nine9jlsmfgdgntwothreeeight4
+136nh
+635ninejghg5
+cmone7fdlk9lfivemzvnhkcsp
+8eightnlndm
+6fourpb892
+fiveseventwosixfourthree7
+5fm
+ninegchdnrf63431
+24sgnflnsixninenine8
+snm9
+3fntd721dhhkrqqxsfpstsvzpgonetkhcr
+jlzfbml61vdmgb7one
+266517
+7fivetwo2vhchmg678nine
+cgrp3vzn5ninetwofour
+666ninefour
+9s
+svpcnlktpxtvk42jhsvvdpftxpsk
+2qznfzvbdr
+foneb7eightfivehlbjjknninethree
+kfp6
+l34pxxhxtd7d
+rsbcrtwo27twocqlmeight
+jkzgvqgpjfdqvmjfx2flnvjmgllxghhrbjjkfour2
+45sevengdnf59twofive
+6fivespvkblrxvkcgdxktl
+three9dvrssvl5eight4ftsix
+seven56gdmlbfbjsl894sevencmc
+814
+1one4
+onenine5fivekcrf1gvvfhlncsv
+2ctvq9djzddfxcrj
+ntdlcqgsixvmfvlc4fourvlhtvvqmnmkrm
+9nineseven1seven
+lcvzbnfourksvjqvmv47one5
+nine4blvlvlpkl6
+sixnqxrhnztzvpmbzmxjm19five
+18jtzhk
+rzrhv8four
+2npghxvjonebchsprfhsjznrxvxnine
+eightngsevencrjkxbhpgtxlzhgb46sevenqhqmlfx
+threesffl9fivelgmndjfvseven92
+seven85
+87six9vnshclz
+threetwo7915three
+one2vkbp6rhqbxvcl7
+bsbr1five91
+qd3mnine
+jjvhltxtdh5nineone6
+mbxlnj7bbhnxonejtmtqjfrzqgtrhkeightnine
+fourfourqrxdtfive2smnqp
+7tvjrszvrhdl5five
+four15tvmpvxpvdjnine
+sevenvv5tworpvdlseven3dlqvgblqtwo
+nkckggninegnlqlnv25threexlhlbzvzk
+3vngmhprjseventhreeeightnine
+nvqtpzsszrdvttfivenine56oneseven8
+146
+fxfbone59
+f32dhffctkxp6rcngvtfq
+sixthreefsixjhckmjqfive495
+42four
+65nine984
+5fthreeone9twoqqsfvzmp
+ttwonefive4
+one6gfxseightxqcq6
+3sixnrjtwormrncmhxeight
+jhdxnmsgsdsevensqsslbsndpdmznmldbgeight3tcvjjv4
+5sixtvpckxzcjzbmrzk9
+pmdmnfgkb3six8xsmstsmxgmm
+53onetvlgbglq4zbqpdgsskzdsksd6
+kzjcllvz6skphkfdxfiveqrbhmk
+75qqjdgxlmfthreevzbfjdlxkfqqq
+seveneightjntpjthzptwo2two
+2five4fvrfxxnine4qzkkfkmq
+2xlvcltn7
+fnmggtj2rqxzh7three
+rzpjkgtml1
+2oneseven4one7xps6
+rljfhfrhmzkjxktnszbkpfspxdkqneight2
+pzgnine49six2
+plxsqeight2
+eight2sevenseveneight8rfcrsdlxb
+sevenclpqqfxgjnmtwo9
+9sevenrqsixone8eightrxqgfsbjh
+kqtkstrxhtfzbllhl4lqvqkcbr
+hfplfpbltczflpp7nfive8
+ninenvqfrvtwo6onel
+threev65
+frhn18six9sixninefourrsqzgd
+mcxckfg5vpkbs89gbninexjzvlj
+fivesixdx28
+7ppbqv
+hs9twopcvpgtjnrsvksskpc8
+9mlpckzj2twothreefive
+rkrgdclkninetwo6eighttwodc25
+tfivefourtwohkhhgsqlj1dtdcxmxkf
+1four6five
+fgbvmvxvtsix2twonine2sixfour
+foureight66
+s6fourcv
+mxl358sixfive8six8
+ztbtwo73sixvxsix9four
+eight7qmdlcxfive5
+phgfivekrjxdmnzsqsix9
+1mfqsevenhz
+rjhcdgzngtc155bqlttbsxklpknvlmk
+qjkdqlrrs6two
+sxlmqzxdpxdnj9fivetwo9seven5
+2qtdblb2
+8qgdzrsixtwo598oneightp
+1shdb944
+vrlpronek2
+jm52
+8eightfourseven11mvtrmtkr2bmp
+mnvnjxrgmrxhztwo2ssrdpqk
+ztfive435three6threetwo
+tnrrdnbgnbhzljdxhxxfrqkcpeight8js3
+foursix6zcsrztvgjxmp
+five7fourgnnkspxcmczcbgsbdf77five
+fgbrzkmvgrdbqjqndpfive81onetwomtzlfb
+2qbsfd1two3ninetwo2
+8tdjxvfpvdvone33three
+lpchnmln56twofive8tfour
+cfkfbhppjf6fourdkfxsvdtbcjspzlseven8
+5fivestgkzsevenonedkhhrkthree
+37nine8six8onefhvvbkmgdfgtv
+26hzz
+5glvnsztmnfjmkjseventdm4five
+pvnnqrqvftrbcvnnthreenine5
+mgscxxlp3eight
+53eighteight
+two1oneqlcdkbddfour
+jbll3
+8threeseven5tmtrgdhqxd
+8twonine6s1
+91seven5pmqrjlhqrtzs
+jj3sevensix4482
+jeightwo7lk4three
+zchchxmsctzffivefournine9sqhqkgfour
+72xct1
+vnsxvsqkhpfvgdseven23gzcmltzgone
+xzjqhcvsix1fivecjtxnfivekmvjdc
+zdfourgjlhtwo24d5klkpdgqbz
+7sdzzdbrxbtonerjcmknnql4dfzqccvqt
+tncqzxjq9twofiveqkxdrxrpj894six
+dddmkctrzlpfmsszeight8zvbpmpkg
+three23ckjhgjc
+375jzdhnfcfr19mhsbnplqh
+vpbbjlzone5sevenseven33four
+onejzfsevenrbskjq1four
+seven13one
+vcnkfgv979one6zln
+rqlxzzbmjb4lmbthreektqsdcfzbmdsfivethreenrxdlkqt
+qkoneight8
+5rfourfivenine94fdprsix
+onexonelzdh2lcbqpzq6
+six6v
+7gtgxqnnine
+tsljzhntwo3fourpbjncgmvf3fflvjxp
+vfkdone9fivecftvmjdk
+xc5three6eight94
+18363one7
+8fiveksshdlfmzhljhcmjrn7kpv5j
+xbhmxfhbjnjzmninethree7
+2933mkmdqjcl
+6ncvzqxfvgfive
+lnine5fivetb4qmfktnqjxs
+93187
+5mqninedzkfhbk
+two7eightntdbsix298four
+sixone3bspxqxggkmkrbcqrhfrxrlgjrlvfl96
+fourfivehqls3nine
+threedfklszn2threeqzhh7one
+mqmftzglone6kjpgglznhrjz89
+146cvkftscqsevensixnine
+nndhdgpd484hxdgjtfsdxxg9
+6mbzckbjphg
+eight6jbjtnld2mdjtd
+zjtzcqxb736five
+jlkdmone8
+gvjnjvmlfvcmvnfb8xcgjcmjqvz1bzcctvsixfzqjlhfkfk6
+vr6onejnjmrrldnsixsix5six
+ninembtmtkgbctlfive45cjzzrmgcscfbcgeight
+2mdvneightjzgffivefive4
+hmdnbxghxjxt4czshmsfzc
+61six18threehrcj
+six3five6eightkdfzhxcjkdhq3
+jrhqrqkpd4hsixdsbjdpscclmnnhknqq16
+jflzcxr3three
+threefourghvgsktkc93cmjmsgh8one6
+96fivesevenslklhsfmpz
+jgkpgfnnbq2pmspdfhsqxfour
+g4fourthreerpkdhjhlxlzvnineseven
+xkxhkphnkvpdnlncn86srxthree
+7sixsevenrfour
+5zr72qltsrbdsv
+ninervqzdfzqmf6five
+8jslpvs73
+ztvlxndlm5twohdhmtrdnhbzdrxb
+seven6nine4dpdpvrtrmqvql
+jfz1
+5nineeight5onefivecxtqbsdtbthreefour
+fourgeight6threeszgseventwo9
+sixfour3
+npl8
+tzjkffsvbjseven5rhmlxonezlx
+5dhtpfour
+twothreebxtfndvdnine1sixbb9
+five9nineqlzrmtgs5
+9v764nineeight
+five4eightlsix6
+3nineeight21
+foureight8btsc
+3xgdgtb2
+7threetwonexqk
+kkqsix48onefourhlsh8
+onekgtdzgfh2fivenine2onerb
+six4zgcnlhmltrxp5xphvtwo9
+eight7cdqggpssix
+niner9pzmrbqldkljmgphrrgmdjseven6
+439
+twofoursixrthree5bxppnhqtx
+bmpnt3
+fivepkzkzpghrptpksevenseven83two1
+9fiveone8one
+fiveseven3lqxghdlskbltrzrstwo
+fournine3ninephlghonetwoeightbvmdcconeightq
+three2pvklmzqjfh4sixonedrctlsfdfour
+three91spjlscscjcxbbpdhrg37
+57qqjpdfppsix1qxrh5mlmncf
+4nfone5eight
+eightqsix7one
+4jtvxfd38hnrmqkbnvfxpp
+qmfsspkfour1plmslcrsseventhree
+fzckcbfvxbpsix7nine
+fzrj4
+4threeqntnineqstzjftnine
+tkrh6sixdqflrvtmzmfiveseven9ktmtvprkxhfour
+nine4983four
+mpllmjrfgv66five3kvhthplrtwo7nkklb
+9ngvdjddqbz
+5twosix8lbhmzrg
+eightsbmcfgm76two4hhc6
+seventwosevenrpm6threeeightwodxs
+xkbseventwotwogmkxhpmhm42hvvbfchreight
+gcqeightwosix8xdlhrnnbkmsevenqdbrjghz
+458ninextfjxvgsq5fltdsk6
+rlgsflhxqd5bdbhclmrthree
+twothreemqqbzjn88blvqxbseven
+rqrrdrmlfsixfive6
+eight959tzxkgqjd
+txdszrn5eight3cqeight1brqr
+45122
+jvvslnkdk6qnfzjzvseight55eight
+4twoeightgrhhkrvtkrzpfive7seven
+three8gsmkpzsmfvf2
+fiveeight5sevenone9twoseven
+4seightjjdkdglspz3vg
+sevenssrzkspld2
+qnzcvcthrsgjlnzxmxlppjdpnine8seven7
+eight7xhvkrcr
+two2tdjdfbqtqxrs119r
\ No newline at end of file diff --git a/2023/day01/example.txt b/2023/day01/example.txt new file mode 100644 index 0000000..7bbc69a --- /dev/null +++ b/2023/day01/example.txt @@ -0,0 +1,4 @@ +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet diff --git a/2023/day01/example2.txt b/2023/day01/example2.txt new file mode 100644 index 0000000..41aa89c --- /dev/null +++ b/2023/day01/example2.txt @@ -0,0 +1,7 @@ +two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen diff --git a/2023/day01/input.txt b/2023/day01/input.txt new file mode 100644 index 0000000..d6c4d38 --- /dev/null +++ b/2023/day01/input.txt @@ -0,0 +1,1000 @@ +9vxfg +19qdlpmdrxone7sevennine +1dzntwofour9nineffck +7bx8hpldgzqjheight +joneseven2sseven64chvczzn +seven82683 +7onefour1eighttwo5three +8lmsk871eight7 +ninefivefive2nine5ntvscdfdsmvqgcbxxxt +onepx6hbgdssfivexs +cdtjprrbvkftgtwo397seven +2eightsix16 +41pqdmfvptwo +xhlqvsjpbhfivefour5sevenonemcmrkvhkjqfour5 +2czddtpsrgsbgddsix6gvmxqlsnnine4 +twozxsix9kmctfour +3hqfxkzr2nineqdpgbzndxf2two +bjd99eight6sfive +oneeighttwo34dcjck5eightjznpzhxdlc +6sixeighttqslqvplsxvpxch +sixonemc55 +sixeight7five9ninesixfour +lmbzpzrhssdslkeight9eightpjj +six2eight579hlbgjnjkqrxrdlhnpfour +6fkfxsqncm456onesftkndhl +bqfckhdmppqvjlkx75dvjzveight8 +btfppljkfkzcklskgzzhmtwo9fjsix +seven44tgvh +rvmjm8nlg3ttgcjtwo +sevendjdckvz9nine6cth +dpxdpzbmnqsn8prggxn8twotwo4 +twofivesevenonedmkrnpznfhgh1 +gqeightwothreefours16gljkzgnkgclmrpsmfkq +eighteightsrfcxtvg7three1two9nineeightwolqn +18sixlone +eight7rxfbmhnsf +6twodndmhcgxlgbqbqndbbthnngblfgtzh5fouroneightrjp +3vpxlzkc +qpmbxctsmt38sn1 +threefivelxcf9eight +5vsptrhgltgqnkcgn4 +threeseven59 +83eight8sevenklzjcs2 +three5three6twoone9 +fkbfvltznine2bbjpng2zhtmmhnrjq3 +seven1xxjfq6 +7btxleight4one +xzsfive3rcxlczkp +8bjfmkjc4dxvd9 +sixddfg8onetwotwosbsb +gmvbngqgfour66eightcspbtjkzlxrqhfrsvfn +three91djmrkkdkrrsmv +four4eightlnhtvrscbf5gh5 +seventwo775dcg +85sevenfivesixslkjbninefournine +cljxdshd93rxjppchxonekmvpcmrzrv +kkzkp315 +three3jxmvjzzvtwojsj1seven +jvcfzjvfp5gsbpr5fourfour5 +jpfivetxmgthvlqnvjzdgrhknf4dvslqsxtv +jkvtctx6kkgkeight +jgsrnzzz8cf4eighteight3 +88eight1 +one674zclxfive +34nlkc8threexfmlqrxbpeight3rj +6six9onetgjmvqz63tnrrqlg +3n67five16ninevttnvbznlq +seven98 +5pkvtpzqs9mvpfpvhb +39s1one6phcgfqbgcvhpqv +sevensevenlhphq5rxffsix +kvvlqzmglmqddtt87nine +5npjkfhmnreightscqf +954 +five4tmeightkfdkhdfq34eight +smdqspmlv3twokthree +7fivegvgfhlqsqfxdljnnpninenine429 +sevensixdrsltf6fnhtcssfhpl7 +drctwoneeighttwoninebzvhslngqjhtwo1 +kzeightwo14bjkksx +35gglqtcjponenine4lhtjrtjzsf +six4two9 +88dpbpbrrnceighteight3 +jf24sqscmzfq +fourone9three2r2ninethree +2fcjl2two8 +ndshrmtqxtwo56eight +mhlsk7 +hcmx8792six3 +2sixonexgpzsjbmbqnxbtkbcvmktone +trqckccvgbdjt7eight9pcnrkxbxrb +sfqnzdlxqcdf56five27pfb +cffn1bfjkxdvcthreetvvxfzlrrpmpmddh +sxone6xzdrsdlfnn19seven8 +twofourtwoqxvpcjmnv3eighteightonetwo +9seven453seventhree67oneightv +28xmzcttr +five4twohrlthrjqmthreerzprxcbj +vlrdjpznp38 +98nphlf5ztrdzthreeddtnxrkhlzxkttpz +mqbntpz6eight4 +28nine +khkreight3 +1seven2fivebnjbzd +cgvdfmncxdn13tp5kxvfqntveight +7bkgncbfql68ninetwolfmltr8glvsdpm +7onesevennine +pjtmseven6mhcfrbqnmpbspsrcsixfpfkhjxdhq +256one54one +sonefour4 +vzbsj5nnhpkgkqhthreevlgfvnz6 +qtkrjxgrvs4 +four1fcglninemggpfrone2 +22trflsckfg7eighteightoneightrbk +sevenfive5fxmbktqfive43 +twoonedbl1seventwokjjbv +sixjlkfjnfkzfhvsj5eightmgmh +gxqjmnjp5pxdksnszcrfivepeight +eightthree5shxvhnzlhninefourkvchmxfj +two9mjkxhsevenddtbm696 +3threedrs3twothree +d1fivencnbrcvfcbvvphxfour +sevenfkgjgrt1lzfqzksddlcprlx9six +one7ckxzglncdgzxcxfour +three8four6dhn3 +5rphkp6three2six2 +7ztzzlnthree4three +rgxrpczczcsevenrphlhcczm985gdbjcnvjx5 +ggmrcxnrdxfdtd6 +meightwovdrpxgmpjqhpmrdsixhts86cl81 +4ninejdbzhtfkdnthree26 +9five8 +six276 +gbsphnmgz5smseven6 +fourgrjvpbkgninetwo1dkrcv +seven96 +2sixninexvmxbjttxb +sixnine3sixsixhvtxone7 +6x8 +773fiveeightxtrtshfivemcqxnvplx +182mfcthbstt2cvqs +13cone1fcgtchxpgs +three45nblglcktt +seventzrjngglvpcbdzfivexclqhsjdd5 +jhfmcqdjp8pktwoqgzskmp4 +pbsixtdvshb2three2lq68 +one9nine +8six98three8 +7ninethree1 +gbpchggch74lsmfseveneight +shshsjlqp7xggv2chskzzdfceightcnhrnine +twoone1fdzjkdhxeight1 +8hdxvfblkxfive1seven3mxhv +hfgmbeight9threefour9 +seven734 +three9three6 +dgnine4eightnineeight +66nmltsclptfptxrpj +5qcmvt9jhj8five +532qbhhz78 +3bvkm +34mpxdthree7nine4k1 +frls93 +sixsevenhtzjqzfthree1ninesixnpv +jzqgtptsrgx4nine9txzsqghqrbnhflf +7f84 +54sixnsdppg16nine5vcmlcqbmhb +4onesixtwoghhpmgltfkxldzjh7 +5gncbnhztwo6eight7ninez +5191jsnqmgeightwojfr +bvxzrjnhnjjfvvrkvxncs6 +dtwo4 +bgckgdpdzksmlrzfone2two +x98lqxzxrdrjrkbfk8 +6gmseven921 +q4eight3eight +fivenkjkrcvs8hpvnrgpcthreekjfnmtg1vntwo +7nine9 +lthqzvxmthreeonefourtwo8fourfour8 +vgn96cmdrnxs +94fourdmfpjfbgdc7sb5xldk +1eighttwodfzffvpv8eight +onefivetwo1five +6ttjvrlqv2fiveseven5d4 +87399 +7hblrjsxdphnplgsevendx +6312 +vtwone4five61 +2fdmhrbdssf +ztxbmttzvldljxrtt142tkfrfivesevenfive +zz1one +fivetwo98 +mcqggtklx39cdz7lkpxthreensztkfmc +qbzmkprpfd166qhtzpcjhkqpmqrdqtcdgfhtgx +95xjrltxrnp +4rsjnrone85 +qqnhlgchvvpcrj8dmcjccthreesseven +fivevbvqdftvxvgxglsevenlvrrknpk9 +3krqgv5fourq47 +ninetwosixvmt3one +fcfvzrsbrqcsdhbflhkn9fdgtjxn +82onekcxcvjv6dkk +fkntvmx8 +nineljkckkldnk6 +twoqdptcvnine5tnmstkrsixdc +ftwone6lmjlntfxptmnnnconepqszsbsbkqkvcxghmhtvsxvfldd +eightfivexxhjmxvmklhzt52mvh +1mmpxmsbpkf368sevennine +8six3 +onekh1 +74nine6gh1bbvsevenone +4pxzmslsevengdqqv +five1qjfxlstfsixnine6pqqseven +mgbdtwooneeight74hrfflzddfgtnmd +mrsqnffrhmhjlvqthreesevenseven6fxrfmhfv +two5threeeightthree +ddgsixeighttwo26fourgmhg +nine41g962khzsxzkg +qfvdz41svzprbzthreedsfcqksix +threebnbbs5six +msix1 +three1eightoner4 +b2twojnrfk2zsrzqfourthree +3onevqhp +fjszvhmsix1 +hhjkjxz37nbbsjpfg28btponeightxv +2six2krqlzph8 +5two8jmtkmpfxmkbjqxjbbvnfcgl1 +h2mg +3seven2nine6 +five5qbcnsfjxm5nptwotwo +6nineoneppcgf5threedcv +fournjkrjn9zd2cxsfmhjtzfourphflng +9seven33five1 +xjmhz86 +7sevenfivesix +3kpdzzninebjzbmnklkhvn +cvlcqtsix4seveneighthvhrfmsjeight +1p +2four3xrbhl +vonerdscjkztwosj8fbxskdzk7 +pnx8nqjninephdhnhmc7 +1sevenckbxpsix5stlhknddjmgdrpm +8vkltvtwo96 +88xccqf2fg7three +four75 +jrcfgzddtnlmvjxgttthree1threenmrbone9 +27btrxjlcqftxkkjvsxnine +8qvc98shcjzz +cjn8three9dphltgdrscdxpv7pzrfg5 +27sixthree +9one7nine3dvvfcztxk +three82 +bpszb42two9 +twofb5gdzxbt6 +threecrpmqbfivefksjlxgrggb8 +9eight9five872 +vtrsixjgccvbpdppthreethree1eightjk +37lh88four7six +6oneseven157fourtbzdtgnkgc6eightwoqdj +1two4nineoneone4 +2fourkqf +9xbqpvlfpcfdfqxkqv233 +threeeight3 +xc9three57pnlln +nineseveng1four +tfivefive6 +ninedkf6ninerqzdrf +ploneight675xmgxfrfour +sevenvsixeight1pxbtmklzp9 +dtldflk1six +fivetwo8 +eight2kbfmjsvst8 +one2qrtrfblvlnljlmnldmv7dljts +six39sevenphclhsdts7 +bjrfrzknhctwo138four9sixeight +hhttbnlrfour3fourfiveqjvzxdgrpxnine +rvjvqmsscrllhmzmbdlfqlkdfcrjd67one +xggzxpjmddfive5pvcdhllftb8 +5315one5 +2mtjxrxzlftmeightnineqgjpgseventhree +464onenine462 +three6sixzstbsq +1sevenone +seven1pkpdeight1qlxfgqpbkzdlj +1gj +4dzlfbbnfourfive9kp5 +q8m3four9 +94ldqfrgnd1two +38four489eighteightpr +threekxr261 +tworgmfzsd8jjtvdlxhdpzseventwosix4 +tcsvdphjtgrh2 +nmqxclrszlhgrn3 +5tzxvkxbpvqgfourmlmnknxt1hjnine +seven8nbvxqd1 +3zcqcsj6lfjvsfkfmrsplp3 +ts2ninetrmpjp57pbzfnfb +5onesqkk82 +eighteight8 +vkmrvxhjbr3tzjlfksixseven +hrlxjppxsr83dsgfxmdz6ninemlrnhz +8sevenninekvjmfl35nine +91 +35seventkx95six +eight4two854five +four4seven2 +fhbnqmlxthreeeight1 +7threeljeight +four9cvkztds4pqql +5klhghrvgng +hhz8eighttwothreetwojhbxfmkjeight4 +two9eightwocq +znj2 +935eight +55eightkdxcmm6fivemrlbsqtvxb +vzzbjkmjqktwovs5one +7vqqrqhcjtzxeightthree +34cfninesrcbczg91hptwo +63htjrvldqmldzzqrnslzcsfmlcgjmrlnf1zjdrgzkgeightwomrv +ljdpzttczjthree8five +flqjdbskkp3kjmcc9nine +rfcj78five +ttplggc924vdkbqlcrqs +ninethreeseven5 +5sh9 +four6vrrs1 +one7eighteight +4szmhdhgdtseven62nine9four +szsfkfj6cgrprx2 +38fourkbrlzzfhrseven2foursevenxdv +3ninejcghgdchzcffxtl7eight +61three +kbvzkmngj35 +gkzrtccmg3sevenmkdcskvsone +bg8txkhfiveonerdqvhrcxjrhrlndzjj +4v559three +ninethree4prhnsrmgq +onenine2lxsixqjsxqlrzkvzcninegz +444lxgckhmhxd19ngrhftc +nine76lznlninesevenfsrknvktmz +518onethreeeighttwo +vxzkrgfshvvtdpsix99vnts +nine67 +sixtwo2qtncmtxntfthree +two5five895ccsxdphn4 +768 +jvsgtwo7sixkhkvfiveqfhjdone +mqmnrqxbctwo5jtk4tg +2174fjrphztmg +lp4two +1qldfxjmzb6 +one8krbtzzdgfjkrmnfnlone737 +3six4 +nineeight87threefqjgzktgnffrggb +8xjhk +ninesmz44fvx +gktxcseven2brd28xzkflb +42vfqmq8hftsixeighttwoxkfktsgn +3fourzkklrbfh2hqvjmgggxrq137 +mthree8eightvjptjvpkhp8tvrzz5twonez +sc2cbrsrtcnskjsgvd +6jxhprlqpxlhkckmxxxplndps8288 +threegjhnbhzfn7977bfjqsqzdtjhxjpkvx +9sixthree +six3sixonedqgtqqzggfive7kgtksd5 +9djnf9htxlhkphzmthreeqxkrzpljhtx +4threefivethreevxvkfour8qv +eightseveneight1four5fourmvrcxvhx +tdhtwone4vphnspkn +onethree81pkbcljs3 +nspprpkgbnnine8gmfqzdlmdone +vblklpvlfmtcnxgshc1threevth7 +3ninefivekhcvbeight427 +5ninesevensevengjbhfbtjgnfhtmldczcgvmfqgrtjhdmxd +ninebnpvq8two4 +4lpsrkhmzxmffrq +four1seven1 +threesix4 +twobcninegnvtcmnxmq9 +58sixeight1onepdgk3five +mkkdvjfoursix2nmk +six21bljfzdl37seven7 +4eightvtbrr6532 +jf2kxjbfvg +6t +51mdnkqpnine9 +twojqlrlhnseven2one +qoneight5 +rmkhbb36four3vtwothree +vpxfcmmj6fiveonebssninetftgngbxfive4twoneq +twoseven16 +6lfivedpvfltcdeighttwonine +7krhmggd3578 +vckxnbsgqm4jkjtsqrp1tvvhnfkgsghcrrxqkvb +jmclhfourkqmp1 +jvtgthree478qxgprsxscfzngxgtgrfjfqqf +xttnzjcgsxvqrxmhlcnine9two14 +829 +kmb4ninefgtjgjnxzqjmcxqpprdonesix +klsnmqtwo4 +7pjjhtskhdvgtwoxsncbsnj +mhdhkfive23seven +zndrdh1xrsxmmxjvp8 +fktwonefcqstdshq8foureightsix +kzlfqmvbqninetwo4five +4sevenjffivezscdqskmfkfzltbh +1782 +6sevenfour +rleightwoqqnpsbprgtbvssjvd4 +brpfntx5hj +rqvhgqpdz62eightthree9 +onejgsvzns9 +fournjhjlvvqpfourtwofive6 +7jxglnsnhbglnjsixxdhbrhgmd +qznbkl9sevenfourqrnmhfeightjz +1threethree5 +four27znfzt4298 +9fivejvqfdcfqtlxhhm279vl +1dgvpsmnsevensix19vchfgbzpmqtdrksxczxt +twospzvsmjbfqhmcd5zznpgxkfbnbsevenxkzzfhzthree +4sixfpxzgblm +four7sevenbvhxrjf8ffjlbnjkp +73twogmnngcjsnine5 +3fdspqvvrmv +vq8zqpzfhmmdbgqx55eighteight +sixeight4jrzhqbjmcgzzxzgzcjcrg969 +zmsfklqskd79 +one85csix4 +9twodxfqxbhn +sevensix8xbfmdtzeight4bcdcxdlxmk5four +8fdvhpv8tcpqmjsbf6two9dsxrsndr +jnhsclvtltwo41sixfour2 +mnmmdmsqlxpeight9fjgjgnmvvdxsqlcninesbglbone +vleightthree7sixsxgd1 +dhsgn2hflhqzrxvfjbn +1twofivenine2nine94 +threeqtgdnf8gvxfourjjrbsjgksx +two8rlxcgsbdftlhx +1seventhreethree7 +dvksvxfeightbkccpztwo6 +35twokpxztqnpl +ctsnqstklcmcb1xhj +deightwoxbrkhtgszszqspqeight91zjff +onehrkvgs34twofourninennddpjtrkp +2drv +3rjrkmggvfive6nine6fouronethree +8twonine35 +gqnn8ldkrjcbd4four +8mtgpsflmlkcvkmffnstnqhzrfpscjhxpctvkl +89threefive3 +sixxnvtsixxrjqvtkkb1threertdfg +onenine7ndrthree5 +zfftwoneone59 +hqfzfivezpqkpptthreeseven8sixhb +six298xgsfvdz +sxbcgbnrlqsfhjgneightfive6two +6zninenine71sevennineone +txjkscxjxqvhrcmzzbxxxm6ninesix +cnsr6fivefvvbdjfgrnpqkpsjbgbm +tkhdhbmqbhfoursix46cbjpvqr7 +trbtfnsps769 +vkrtwonefour78onevktshzxrg9three1 +5vmxn8vcsxt8 +3eightfourpxblrzxlfx567 +626six1seven +six3fzxsdmlpq +44672ztsjrfkhk9six +8smbknine +seven42tt +five13fivetwotwonegn +98fivehpdtwofive +cvthree491xrhgvlsixp +four4threezkcfbqcl +4six8fivefourfourtwo6 +8849zcrrf2threetwonevc +zmzqvnnxskbbt7nine79five +8cfkzkzlgdx33 +6gnineqj1tmmxnhntqgcrjgrcz9 +ninejpjzphsrsevenvtkthgtcq6onesix3 +seventwo1threevrpfqgrdkrnvlftwothreefive +qgn4nineoneonefqfpvkb +twofive5569four8 +9czzvcrglj86mpxctcrrninefour +16one5 +5fiveeight8lqft +36oneoneqrvqzzlvnbhnvstjrlsrnlplkccjzjx +xtjgdvd3eightfb +vkx2nine1gghfcrdd +three3dzkxgxjvhgqvfnptmfj +8hgvvlgclpl +three7threefour +threetxgtrvz4eighttworkd +rpvlzbxs8 +hgmbvjfxdstpl7tnrgdjzvdtwo7bzhpcghnc +kkrsprlrgslpszcxmnine44z3eightthree +jxrljfivegtzbrhxmh6pqmvzf +twopdvrdffbzjrckcbvp4 +dfms7bcmceightnine7ninethree +xjpzpqtwo4three1ftpz +sixeight5two3 +r21 +1twofivefiveeight47three +483onehhfive9 +nbcfngdpqc4 +slnhjm3hcdnntfmbkvzthg +4nine5 +zthninevonesixcskc8 +sevenckbqvmjxjx41 +4c +nineninegmdpxkttb421jhmlxckm +onesixthreeone75twoj +6sdzj +4xddvcvx +3sixgsntt2fivethree +nq1fourm5 +ninesld9fivesix4dxtvnzdmzvxkp +ptwo8 +9fkvsxprvpf4five +6sbjzd4vdsfvkj9fpcgqksbg +kgrfsrr17twot +lshfkltwo88737sevenxskzzpzg +djxvsnghlm7sevenlh348 +4onevgcxlzmpncfflhtfrjrhf +5sevenjfzkqlpmxknine6 +c3fourvfpzhjcppthree29 +zninellddrfp9 +3qtcxrppjseventbjvfninetwommbchqbqzx +eight7sevenn +qbxqpthreelvxvkprjzsncnz1 +8gkrxthreeeight8ltwoskdvxkg +9seventwodnfghndpxtl +ltwofive3jzh8two +seven9qdngkndlbrhd9 +1m1 +two28fived +8one3kbppsdvrn2sevenhkrfive2 +8one24dkzrxmdxqfourfivev +dxfive11 +5glthvkgtzksixfoursix1 +jxxtpndkctfrhrssqtvv6eightchprr +qdmv9kbtnk5eight83 +sevendkmvljcv6eightwocv +lpzseven8onesbtskxjrhqhkvfblbjv5 +one5lvcjrkjklsfm8six7 +qjfvdjghsdgzmfivefive5slds7mlcsmlgnpfive +tsqkjjmfhlrcfjxxsx278ninebnc +threeknvkkvgpqrzbdn7six +512lkhpmdntsxsixzmpcp +lzvkfkmxlpsix7 +8fztrnfseven91sixxvbhtzghlcr4 +nine6891lnrfdzntsthree +rvfmdl92seven +tlfjnhpsix3onemhmvsthmkftbhcc +3kmxcjnsm8six +onethree479twolht9 +jdlsqp4onefour59lhdthreenine +qnlpgrsrlhtwoeightfournmsbl2four +lhptgljveight1vkbfx +sixsdgv6fourtjltcpkbqrone +nine1one1 +qxkrfczbpndp5gkghrqbcgcmmqrjjkxxf76dnjbnfc +3nineseven99xhmndd94 +6875twonefns +24threeeighttwo +3six1threeeightsix2sixp +xvone27fvmdd11four +6eightwolhn +gseventwobbj9bfrtdzsrjone7qz +twopbfdzddqninern5gxzbqcj +5four4sixfivefb +88xtkpjtthreefourtcldldhk +mnbxx1 +2dvfour2 +eightfvrsnk27 +fivexfnblfpp77qfour1mrfrphbg +6lgddqkjqheight +rvtwonemdxgfsgnnc98hmonexvmhkzkmjt +two6cglzbdklmjqjncn5xptwovtbhvmgsd +sevenkvxn6 +8eightjkmtncbrv8199six +sixd14six665 +gbkfpnnjxpmdfivettvdpnbrk16xdnhqkrpljfq +58vgmvzx +onetxxzl9fivelhcfpkvrsgn4 +25two6mcrvbkxrtltrbsfour +517 +rvqq6ninekfmninefiveseven +five2jp +qvlcmsqpvmjbjknvlknzfxcqp5 +1ttsbmjz8bmgrjvtrrthree8dlrjeightrjjvcbcpmv +95sixtwonine1 +tkpjkpbq16 +lstsfrltcm1qbzx9 +three713three +onetwo4eightfivefive +7sixxcfive +52two9 +xngd1 +8eightvmktwo4eight +sixgjjgvtznrskhxnsonetwoqdhtone21 +9fftwo3 +5ninevmlvmjnxvb91fourqbnnfcz +hpcmsgseven2sdp82eightwot +3five8 +jnxd6 +3vfgbml831dkbqsix93 +6pdlllrll3mskssmddnine8three6 +4vsdqddkfivethree11pklbpk +47five +58fivefptcc3xfqvkxqmd +eight94mrvtn93eight8 +6fdlbrbbninebmdptsfdzmeightzqmxvpptps +1ninegcgcrcgbvtfptlgdthreenflkdhjqjctwoneh +8ppqpvrphfhrkgqjrseven +knklcdrcrcjt545 +ztmqxsevenhpqtgknssnnvdssfpxztwo8threeseven +xnhoneightf2five +r3tworkmgkqvtf77qtbxg +threeone41five57 +fpsix7jrkmmxlhqknjbldthree38 +pzxlnfj2 +sevensevenkbjfvtfzbvgjvzkmnb8eightgggzbz9 +zqkvgk3 +vcpvzhxsxcglhtvmcn2zmqjkxconeonesrdmmmhgjrgkszhxj +dfjhvgftwo1 +8fivetwofoursix8fivenine +rfive5eighttfn1 +fourrnine4bh +gnh9nine4pbbj +4129four22llnx5 +cvdrdzlbmhjchfmvdhhztf4dxnrpvr +31fourfivegl2 +hp2eight2klkzlthmd2 +8mzghdpvjkseven667 +eightfourthreehhxjkljdeight9twoone +d519 +zlcncbrbnlblfxjtntjkmh4939 +3484eight9five1one +6two365vvllsqcsmrzqnfgrf +qqtntflfoureightdhzrgg84eight +43ndrxmkznbnseventwotfckg9five +gqxghcjtmnine1 +622 +nxfdgdgmnd6ninedqnfnvnlkoneeightwob +nhnfgxrninesix47 +9nine8jvqrv4two +ldjklnnfour31oneeight3 +dfhdmtqrttln5five41 +4seven1six52 +6nz498sixhbsbjxbzxr +gpx4four5246 +nqzsqjhqmrninedfxkmnine9431mdgbkn +ghdfpkxkgtjbsqvmqjsbgljrpbqggpgptwofour8 +2pmckttc3663rkshqjmvm +1seven7gzsevenks8 +tchrd7nq44 +pljkrthree2 +four57 +five138 +k36 +fivednxrs818 +three6eight96eighthvpcrldfiveqkglq +fivezbnmsevensix3eight +qbfeightwofour3pcr1sixseventwo +three4two7 +fivetrdfdqpbt15 +26nine1 +3sevenq8eight +two669six +5p4eight219rgkj +76four +jrmnkp1224qrzg6 +29eightninelvkxbt8 +seven7vq +lgrgxxk2sbxbcvmjqqs +4threesixshtxpgdhnine38 +6fcmmzhgnmm8 +lxrtjvqzmzeight2ninept +2hqd93sixone2nine +m1 +4five5threesixnine +7sixfxrbr +eightsix369one +foursix7seven2bmrqmkb7dbvzrk +35seven4onesmsbgbxlh2oneknnlnrg +hmsevenfour84eighttwo +eight73sevenseven555jklfjnrts +ktqbgzvdqdcbreightjkjz4dxnfpfgjs1fvfpbczvt +xflxseight7smkkkdqsrgoneightx +9sixfive3nineonebfqbptl +rkxtmcltxjeight3fivetwomsjpjdm +4bldszkxzrq1threetd +gnpthree5one +3onesevenvbfghbzksrlkl63seven +6xjqqsztdsnine1fournine3eight +8957four17 +three75 +5zlsixtwo78 +mjqtlfqztt55eightpsevensevenkrdrvsqxjtphpp +rztvsc9four5jsrcnvc +2fgstpfournine +onesjjhlcg1nineknqhlr +ldfone9 +threernszcbdxjdhbmg1eight4 +klkmktxqfz4qcvptvdtwofive8 +3sbpvfxpsvpsnine7nine +threexdsbxxrxmmndql19pxzvj +1cbn7hvhggznffkp +41f +hdmgqzrhdhseven25zdjdqrrpksixtwo +2two7ninesixscd +two5twojjvkjbs +eightsix186twonelp +xpdskdkmjb5hhnkcnxrdbnpj +96fourfour +7one22 +1one2qkjszlfourtwoeightgmlfkgsm3 +klqmpxqzhhhk1sixqmmfnmbllqjkvlqdz +nmgjmhsevensix799 +rrgpsbmnine9ninebqdgnxfsix +xrmslkfkzfiveninefzzbn7eightndscmjqsldlclkmsxbtjstzds +bqrjjrbgsixsixjgds1 +7fmtncmjbgcvhfhlhzzdlltpdscszrlmk88 +fourchvjlhzxxtwo94 +six2one78vkrqvp2sixvhtmqngtk +fknxmgcljbxfkkbdkbl868nine9 +height12fjt +knrlb2ninesevenpzjd +threefourkxtmnxbtfiveeight98fvnkvrx +3xxszc +vhp2rxfrhteightkfive +cxlzglbnineeightsixxlphhkkkl7eight +lcltksrvsevensixsixtssrszb55 +21sjzxsqvlj1seven293j +3gkjdshvxkfmxnfkqhpfour56 +kgdbqsmxxqone3p4 +3m7hmbctwo297 +4vvr5 +eight11 +nine1six74vzdllp +1nine9756sxr6 +9sevenfourtwovxbshb +qcgztnjjvvfiveghlbr7 +nfgngg7fntfv +threeftwonndpzp681 +llbmvrfive5slpjkrpslcthreer +eightrgmglgds3ggddvtfbrddhpktz +75nineonethree6fourseventwonek +2226 +4twokt8 +2svschdf58eightzpsk1 +gqxthreetmfourcqvzponethree2 +rbsvrl616 +8threeghjeightshsnheightrvrfhvzgeight +6klzknkbkxg76cs38 +vfive4cxrnmkfnmf54cffsnrsbhjtwo +twozclqgkdfmqfzvjxzbfonetwo5tgrfive9 +hphppvb43ninefive3 +3tx76threeninefqdtspfxqvq +5twoltwo6lvqsfd4 +bvzcthreeqxbjrnnm5 +61five +nine1fgsdjvdfrl9ninefour11d +hfzkbvmbrbh866ninefour +4spfmhsdbqn +fbgqhzpffhfvrnflhttrmx7fourfourrrfrcrnbbcsix +xczblxnpjjhbxlpffzchjvhhj98jkhvjphb +two17x +twodkg2three +4ninefour2grfive1eight +sfsvv5nineninevgshrjonefiveone5 +fiveqqpggmmptjcg5seveneight4threejqpn +8sevenfoureightthreegrrjlgn9 +6fnmtzfqfive72three8 +7nine7 +1threelhddbxnndpsgxnb +73mpcjnhcn +2knbcxnnfvthree +two4kmbrxzrqgtnineftjlslgdz +f36992ninefour +26fourninesixthree +zvggfbznineone85nine +three7threehfour +4eightxq7vxdqxjdntc +8nineprhgqb9rvkcssflvck2bghnf +kbkjxjs4eight188rjlmmdgcvr7 +fnkcbmdmbmnglztltrbcnineone6 +7jjgtlt821 +78xfgxrtm6four +9k5five +four764one +4pmdqzcceight6sevenrl5seven +ckhvfc92jdrxzxhzgsnkj45 +sgveightwolhl8one454pmcmks7 +hlpbfkqtnjoneeightjnpt9 +tnine8 +ddlhfqglnftnd4 +pdpdvdgdr3twofqzjqqjp8sixtwo +jq4onetlpzllzmk +twoseventwotwobpone1twok +3759qbxgjfivenine4 +vhxhh31 +cbfkfld3one54 +bpchvxkvtone4npnkccpchvf16sixrpcrftmc +3sixeightmhvbxthree +2six5qeighttxgfour41 +vjchfvn88kjsdzvkzphlhgsvseven5 +823nineqd369 +377 +8ninethree7 +jvvvz4 +mldjxseven2 +two2xvjrjvqsx8 +ftwo91 +zhndzkhzcqone332 +vcssgkmvneightcdhm1przq +8tfvgcheight76 +zqxthsnine7nine +onezsklndhqllfourfive24qmlvgtm7 +jgh8h1six +six23 +threehxhvsqpcxrnrpggtwoxtptrlt95 +rhcxxeightthree444djzcckrst +9onensgone1eightmfkftpsfctqmn +55eight +656cpbmgsevenrsqd2onefour +3sevenbjlggzzfzxnhkzxtbpgxqbrfgtb4 +3hhbrdtmmrzssfmtv8 +28szkfjnzrcv +7twopthree +hnp42 +5rxg6 +twoeightnfhdbndrtzltninehdtkheight4eightwolpr +33sevenmggst +2fiveseven +fhfrmgnsfcthree849bznbtbfourfive +1twooneone1four +fourxlvsgqzzpkzgmsixtwo63 +nmcmgkfdt2fiveeight7 +qnhjdccdqdnine41tjzbpzmztwo7 +1eightkqftvgmgqnqqgvghvhds4 +49seven59 +6trfive9 +sixbtrqxgsdjl6three +eight4seven +14xblhzfdbxeight +sixlbthqhcmrn7five2eight3 +tpltwonejjvqkz8onelgndpsvxzninenineseven +sevenfive8twonez +dkzrpvtkhq664pnine +nine1m6 +ltwone1fourphtqthreethree1foureighttwo +threegmlxrnbkmjfvlbmdhn4mcchtmcninetwodtz +ninerknt1sixsevenfive +6vzpjhtwonemc +sixsevenninexmf6five1 +qrkvjcdvnkh1ssfmqxqmnine83three +8cjtsf6hmmnveightsix82 +zphqxnsevenjklnhmfphcfoursixtbmtmkeight5 +3sevensevendnxdrqskvx +vpltgsevenpkbspnfzc5qmbdb +fiveseven5dgkdpjxtzvffqvltwo38 +ninesxljqcmmqf3two +one19mgdbsmsonethree73lmdchhccc +27six +vd6seven946h +fourthreerqcnchsfourthreefourgghcmcjvfv4 +mmjhninefiveseven5 +8eighttls2 +bcconeblccrjckjpr5tqbvpm9 +1rggt418threevmjhkdztqm5 +687jzfltlveightone1 +nine5seven4ninexmgnmpqnc +6cbthree2 +mdhrs4tqddtrhzxscxxggkgcfiveone +5rjfldggflcslhkkjllthree631 +94pxssc6eighteightfivesix +fivezmjqnlfggqzsix9 +fivefour369five5 +4stgkns3xz +threenine1 +7qttnmpld89fivetpxgzjhgjpcrhm +eight158 +16one +ninefqbmlkkkhppbvlljbeightc6onefkthmhktkbdjc +eight533gzndzbl7sevenninefive +fournine6 +49pscnggt6one4 +six2seven2fourmeight +xdvvgsevenjpdjtl7eight6onerj5 +cdmcsjbt7fivevvczqvdpqqcnxttk1two +fivefourfivespmgsfghdqmpqqvngj6 +6fkrqlc +qffdddhmxck23nvnqmczxpvnb8eighttwo +j6xhzcgskqzk9qtnine3 +three224vdsix +qhl8lzcvdskb +six9hxgm +six3lm8xgptktfbml3 +3twofive1threeeight6 +933seven7sspmm +vvxkvmlpzn7 +2six6onempljqttngeightgrzkxxsbqb +fourtjgmd254two +jptqbmvninenqx69 +cqcsfmzx4kvrcpjm +jmmmb4mpdxrkvqc5dthree1seven +psmpdnmb3hthree +5612zvndmk +cdfmfrxrhvsevenbpvpxtsmr9two3 +six7fourt1sixtwo +9sevenfour4fdzseven5vdcgvqsix +dffpldbfourjlklt99 +vhmbrd8qhglxdgninefourdnvcdzfzhssqnmfnlgeightrvff +sfxkfhx8 +qglscpbxzffivenineone41hbzgjfzzvghtrklp +rrzvzbqkjl4 +sixfour1zkqtmrkhm26six +2rqdcxnine76seven9five +8lxnzzt514 +gdhdz572bhbhqhrhxdninebvv +3one68eightvjtrqg +8775mdcqcjthreehhrshdbtss19 +ddgjkksvhseven22dqsclbgl +six7vdsix4 +fsbtxfmdzlfxqxpfdxl65sixjpvpkjhqp +l4r3mgjninedqh +four2cmk6twoczsnqddjdxgm3three +gsmhmkfsz8mfninehx +5dhgpmdjmdvpvmbone995qdhmmjlg +tfour35636fiveseven +vfdv8bzvjqbfpsix +sixdgfqgxfvr6tdzhzkzknbl +fivefoursix83eightsevenrcqprm +eightzxxvckndp58zpq +66one +8xlgdrjnhxphtsstrptninetwojgvkrprtzklcpjbp +8fzdtf +8hkljkkck5 +onefivesix6nllxhcczxdszxnxpxbpthree15 +85oneighttx +1fiveqkvflmzsgdxnnthreefour +8fczsixone9sixfive +eight9onedtvszfxsqpvdzmsevenfivejghsqvkhn +foursevendmrgdbngndeight6fivendmgxkh +4446 +9kbrmsm2eightsfxvldhgsznrlqsixhtfxxllm9 +8trchslhdfxxhrrkonesix74twoone +eightnine5cfsrfjpxh141 +four6nine6 +threenmxeightseventhree9threevqzfg +three9fournineeight25 +four5nhd +nrkzspjpmfcqxthreerxpxlcknn1rkhggsix +kzrdjnvxfone5sixsixrdnbvgtwo7 +ninethreefive3vmc63ninebkccndnmq +seven89eight8fjtfzqlrbmnine9r +lbhkmjxx46one4 +32121nine2 +seveneighttskhdjninezzfh4clnhstsnine +9fourcvhseven +pbheightwobpcpfzqfxone6onejmmmtgvhtfour +62rkfnbkjkqzthree4twoeight15 +six1jgpvqtwo378 +4stwosevenxfnqcmglgzxtrbhvd +nkoneightq35srthgtnjpd +three6ctx1fiveeight +eight9eighttnthsddmfz8mktrsix4 +eightpmqqxfqcffour8xflgdscrzmbjhjq1four +648one +threesix88zdsbmsmch5 +fourdpkgxggzvm3 +262 +597onethreenine +2zsgllcmjz8hvvgbzxpv29qdqnfrj +63lxzjglsk59 +5nineclzblmhqzoneninesixm +6eighteightfour9threehnine +pjrqcmrntwo5g346hhstlmgx +fhgkhdhqbzrlone9fiveknjmthreethreejqgbgmvxlq +onesixmhhfckkhcbzffthreegp6 +foursixkbvzvnsdtggpb68onefourctst +6zlrrqdnineqfjjq +4bx +dqnsix1onefqlsqlmtlcgpsfrkcx +4three2czjxqbf8s4vhsc +fourtwomdfiverfmsgzfour6one +qgpctkpdoneonefive2 +vks66 +four5725eight +tdrxflfkpgtwo35three +eightfivebxs3 +8four4298gtfqnmqvqd +7jhvtfxs +961cvmsbzkonefive2 +rdkfxsix4tnmndhnxnv86 +two4dddpmrhh7fourthreeeight9 +slhdsxngfxszspppxxfftmxlptzhtwovp1 +4vmzcrhtdvnm6zfive5pkbhcxj diff --git a/2023/day02/Main.hs b/2023/day02/Main.hs new file mode 100644 index 0000000..5b235d2 --- /dev/null +++ b/2023/day02/Main.hs @@ -0,0 +1,26 @@ +import Data.Char +import Data.List + +type Parser a = String -> [(a, String)] + +char :: Parser Char +char [] = [] +char (x:xs) = [(x, xs)] + +failure :: Parser a +failure = (\a -> []) + +return :: Parser a +return v inp = [(v, inp)] + +parse :: Parser a -> String -> [(a, String)] +parse p inp = p inp + +main :: IO () +main = do + inputLines <- lines <$> getContents + + -- let arePossible = filter isPossible lines + + mapM_ putStrLn inputLines + diff --git a/2023/day02/MySplit.hs b/2023/day02/MySplit.hs new file mode 100644 index 0000000..2bb5f3f --- /dev/null +++ b/2023/day02/MySplit.hs @@ -0,0 +1,41 @@ +import Data.List.Split (splitOn) + +game :: String -> [String] +game = splitOn [';'] + +reveal :: String -> [String] +reveal x = concat ( map (splitOn [',']) (game x) ) + +colors :: String -> [(Int, String)] +colors x = map (\x -> color (splitOn [' '] x)) (reveal x) + +color :: [String] -> (Int, String) +color [_, i, s] = (read i, s) + +validColor :: (Int, String) -> Bool +validColor (i, s) = case s of + "red" -> i <= 12 + "green" -> i <= 13 + "blue" -> i <= 14 + _ -> False + +getColors :: String -> String +getColors s = tail (dropWhile (/= ':') s) + +isGameValid :: String -> Bool +isGameValid s = all validColor (colors (getColors s)) + +isValid :: [String] -> Bool +isValid s = all isGameValid s + +main :: IO () +main = do + inputLines <- lines <$> getContents + + -- let arePossible = filter isPossible lines + -- myColors <- isValid inputLines + print (sum (map (\(_,n) -> n) (filter (\(b,_) -> b) (zip (map isGameValid inputLines) [1..])))) + + -- mapM_ putStrLn myColors + -- mapM_ putStrLn inputLines + diff --git a/2023/day02/MySplit2.hs b/2023/day02/MySplit2.hs new file mode 100644 index 0000000..baee8ae --- /dev/null +++ b/2023/day02/MySplit2.hs @@ -0,0 +1,50 @@ +import Data.List.Split (splitOn) + +game :: String -> [String] +game = splitOn [';'] + +reveal :: String -> [String] +reveal x = concat ( map (splitOn [',']) (game x) ) + +colors :: String -> [(Int, String)] +colors x = map (\x -> color (splitOn [' '] x)) (reveal x) + +color :: [String] -> (Int, String) +color [_, i, s] = (read i, s) + +validColor :: (Int, String) -> Bool +validColor (i, s) = case s of + "red" -> i <= 12 + "green" -> i <= 13 + "blue" -> i <= 14 + _ -> False + +getColors :: String -> String +getColors s = tail (dropWhile (/= ':') s) + +isGameValid :: String -> Bool +isGameValid s = all validColor (colors (getColors s)) + +isValid :: [String] -> Bool +isValid s = all isGameValid s + +getMyColor :: String -> [(Int, String)] +getMyColor s = colors (getColors s) + +myFilter :: String -> [(Int, String)] -> Int +myFilter color s = maximum (map (\(i,_) -> i) (filter (\(_,c) -> c == color) s)) + +main :: IO () +main = do + inputLines <- lines <$> getContents + + -- let arePossible = filter isPossible lines + -- myColors <- isValid inputLines + -- print (sum (map (\(_,n) -> n) (filter (\(b,_) -> b) (zip (map isGameValid inputLines) [1..])))) + let myColors = map (\x -> getMyColor x) inputLines + let myResult = map (\c -> myFilter "red" c * myFilter "green" c * myFilter "blue" c) myColors + print (sum myResult) + + -- mapM_ putStrLn myColors + -- mapM_ putStrLn inputLines + diff --git a/2023/day02/Parsing.hs b/2023/day02/Parsing.hs new file mode 100644 index 0000000..1974be1 --- /dev/null +++ b/2023/day02/Parsing.hs @@ -0,0 +1,122 @@ +-- Functional parsing library from chapter 13 of Programming in Haskell, +-- Graham Hutton, Cambridge University Press, 2016. + +module Parsing (module Parsing, module Control.Applicative) where + +import Control.Applicative +import Data.Char + +-- Basic definitions + +newtype Parser a = P (String -> [(a,String)]) + +parse :: Parser a -> String -> [(a,String)] +parse (P p) inp = p inp + +item :: Parser Char +item = P (\inp -> case inp of + [] -> [] + (x:xs) -> [(x,xs)]) + +-- Sequencing parsers + +instance Functor Parser where + -- fmap :: (a -> b) -> Parser a -> Parser b + fmap g p = P (\inp -> case parse p inp of + [] -> [] + [(v,out)] -> [(g v, out)]) + +instance Applicative Parser where + -- pure :: a -> Parser a + pure v = P (\inp -> [(v,inp)]) + + -- <*> :: Parser (a -> b) -> Parser a -> Parser b + pg <*> px = P (\inp -> case parse pg inp of + [] -> [] + [(g,out)] -> parse (fmap g px) out) + +instance Monad Parser where + -- (>>=) :: Parser a -> (a -> Parser b) -> Parser b + p >>= f = P (\inp -> case parse p inp of + [] -> [] + [(v,out)] -> parse (f v) out) + +-- Making choices + +instance Alternative Parser where + -- empty :: Parser a + empty = P (\inp -> []) + + -- (<|>) :: Parser a -> Parser a -> Parser a + p <|> q = P (\inp -> case parse p inp of + [] -> parse q inp + [(v,out)] -> [(v,out)]) + +-- Derived primitives + +sat :: (Char -> Bool) -> Parser Char +sat p = do x <- item + if p x then return x else empty + +digit :: Parser Char +digit = sat isDigit + +lower :: Parser Char +lower = sat isLower + +upper :: Parser Char +upper = sat isUpper + +letter :: Parser Char +letter = sat isAlpha + +alphanum :: Parser Char +alphanum = sat isAlphaNum + +char :: Char -> Parser Char +char x = sat (== x) + +string :: String -> Parser String +string [] = return [] +string (x:xs) = do char x + string xs + return (x:xs) + +ident :: Parser String +ident = do x <- lower + xs <- many alphanum + return (x:xs) + +nat :: Parser Int +nat = do xs <- some digit + return (read xs) + +int :: Parser Int +int = do char '-' + n <- nat + return (-n) + <|> nat + +-- Handling spacing + +space :: Parser () +space = do many (sat isSpace) + return () + +token :: Parser a -> Parser a +token p = do space + v <- p + space + return v + +identifier :: Parser String +identifier = token ident + +natural :: Parser Int +natural = token nat + +integer :: Parser Int +integer = token int + +symbol :: String -> Parser String +symbol xs = token (string xs) diff --git a/2023/day02/Test.hs b/2023/day02/Test.hs new file mode 100644 index 0000000..6d21d48 --- /dev/null +++ b/2023/day02/Test.hs @@ -0,0 +1,43 @@ +import Data.Char (isDigit, isSpace) + +data Color = Red | Green | Blue deriving (Show, Eq) + +-- Parse a single digit +digit :: Char -> Maybe Int +digit c + | isDigit c = Just (read [c]) + | otherwise = Nothing + +-- Parse an integer +-- Parse an integer +parseInt :: String -> Maybe Int +parseInt str = case reads str of + [(num, "")] -> Just num + _ -> Nothing + +-- Parse color +parseColor :: String -> Maybe Color +parseColor "red" = Just Red +parseColor "green" = Just Green +parseColor "blue" = Just Blue +parseColor _ = Nothing + +-- Parse the entire input string +parseInput :: String -> Maybe Bool +parseInput input = do + let (numStr, rest) = span (\c -> isDigit c ) input + num <- parseInt numStr + let colorStr = dropWhile isSpace rest + color <- parseColor colorStr + case color of + Red -> pure (num < 12) + Green -> pure (num < 13) + Blue -> pure (num < 14) + +main :: IO () +main = do + putStrLn "Enter input (e.g., '10 red'):" + input <- getLine + case parseInput input of + Just result -> putStrLn $ "Result: " ++ show result + Nothing -> putStrLn "Invalid input." diff --git a/2023/day02/example.txt b/2023/day02/example.txt new file mode 100644 index 0000000..295c36d --- /dev/null +++ b/2023/day02/example.txt @@ -0,0 +1,5 @@ +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red +Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green diff --git a/2023/day02/input.txt b/2023/day02/input.txt new file mode 100644 index 0000000..876d2a0 --- /dev/null +++ b/2023/day02/input.txt @@ -0,0 +1,100 @@ +Game 1: 12 blue; 2 green, 13 blue, 19 red; 13 red, 3 green, 14 blue +Game 2: 12 blue, 1 red, 1 green; 1 red, 12 blue, 3 green; 5 green, 1 red, 9 blue; 1 red, 7 blue, 4 green +Game 3: 1 red; 12 blue, 15 red; 1 green, 10 red, 2 blue; 1 green, 3 red, 9 blue +Game 4: 6 blue, 5 green; 2 blue, 6 green, 6 red; 11 blue, 5 red; 6 green, 11 red, 7 blue; 4 green, 10 red; 1 green, 7 red, 13 blue +Game 5: 10 green, 1 red, 2 blue; 3 red, 4 green, 4 blue; 5 green, 5 red +Game 6: 1 green, 6 blue, 14 red; 9 blue, 5 red; 14 red, 12 blue +Game 7: 1 green, 9 red, 8 blue; 9 blue, 1 green, 6 red; 1 green, 15 blue, 19 red +Game 8: 9 red, 7 green, 2 blue; 6 red, 17 green; 18 red, 16 green, 2 blue; 10 red, 14 green +Game 9: 1 blue, 11 red, 9 green; 8 red, 1 blue, 9 green; 4 blue, 16 red, 9 green; 8 green, 3 blue, 6 red; 8 green, 11 red, 3 blue; 11 red, 2 blue +Game 10: 8 green, 14 blue; 1 red, 6 blue, 9 green; 6 blue, 4 green, 1 red; 16 green, 9 blue +Game 11: 6 green, 11 blue, 1 red; 10 green, 1 red; 7 blue, 2 green, 1 red +Game 12: 3 green, 5 blue, 2 red; 14 blue, 16 green, 4 red; 8 green, 14 blue, 4 red +Game 13: 5 red, 12 blue, 2 green; 2 green, 1 red, 9 blue; 1 red, 2 blue, 3 green; 3 green, 3 red, 7 blue; 2 red, 13 blue; 1 red, 10 blue, 2 green +Game 14: 5 blue, 1 red, 2 green; 8 blue, 1 green, 1 red; 1 blue, 2 green +Game 15: 14 blue, 9 green, 1 red; 2 red, 15 blue, 12 green; 1 blue, 2 green, 1 red; 1 red, 16 green, 15 blue; 1 red, 12 green, 8 blue; 1 red, 17 blue +Game 16: 7 red, 1 green, 18 blue; 7 blue, 5 green, 17 red; 14 blue, 8 red, 6 green +Game 17: 4 green, 5 blue; 5 green, 1 red, 7 blue; 3 green, 6 blue, 4 red; 2 green, 5 blue; 9 green, 6 red, 6 blue +Game 18: 8 red, 6 blue; 4 blue, 19 red; 4 blue, 9 red; 9 blue, 10 red; 2 green, 9 blue, 13 red; 3 blue, 7 red +Game 19: 8 green, 2 red, 17 blue; 11 blue, 4 red, 5 green; 8 blue, 8 green, 10 red; 9 green, 4 blue, 2 red; 4 green, 10 red, 6 blue +Game 20: 9 green, 3 blue, 1 red; 5 blue, 16 green, 3 red; 3 green, 3 red; 2 blue, 1 red, 5 green +Game 21: 7 green, 1 red, 10 blue; 7 green, 5 blue, 7 red; 7 green, 9 blue +Game 22: 5 red, 2 blue, 9 green; 6 red, 11 green; 6 green, 6 red +Game 23: 14 red, 2 blue, 9 green; 9 green, 1 blue, 4 red; 9 red, 1 green, 1 blue; 6 green; 3 blue, 1 green, 9 red; 1 blue, 2 red +Game 24: 3 red, 7 green, 6 blue; 1 green, 5 blue; 6 blue, 1 red, 2 green; 5 red, 1 blue, 4 green; 6 red, 2 blue, 11 green; 2 green, 2 red, 1 blue +Game 25: 5 green, 1 red, 3 blue; 3 blue, 6 green, 3 red; 3 red, 4 green, 1 blue; 6 green, 1 blue, 9 red; 2 blue, 2 red, 1 green +Game 26: 3 green, 4 red, 12 blue; 2 red, 1 green, 15 blue; 7 red, 16 green, 4 blue; 11 blue, 11 green, 3 red; 8 green, 15 blue, 10 red +Game 27: 9 red; 10 red, 2 blue; 3 red; 8 red, 1 green, 2 blue; 1 red, 2 blue; 1 blue, 4 red +Game 28: 5 blue, 8 red, 5 green; 10 blue, 4 red, 5 green; 8 red, 14 blue, 10 green; 10 blue, 4 red, 1 green; 5 red, 17 green, 4 blue +Game 29: 16 green, 11 red, 5 blue; 11 red, 14 blue, 13 green; 13 blue, 8 green; 3 red, 18 green, 15 blue +Game 30: 2 red, 4 blue, 8 green; 6 green, 2 red, 2 blue; 6 green, 6 blue, 2 red +Game 31: 2 red, 1 blue, 16 green; 10 green, 1 blue, 7 red; 1 blue, 14 green, 7 red; 2 blue, 1 green, 1 red; 6 red, 13 green; 2 blue, 6 red, 10 green +Game 32: 4 green, 4 blue; 1 green, 5 red; 6 green, 1 red; 3 green, 5 red, 2 blue; 4 red, 1 blue, 4 green; 6 green, 2 blue, 6 red +Game 33: 5 blue, 2 red, 1 green; 5 blue; 1 blue, 1 green, 10 red; 8 red, 3 blue, 1 green +Game 34: 15 blue, 7 green; 12 green, 17 blue; 10 blue, 11 green; 1 red, 5 blue, 9 green; 2 red, 10 blue, 11 green +Game 35: 2 red, 6 blue; 2 red, 5 blue, 4 green; 2 red, 8 green, 10 blue +Game 36: 4 red, 9 green, 3 blue; 4 red, 6 green; 6 red; 11 red, 4 green +Game 37: 3 blue, 12 green, 14 red; 3 red, 5 green, 7 blue; 2 blue, 2 green, 16 red +Game 38: 17 blue, 16 red, 8 green; 4 green, 17 blue, 4 red; 8 red, 7 blue, 6 green; 2 blue, 9 green, 17 red; 10 blue, 8 green, 11 red +Game 39: 10 blue, 1 red, 4 green; 4 green, 4 red, 6 blue; 11 blue +Game 40: 5 green, 17 blue; 11 blue, 4 green, 7 red; 2 green, 6 red, 13 blue; 7 blue, 12 green, 16 red; 15 red, 3 green, 8 blue; 12 green, 3 blue, 12 red +Game 41: 13 blue, 3 red, 1 green; 2 green, 10 red; 1 blue, 5 red, 3 green; 5 green, 16 blue; 9 blue, 2 green; 14 blue, 4 green, 5 red +Game 42: 2 blue, 15 green, 3 red; 3 red, 17 green; 6 red, 1 blue, 8 green +Game 43: 8 green, 9 red, 3 blue; 1 blue, 13 red; 5 red, 1 blue, 6 green; 2 red, 2 blue; 17 red, 2 blue, 6 green +Game 44: 10 red, 3 blue; 10 blue, 5 green; 4 red, 4 blue, 1 green; 16 blue, 6 red, 7 green; 3 green, 12 blue +Game 45: 12 blue, 2 red; 2 blue, 3 red, 2 green; 8 blue, 3 green; 4 green, 8 blue, 5 red; 3 red, 2 blue, 1 green; 1 red, 2 blue, 7 green +Game 46: 1 blue, 11 red, 6 green; 2 blue, 11 red, 6 green; 8 red, 5 green +Game 47: 2 blue, 9 red; 1 green, 5 blue; 10 red, 2 blue, 2 green; 10 red, 3 green, 3 blue; 3 red, 6 blue, 2 green; 1 red, 1 green, 5 blue +Game 48: 1 red, 7 green; 1 blue, 10 green, 5 red; 4 red, 8 green; 10 red, 10 green; 2 red, 16 green; 11 red, 14 green, 1 blue +Game 49: 1 red, 1 blue, 5 green; 6 green, 5 red; 3 blue, 4 red, 3 green; 3 red, 5 green, 2 blue; 3 blue, 3 red +Game 50: 17 red, 1 green, 7 blue; 4 blue, 1 red, 5 green; 10 red, 13 blue; 17 red +Game 51: 2 red, 1 green; 1 green, 10 blue, 2 red; 5 red, 1 green, 7 blue; 7 blue, 1 red; 9 blue, 5 red, 2 green +Game 52: 8 green, 1 blue; 14 green, 1 red; 10 green, 1 red +Game 53: 17 green, 6 blue; 17 blue, 9 green; 1 red, 12 blue +Game 54: 4 blue, 7 red, 9 green; 7 red, 2 green; 14 green, 10 red, 3 blue; 9 green, 6 blue, 5 red; 2 blue, 3 green, 11 red +Game 55: 11 green, 4 red; 14 green; 3 red, 3 green; 3 green, 4 red, 1 blue; 15 green, 6 red, 2 blue; 4 red, 3 blue, 15 green +Game 56: 8 blue, 5 red, 9 green; 11 green, 5 blue, 6 red; 1 green, 1 blue, 7 red; 7 green, 4 red, 1 blue; 9 blue, 5 red, 1 green; 5 red, 2 blue +Game 57: 11 green, 19 blue, 5 red; 15 green, 5 red, 18 blue; 16 green, 5 red, 10 blue; 19 blue, 3 red; 9 green, 8 blue +Game 58: 4 blue, 12 green; 11 green, 4 blue; 6 blue, 6 green; 1 red, 2 green; 11 green, 3 blue; 13 blue, 6 green +Game 59: 10 blue, 1 red; 1 green, 4 blue; 4 blue +Game 60: 7 red, 2 green, 6 blue; 1 green, 13 red, 12 blue; 9 blue, 9 green, 8 red +Game 61: 7 green, 3 red, 2 blue; 1 red, 1 blue; 5 green, 3 blue; 4 blue, 1 red, 4 green +Game 62: 1 green, 8 blue, 6 red; 7 blue, 3 red, 12 green; 2 blue, 7 red, 6 green +Game 63: 3 red, 2 green; 3 green, 4 blue, 9 red; 3 blue, 3 green, 16 red; 4 red, 1 blue +Game 64: 10 red, 2 green, 15 blue; 4 red, 14 green; 6 red, 14 green, 2 blue +Game 65: 11 red, 14 green, 5 blue; 7 blue, 14 green, 15 red; 1 blue, 14 green; 4 green, 4 blue, 7 red +Game 66: 6 blue, 9 green, 6 red; 6 blue, 2 red, 4 green; 3 blue; 8 blue, 5 green, 8 red; 17 blue, 11 green; 12 green, 11 blue, 4 red +Game 67: 8 red, 4 blue, 6 green; 4 blue, 8 red, 2 green; 1 green, 6 red, 2 blue; 10 red, 1 green, 2 blue; 1 blue, 5 red; 2 red, 1 green, 2 blue +Game 68: 10 green, 9 red, 13 blue; 2 blue, 2 green, 4 red; 11 red, 13 blue; 4 green, 2 red, 8 blue +Game 69: 16 red; 12 red, 1 green, 4 blue; 1 green, 14 red, 9 blue; 12 blue, 2 green, 13 red; 14 red, 2 green, 10 blue; 11 blue +Game 70: 1 red, 19 green; 4 blue, 6 green; 12 green, 2 red +Game 71: 9 green, 2 blue, 3 red; 5 red; 1 red, 1 blue, 5 green +Game 72: 1 green, 19 red; 12 red, 1 green, 1 blue; 16 red, 6 blue; 14 red, 7 blue; 11 blue, 1 green, 13 red; 16 blue, 4 red +Game 73: 1 green, 1 red, 2 blue; 8 green, 2 red, 4 blue; 7 blue, 7 green, 7 red +Game 74: 1 blue, 1 green; 1 red; 1 red, 5 blue, 4 green; 2 blue, 1 red; 1 blue +Game 75: 8 green, 1 red; 3 blue, 1 red, 5 green; 12 green +Game 76: 8 green, 6 red, 2 blue; 7 red, 1 blue; 2 blue, 9 green, 1 red; 8 red, 13 green; 12 green, 2 red; 7 green, 5 red +Game 77: 3 blue, 1 green, 10 red; 13 red; 1 blue, 13 red, 1 green +Game 78: 2 red, 3 green, 14 blue; 3 red, 16 blue, 6 green; 3 blue, 3 red, 9 green; 4 blue, 11 green; 6 green, 2 blue; 2 red, 10 green, 11 blue +Game 79: 5 green, 10 blue, 2 red; 16 green, 15 blue, 1 red; 1 red, 11 green; 1 red, 11 blue, 16 green; 7 blue, 18 green +Game 80: 9 blue, 10 green; 13 green, 9 blue; 1 red, 5 green, 5 blue; 13 green, 5 blue, 1 red +Game 81: 9 green, 15 red, 11 blue; 11 blue, 9 red, 5 green; 2 green, 11 blue, 19 red; 14 green, 15 red, 5 blue +Game 82: 4 green, 6 red, 13 blue; 5 blue, 5 red, 4 green; 2 green, 7 blue +Game 83: 12 blue, 8 red; 6 red, 1 blue, 1 green; 7 red, 1 green, 1 blue; 6 red, 1 green, 9 blue; 10 blue, 3 red; 1 red, 5 blue +Game 84: 9 blue, 13 red; 8 blue, 1 green; 9 blue, 1 green; 3 blue, 5 red, 1 green +Game 85: 14 green, 5 blue, 8 red; 1 blue, 5 green, 1 red; 10 red, 7 blue, 17 green; 3 blue, 6 green; 6 red, 5 blue, 4 green; 5 blue, 4 green, 6 red +Game 86: 14 red; 20 red, 3 blue; 1 green, 12 blue, 15 red; 16 red, 13 blue; 13 red, 12 blue; 2 blue, 20 red +Game 87: 2 blue, 2 red, 10 green; 8 green, 9 red, 1 blue; 11 red, 1 green, 4 blue; 13 red, 1 blue; 11 green, 16 red, 3 blue +Game 88: 5 green, 4 red, 1 blue; 3 blue, 8 red, 10 green; 11 green, 7 red, 4 blue; 11 green, 5 blue, 4 red; 9 red, 9 green; 4 blue, 6 green, 9 red +Game 89: 2 blue, 2 red, 5 green; 2 red, 2 blue, 3 green; 2 red, 1 blue, 7 green; 6 green, 1 red, 2 blue +Game 90: 4 green, 1 blue, 5 red; 2 blue, 2 red, 10 green; 2 green, 8 red, 1 blue; 10 green, 5 red; 2 red, 3 green, 2 blue +Game 91: 16 blue, 5 red, 15 green; 4 green, 7 red, 3 blue; 4 red, 8 green, 12 blue; 4 green, 8 red, 17 blue +Game 92: 13 red, 2 blue, 12 green; 19 green, 7 red; 17 green, 2 blue, 3 red; 6 blue, 11 red, 10 green; 6 red, 15 green, 3 blue; 6 blue, 20 green, 11 red +Game 93: 2 blue, 3 green; 1 blue, 4 red; 1 red +Game 94: 3 red, 5 green, 6 blue; 7 blue, 5 green, 6 red; 9 blue, 1 green, 2 red; 4 blue, 1 green, 4 red +Game 95: 8 green, 9 red, 2 blue; 7 green, 7 red; 2 green, 4 blue, 6 red; 6 blue, 2 red, 2 green +Game 96: 11 blue, 4 red; 1 green, 3 red, 14 blue; 2 green, 3 red, 8 blue; 7 red, 1 green, 3 blue; 8 blue, 6 red, 2 green; 9 blue, 3 red, 3 green +Game 97: 5 green, 13 red, 7 blue; 2 blue, 12 red, 6 green; 10 blue, 11 red, 3 green; 4 green, 11 blue, 15 red; 8 green, 16 blue, 1 red; 15 blue, 4 red, 5 green +Game 98: 3 blue, 1 red; 4 blue; 2 green, 1 blue; 2 green, 1 red, 5 blue +Game 99: 4 green, 3 blue, 9 red; 6 blue, 5 red, 3 green; 2 green, 4 blue, 7 red; 8 red, 4 blue; 2 green, 15 red; 4 red, 5 blue, 3 green +Game 100: 8 red, 4 blue, 4 green; 10 blue, 3 red, 4 green; 10 green, 4 red; 18 red, 9 blue, 2 green; 12 red, 4 green, 2 blue diff --git a/2023/day03/Main.hs b/2023/day03/Main.hs new file mode 100644 index 0000000..d9d8f4b --- /dev/null +++ b/2023/day03/Main.hs @@ -0,0 +1,28 @@ +import Data.Char +import Data.List + +-- findBegin :: ((Int, Int), Char) -> [((Int, Int), Char)] -> ((Int, Int), Char) +findBegin s@((x,y), c) dict = case filter (\(p,_) -> p == (x,y-1)) dict of + [] -> s + n:xs -> findBegin n dict + +main :: IO () +main = do + inputLines <- lines <$> getContents + + let distances = concat (map (\x -> (map (\y -> (x,y)) [-1..1])) [-1..1]) + + let numInputLines = zip [0..] (map (zip [0..]) inputLines) + let charCoords = concat (map (\(x, l) -> (map (\(y, c) -> ((x,y),c)) l)) numInputLines) + let symbols = map (\(p, c) -> p) (filter (\(_,c) -> not (c == '.' || isDigit c)) charCoords) + let digits = filter (\(_,c) -> isDigit c) charCoords + let serialChars = filter (\((x,y),_) -> any (\x -> elem x symbols) (map (\(x1,y2) -> (x + x1, y + y2)) distances)) digits + let serialBegins = nub $ map (\x -> findBegin x digits) serialChars + let serialNumbers = map (\((x,y), c) -> read (takeWhile isDigit (drop y (inputLines!!x))) :: Integer) serialBegins + -- print charCoords + -- print symbols + print (sum serialNumbers) + -- convert input to [((x,y), Char)] + + -- mapM_ putStrLn inputLines + diff --git a/2023/day03/Main2.hs b/2023/day03/Main2.hs new file mode 100644 index 0000000..d7329f6 --- /dev/null +++ b/2023/day03/Main2.hs @@ -0,0 +1,30 @@ +import Data.Char +import Data.List (nub, sort) + +findBegin s@((x,y), c) dict = case filter (\(p,_) -> p == (x,y-1)) dict of + [] -> s + n:xs -> findBegin n dict + +uniqueLists :: [[((Int, Int), Char)]] -> [[((Int, Int), Char)]] +uniqueLists = nub . map sort + +getNumber :: ((Int, Int), Char) -> [String] -> Int +getNumber ((x,y),c) dict = read (takeWhile isDigit (drop y (dict!!x))) :: Int + +main :: IO () +main = do + inputLines <- lines <$> getContents + + let distances = concat (map (\x -> (map (\y -> (x,y)) [-1..1])) [-1..1]) + + let numInputLines = zip [0..] (map (zip [0..]) inputLines) + let charCoords = concat (map (\(x, l) -> (map (\(y, c) -> ((x,y),c)) l)) numInputLines) + let gears = map (\(p, c) -> p) (filter (\(_,c) -> c == '*') charCoords) + let digits = filter (\(_,c) -> isDigit c) charCoords + let gearsChars = map (\(x,y) -> (filter (\(p,xd) -> (elem p (map (\(x1,y1) -> (x+x1,y+y1)) distances))) digits)) gears + + let gearsBegins = uniqueLists $ map (\gearChars -> (nub (map (\x -> (findBegin x digits)) gearChars))) gearsChars + let twoGears = filter (\x -> length x == 2) gearsBegins + let serialNumbers = map (\gs -> product $ map (\g -> getNumber g inputLines) gs) twoGears + print (sum serialNumbers) + diff --git a/2023/day03/example.txt b/2023/day03/example.txt new file mode 100644 index 0000000..b20187f --- /dev/null +++ b/2023/day03/example.txt @@ -0,0 +1,10 @@ +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.. diff --git a/2023/day03/input.txt b/2023/day03/input.txt new file mode 100644 index 0000000..0d465e9 --- /dev/null +++ b/2023/day03/input.txt @@ -0,0 +1,140 @@ +.......262....300...................507.....961..............668.....................189.906...........................624.................. +..148.................805..130..880*...........*684.............*......*..............*..-......%.................$........17...65....91*... +......272.....464.....=......*.........................208*.....260.967.38.......692*.........676............@247..652.585.#......@......74. +.................*734........772......171.........728$.....52........................747.=866............350...........*.................... +..328....21...........941......../.....*...243................429@......567$...623.................654..#.....*815....360......812%......... +..........$.....%....@....6....583.....598...&.114@...618......................+...............156.........817...../.................340.... +.....883........359.....*.*..........................*............@............................./...920............302.712...........*...... +........*.....*......100..192.160........791......843...680*643.252.................322...354..........*.....+.........*............556..... +.........958.580.................*.............................................879.....-..$............633...63......561.....289............ +..............................745.......221..504-................356..............*827........355...............................*46......... +...................206..382...........$...........142@.105...534........./.......................*..........535.....................515..... +..201.....336.......-..*.....268..121..775...-...........%..............791.............129...449.....450..*.........790...........*........ +............%.559*......7.....+..*..........865......895............930.....427..242......#...............414.830............37..809........ +..................85.............466..550-..........+....................44...*...*.........361..215..........*......808.220*............... +................*......709....................577......430...&..148........*.696.988....801.*.....*..........202..25..*..................... +.....636......14...........372.............64...*...........586.%...15..241.............&....387..447...............*..811....146........... +.....-...........892*226....*....161.........%.623..................*...........$...............................................&.....657... +........987.................147.=....+.254..........887........773...321.....221....415.971..................74.......702..212.............. +......@............182............335.....*...........*..77.......#......................./.....29..........%...........&..*.......872...... +......643............*...................756.........677.*..........251......521..620......................................685.206.......132 +............274*...........929.................871........686.542..%........*......*.......................882....756.............*859..*... +................516.........*.....................*..............*...289...10.....890..985...258...963...............*.................526.. +.............................610...............857........210..818......*.......@.........#..=......*.....968.........42..........732....... +.............../..*453.................467..........376......$..........429..218.....................955..%..............357................ +.......841....493..............830#.......*342.........*........*................./....562....945................224.......*..435........... +..................843.803......................2........56...248.560.............281.....*.......*.........-........*5....728..*......156... +...822*288....352.*...+..............$.........$........................@..............794......539..-814..528.81.......+.......687.....*... +................*.783..../454.859....809..742........................663...267/..................................*.....847..............167. +....&371.296.484..............*..........=...........516.......925...............................#................441...............224..... +.........#............594..417....458............112*.....65.....#.....337...357....#..369*277.825....386..................212.............. +................651..#...........*.....$..................*............*.....*...125...................*......497.........*..............509 +......320..........*......-...883..989..733.....668.905...997.......454.....353...........946....18.....340...&......515...774........*..... +......-.....880....476...955.......=................*...........58.....................23....*69.+..102..............*.............933.687.. +........931....*..............................757....602.983......-..822..............*.............*.......732.....15...................... +....../....*....463.............183$..961........*.......*....#...........572......618.............52..........@........205......*....&429.. +...204......550............-.........%.........628.....240..588............*................................/..........*......167.776....... +................360....*....69..........*..........534..................%..340.....................885*912..52......949..................... +.........483......*..46.754......-....607.346.....*..............851.302..................@....................-........330.-201............ +.........@...274.811..............819...........56......326......................496....650...........382......168.420...*.........452...... +..............#........325.449........581...........112*........................+............163.......*.................407.......*...460.. +......595.........*......*...................226+.................268..153.........#123........*.....$..877..........#..........361...*..... +......*........280.287.427...........755...........................%.........................722...323................307................... +..132.553...............................*.......117......450.109...............849.....749.................................105..537#..741... +...*.................................788.......*....691...%...$............148.....960..*....512.728#..544.624.....$......*................. +.523..97...186..907....508....................739......*................*.....*856.&....15..................$.....911.......&..877..632..... +..............*.*.........*.........161*....+........381.............453.376..........................30..................806.......*....... +............560.877...773...............168..446..............465..............435@..24..622...%.................................=..347..... +...*165................-.......................................*......@816..............*....313..421......269....539.49.530..113........... +768......*626.926....=.....676...981=............703.........682.&141....................444......=........@.........*......*......539...... +......159.......$..362......../.......254.....14..=...............................219.................383.........*......182.............733 +.324........879.....................*.=...............316.....*480......*............*............439*.........621.961.......*481........... +....*...208*...........188.......763.....553...........*...957.......771.944........445......4...........375..............174.....903.665... +.................651........851.......37*...........303.................................446......61......*......346................@...*.... +......160....412*......../.....=.220.........354.........-.....838...........473..........#........$.870.......*............*........391.... +.....*....................218.....*.............*.....739..320*.........358....*...521......383.........*.....27...........107.............. +...969...718..................+....200.534.237+..........................=..889....*..........@........396.......................103..243... +........&..................841...-......&........./748...655..325.................430............813.................618.....687...#..@..... +..........825...761............800......................*....&...........496............652...$..*...............206..*..................... +...................+....&584.........35..663*590.....677...................*........741*....908...293..918............570....$......%....... +...........794.......................&...................852*...........361...............-.................................502.769.82...... +..535.......$............523*522................-..............847..........593..........267.....................................*.......... +....*...........73...............................299..262..941*..................813..............682..........877........494...411......... +..528................*997....*...477........464.....................521........@....*315......#...=..............*.......................... +............669...909.......342..*...........*..........444@...@.....-..611.911..............864......114....555..628..890.................. +............*.....................444.....921................783.......*.......................................*........=...414............. +..........622..................................422..-...............404......&906..381............438..........605.........@.....389.352@... +....77.........519...282........720.....159=..*....87......225.605......125...........+.............*..860-......................=.......... +...$...556.......-.....*..........#..........479............&....*.........*967...343..............400...........*883..................*881. +......*............207.653....113...359............227............357............*..........771...........426.905..............313..563..... +...74..233....959../.........*.........&............*...#.................543..64..*....179................*........@.............*......... +.....*..........*.......707.341..........&489.....206..132..407..........*........224..*................310........255./.........136........ +...251.......770........................................................475.............694....514.....................236.................. +........944........-379...............403.....934......47........................................*..............694........359.............. +732.............14..........*..........*.........*.................720....325..............375.483.............*.....356&..............686.. +.......160..672*.........250.125....791.....&76...1.....&963...422..#........../....191......*................925..........771...405&.-..... +...205....%......402................................117........*.........887....509..........44.....417.................=.-................. +...................*............=..145......746.......*........861..804....*.........313...............*....*.........761.......638......... +..852..767.....#67.835......$.359..*..................789.@................675.938.............957..........459.652..............*...949.... +........*.................977.....779.......348...627.....136.........+623..........964.............948+..........*.................=....... +........882......+............................./...#...............................*......311...152.......186......233.......374.......989.. +..148.........125.....931......706%....#...379.........................181.......227..........*..........*..............581..*.............. +.....*..179..............*.............970.../.......605...........736*......................700......970.................*.........+.487... +....209...*..............810....790..............787*......................#...+....-...824......587......709*.....899.....283....324..*.... +...........50...750............./.......633...............................364..66..593./......................115......-..............561... +...................#......989..............*217.......................620...........................................740.....*361....+....... +..........266.........647*....$..992....*...........318...345...........*..............-........252..797.................354........8...110. +.............................375.....344.334.......*.......*..........460......558.....364.......#..$...........@....%..........3........... +...$14...314...652...............................626............%...................%.....................778....868..215................... +...........&....*.......$........241.................*796....552..738..#234...@....358............993....*.................................. +................594..230..-..647*.....&............56.............*............479.....921..............519................426......713..... +.....944*................404........53..349....$........459......986..+......=..............-666..............237...897#..*........&....755. +.........176........280......714..........*..876.268...*.............946.492.113..........*..............................855................ +.....................*........*...936..................973.................*............736.......844.659....652.@............266...547..... +...677......@........426.....89........./...................185..........630.285............196...../....*...*....349....102....*....*...... +........765..677................*..46....85.901.....*...440...................../..........*.............304..952............1........507... +...........=.........669......847....*........*..821......*.301.......880.................829.951.460....................876................ +.................466*......*.........69.....207.........419...*...................442............*...........-.....898.....=.667............ +....421.56=................318....................................178...............+...............896*855...522..&..........%....151*405.. +....*.......481-...70*401..............550...................*.......*296...91........998.566..112.......................................... +...235.472..............................*......962....963.935...921.........+.....................-...........168.....=516.304...416*699.... +........#...*10.................240=.....687..*...................*.475..-...........697.......................*..............*............. +..261.....47.......750....954.........=......274........-...203.570....*..71...........*...484..*.....%61...397..854...#.......523.....931.. +..............34............$....%.....500........216.647............271.......908....906.......488...............*..92..634................ +..........83*....................994.......511.55*........991...16.........417*....*......96...................697.................&........ +.............582.450=.....................................=.....*...............654.411........313..................29.........32.849....... +.......563..............239.........&.............405............193......+.411.........%......*...&.....623.........$....+748..=.....840... +..........&......#.......-....761....639.275+.......*...................69..$....../.233..@..88.....226...*.....366................../...... +.............248.16............/...............+...556...........306............354......308..............682.../......894...#.............. +..697.......*.........@..........959...125....297.......................*337...................72....108...............*......991.344....781 +...*.......715...49.392.........*.......*................652/........#.......55*.......................-.844......./..344..........-........ +...591....................334.701.......838.......................397....501....759.....-.........................946.......442............. +..................557*421...@.....749........500..........#170..........%............941..373....425..818.......................828.....237. +..793*144...........................$.302....*.....938*..................................*..........*....%.378........66..63...*............ +............474...............893............267.......810................585..........558.......694......../.................340.701....... +..............#..798......332*.....855.....................592.589........&.....833=.........199......730.......+......177.................. +.................*..................*.........................*........................#.......*......*.....154.589...*..................... +.....64*809........../............@.139............228..374....../.......771.........534........281...........*......506.......=............ +..............427.750......546...98............707..=......&..381..877..*..........*........6.........%......489.........../.795............ +...895.805*.....*.....................*694....=........848...............616.....69.86.....*..460......895.......544.....651.......14.886... +...........390...850..777.534..138..52..........570....@.........812.$71................795.......557............-.....................*.... +..46*41...............*...........*................@.........613*.................584.......=........*...............106*....627.602....829. +........217*380.............721..928.873...........................593..353...............341..430..989..923.............695......-...%..... +..................586.......$.........*...207.......585&......485..*...*..........................*......*..........................929..... +............#.154*.....60.............95.......................*..138.764..........................425.275......%.331*664..854..........887. +908.917..359........../........659........125..785...........499..........991....358..........102*...........903..........*.....409....-.... +...*.........963*.../......408.............%........830*871...............*......*...828..........764.671................293...*............ +....................559....=..........81............................391...969.513....*.......991........&..518.....208*.......75............ +.....461.560*......................../........950.........320%.....*................97........................#..........+675.....352...339. +......*......439.%101.709...302.870......838....@.....594........953.......514*862........339....................................*.......... +...247...................@......*.................312....#.................................-...271..800...@..818.850....333*722...330..951.. +........922.................184.666.............../..........................356...105.........#...*.....353./........................*..... +832.....-.......758...800....$......................337.......419...........=.......*...258........926.........................../592..186.. +...................+...........220.287...117....783......646..#.........451........750..........27.....$.......*750......890................ +........719............982....%.......*..*.........*144.*..................*...........*764./.....*373..368.201..........@.................. +......../..........388....*........115...432.............594............345..658$...442......833.................408.........=..........542. +..........27.#498..*.....286..+490...............................966.....................262.......................#..542.237............... +72....251..#.......667.....................282..556..260...........%.$......................*....107..................*..................... +.......*.......*..............................*..-...*...............64..#...=.....402..@....790.@.....................295.766...484..969... +......85....882.80.......184$................117........................454..583......*..351...............266....................&....*.... +.......................................................48...........................436........275...................869............258..... diff --git a/2023/day04/Main.hs b/2023/day04/Main.hs new file mode 100644 index 0000000..9bf100b --- /dev/null +++ b/2023/day04/Main.hs @@ -0,0 +1,20 @@ +import Data.List.Split (splitOn) + +getGame :: String -> String +getGame s = tail $ dropWhile (/= ':') s + +splitGame :: String -> [[String]] +splitGame s = map (\x -> filter (/= "") (splitOn [' '] x)) (splitOn ['|'] s) + +calcPoints :: [String] -> Int +calcPoints w = round $ 2^^(length w - 1) + +main :: IO () +main = do + inputLines <- lines <$> getContents + let games = map (\x -> splitGame (getGame x)) inputLines + let wins = map (\[w, cards] -> filter (\card -> elem card w) cards) games + let points = map calcPoints wins + + print (sum points) + diff --git a/2023/day04/Main2.hs b/2023/day04/Main2.hs new file mode 100644 index 0000000..7b883e8 --- /dev/null +++ b/2023/day04/Main2.hs @@ -0,0 +1,26 @@ +import Data.List.Split (splitOn) + +getGame :: String -> String +getGame s = tail $ dropWhile (/= ':') s + +splitGame :: String -> [[String]] +splitGame s = map (\x -> filter (/= "") (splitOn [' '] x)) (splitOn ['|'] s) + +calcPoints :: [(Int, Int)] -> (Int, [(Int, Int)]) -> (Int, [(Int, Int)]) +calcPoints dict (num_cards, []) = (num_cards, []) +calcPoints dict (num_cards, this) = + let new_wins = map (\(i, w) -> take w (drop i dict)) this + in calcPoints dict (num_cards + length new_wins, concat new_wins) + + + +main :: IO () +main = do + inputLines <- lines <$> getContents + let games = map (\x -> splitGame (getGame x)) inputLines + let wins = zip [1..] (map (\[w, cards] -> length (filter (\card -> elem card w) cards)) games) :: [(Int, Int)] + -- let points = map calcPoints wins + + print (calcPoints wins (0, wins)) + -- print (wins) + diff --git a/2023/day04/example.txt b/2023/day04/example.txt new file mode 100644 index 0000000..9bdb874 --- /dev/null +++ b/2023/day04/example.txt @@ -0,0 +1,6 @@ +Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 +Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19 +Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1 +Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83 +Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36 +Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11 diff --git a/2023/day04/input.txt b/2023/day04/input.txt new file mode 100644 index 0000000..da97dbb --- /dev/null +++ b/2023/day04/input.txt @@ -0,0 +1,208 @@ +Card 1: 57 76 72 11 8 28 15 38 54 46 | 77 87 71 98 40 7 84 43 61 64 5 50 19 83 79 99 36 47 4 95 30 44 37 55 26 +Card 2: 44 69 14 83 54 48 21 6 20 26 | 80 26 86 3 9 4 62 34 15 87 60 88 90 29 65 46 92 73 24 12 40 10 99 37 74 +Card 3: 15 60 63 84 20 93 36 39 17 19 | 68 80 17 91 20 84 69 72 15 39 5 61 74 99 60 85 19 45 24 79 53 36 7 63 93 +Card 4: 22 74 83 58 88 46 7 52 84 5 | 75 20 95 8 37 56 31 42 73 43 40 48 4 28 99 45 90 63 81 93 68 50 46 30 7 +Card 5: 4 97 41 50 32 26 68 84 5 11 | 91 70 87 4 88 13 48 51 32 34 38 82 86 11 1 50 40 43 28 5 61 89 84 41 37 +Card 6: 79 97 39 26 57 69 38 87 60 44 | 22 92 80 38 27 66 54 2 9 62 3 4 71 99 24 97 14 7 93 28 53 50 77 68 73 +Card 7: 73 91 51 23 90 67 19 81 50 12 | 4 76 97 64 19 85 31 3 74 12 23 60 20 68 52 39 43 65 37 63 40 59 99 80 6 +Card 8: 23 64 38 82 68 79 49 56 5 76 | 68 25 64 30 40 52 16 53 95 96 85 9 4 7 26 80 62 67 73 35 32 44 90 69 93 +Card 9: 75 87 69 31 8 11 89 49 95 24 | 35 26 68 69 42 66 37 77 25 45 75 72 38 50 27 24 32 46 11 10 14 95 62 7 86 +Card 10: 37 25 47 36 57 81 44 6 79 98 | 67 34 86 70 39 97 80 69 27 17 7 50 99 84 45 32 49 53 15 95 19 18 47 37 41 +Card 11: 87 98 16 76 21 53 8 42 40 75 | 21 7 89 85 65 30 32 19 68 22 64 82 48 62 39 46 4 57 77 18 55 24 34 29 67 +Card 12: 60 11 44 35 9 56 93 91 15 32 | 31 45 37 63 26 12 15 14 48 92 81 1 97 65 29 95 57 77 99 93 27 25 58 66 61 +Card 13: 25 75 5 60 47 83 8 37 2 43 | 52 30 68 13 1 92 89 63 78 57 87 75 28 82 59 46 33 3 65 41 47 69 21 2 96 +Card 14: 64 44 89 88 1 38 20 99 9 81 | 71 68 91 21 92 75 49 22 27 12 9 26 57 13 66 45 40 37 16 4 44 90 98 85 61 +Card 15: 16 56 91 62 12 83 25 3 70 61 | 81 55 73 96 13 7 67 99 88 90 87 48 83 35 19 97 9 31 20 49 38 44 41 45 5 +Card 16: 78 68 81 18 76 41 88 45 24 87 | 59 84 67 36 33 57 42 32 11 74 65 31 54 46 72 39 98 40 16 49 79 19 3 44 22 +Card 17: 84 11 48 66 54 86 28 4 45 23 | 4 54 42 62 81 8 92 45 47 66 84 48 18 72 28 86 23 34 3 24 73 82 96 11 59 +Card 18: 46 40 41 22 75 92 68 10 52 3 | 84 73 9 22 7 19 3 65 32 6 99 77 97 63 62 59 57 17 8 68 91 28 39 4 41 +Card 19: 19 57 22 85 75 69 50 62 65 61 | 35 24 50 47 74 97 61 27 66 57 77 75 22 30 70 41 62 69 85 58 81 65 19 91 63 +Card 20: 18 13 96 41 20 44 62 97 57 52 | 18 59 96 40 23 58 20 57 41 97 44 62 75 54 85 78 94 52 64 34 37 45 84 13 53 +Card 21: 34 3 13 85 81 19 37 97 29 91 | 9 97 52 3 35 48 24 34 17 50 21 71 57 36 94 82 19 4 14 83 98 37 80 91 59 +Card 22: 18 14 95 74 23 71 31 83 51 57 | 94 14 63 18 16 73 57 31 5 23 51 69 85 45 70 35 74 49 79 27 40 95 83 13 71 +Card 23: 54 12 52 31 58 93 9 45 27 64 | 48 54 93 12 44 64 56 83 35 94 33 4 58 89 8 45 27 1 86 90 52 31 19 57 9 +Card 24: 56 75 17 67 59 37 76 94 25 36 | 24 14 56 53 82 35 92 96 17 34 25 1 16 86 41 95 64 45 38 63 31 18 80 33 66 +Card 25: 32 22 47 24 80 92 96 67 5 26 | 22 81 87 47 26 96 92 60 57 64 66 16 5 83 67 49 32 39 71 80 40 63 99 75 53 +Card 26: 62 36 66 9 3 71 75 67 29 61 | 9 31 66 82 29 41 67 71 38 36 28 76 14 75 69 61 99 57 62 88 70 95 63 10 59 +Card 27: 46 38 59 90 1 65 16 80 76 34 | 70 15 49 31 27 71 54 46 76 1 8 77 93 2 90 39 14 67 62 16 78 56 68 9 58 +Card 28: 47 85 54 21 37 14 44 73 12 51 | 78 70 14 77 98 88 25 49 9 79 58 23 52 2 43 17 12 84 59 51 56 89 47 48 6 +Card 29: 74 37 60 11 56 21 87 44 33 46 | 80 61 34 54 9 3 45 7 55 13 98 84 10 19 14 8 90 81 50 69 31 12 38 29 78 +Card 30: 29 20 44 62 79 34 52 15 49 48 | 17 84 34 1 33 9 23 55 94 10 95 69 42 79 78 44 51 82 20 25 81 29 15 13 32 +Card 31: 88 41 38 98 34 40 92 36 25 50 | 33 54 18 53 46 69 8 22 25 36 51 34 42 92 85 45 40 60 84 27 97 39 10 70 41 +Card 32: 5 28 85 29 95 37 60 34 24 16 | 74 8 48 73 34 65 66 56 64 85 78 17 39 67 92 30 75 22 95 12 29 24 6 2 51 +Card 33: 71 31 99 53 62 80 65 32 13 23 | 87 20 55 24 42 19 67 77 37 89 32 83 44 9 60 46 47 36 49 35 92 10 82 2 81 +Card 34: 78 61 12 81 96 82 7 30 80 32 | 62 8 56 89 11 12 39 31 17 18 79 51 30 92 48 5 45 78 41 44 77 98 71 67 73 +Card 35: 59 35 63 76 51 8 53 70 24 97 | 20 36 31 17 77 26 34 15 41 39 61 24 35 46 80 74 2 71 5 91 16 11 55 87 4 +Card 36: 46 51 79 66 57 52 21 11 75 33 | 88 64 74 99 22 39 42 11 14 65 1 56 86 8 26 16 72 13 55 20 60 40 19 85 58 +Card 37: 83 88 1 19 95 30 38 43 14 51 | 98 20 22 55 13 58 93 21 68 11 76 70 71 35 44 90 52 53 75 17 96 27 49 31 26 +Card 38: 87 49 43 19 16 34 88 66 67 9 | 70 46 63 58 7 53 96 1 59 35 91 85 18 21 93 68 90 73 11 92 60 61 98 38 15 +Card 39: 24 68 25 61 54 63 30 37 21 73 | 50 84 48 10 81 5 62 28 92 66 96 6 20 83 78 88 31 89 12 71 60 8 34 70 90 +Card 40: 18 72 44 15 3 19 69 63 73 57 | 14 3 52 76 71 12 50 13 86 21 55 31 27 29 43 47 90 75 9 97 6 32 96 37 18 +Card 41: 81 66 49 20 86 80 4 55 93 44 | 87 81 7 47 25 85 80 51 76 27 78 10 16 50 33 66 13 64 35 18 44 63 29 92 48 +Card 42: 27 21 14 28 69 89 94 9 19 46 | 92 13 27 99 96 19 43 54 4 14 45 16 44 83 24 61 2 28 5 90 49 51 63 64 73 +Card 43: 34 49 58 85 23 88 84 78 89 55 | 72 45 73 23 75 52 84 78 46 55 58 71 98 5 56 91 49 39 88 70 42 59 89 85 34 +Card 44: 18 69 46 58 73 59 56 23 12 40 | 71 23 87 93 21 84 10 79 47 92 91 13 52 1 32 78 59 95 72 55 97 56 43 61 75 +Card 45: 33 47 58 69 57 1 82 6 61 48 | 48 97 4 1 67 66 82 12 6 29 21 96 90 33 57 28 47 69 74 27 2 32 58 61 9 +Card 46: 42 54 98 50 36 86 27 66 29 60 | 32 23 40 62 38 91 43 98 29 85 18 30 66 28 81 35 68 61 11 27 50 22 41 46 42 +Card 47: 1 31 87 71 53 17 5 93 84 56 | 48 26 14 47 34 44 18 93 17 88 61 8 95 74 53 50 56 80 62 84 99 49 87 52 1 +Card 48: 40 75 79 29 64 57 33 49 95 68 | 7 39 63 79 89 10 23 40 22 86 92 13 57 29 9 19 90 87 58 12 77 16 75 4 91 +Card 49: 4 45 87 47 71 35 9 2 81 77 | 93 33 49 75 11 34 62 39 83 40 55 17 84 43 80 60 46 7 18 56 48 66 95 57 74 +Card 50: 88 42 2 30 24 89 15 93 16 45 | 93 45 72 68 30 28 17 82 64 91 29 98 14 24 88 70 55 48 58 10 42 83 66 2 77 +Card 51: 91 96 87 48 6 73 95 55 71 89 | 94 49 84 33 82 9 21 32 25 46 65 15 86 83 66 11 37 1 14 61 92 36 35 45 27 +Card 52: 48 3 94 56 41 13 34 8 96 25 | 40 88 46 14 68 25 75 66 87 55 64 78 92 43 19 97 53 90 83 59 69 31 84 95 13 +Card 53: 13 45 61 92 91 32 49 58 43 36 | 44 70 55 28 2 6 35 79 24 54 82 95 52 73 75 84 34 57 21 23 33 22 80 88 1 +Card 54: 61 52 20 8 73 54 83 60 29 6 | 74 40 27 46 81 75 3 42 47 69 22 59 58 49 90 63 57 50 79 70 82 5 53 91 39 +Card 55: 41 51 64 55 57 44 26 70 62 34 | 24 82 49 39 56 84 31 27 86 77 22 6 73 72 99 47 60 18 53 68 42 19 66 9 50 +Card 56: 30 89 82 17 72 46 98 5 54 58 | 4 86 18 15 84 41 16 63 44 91 12 31 66 96 94 87 49 59 67 64 80 33 5 11 40 +Card 57: 39 80 17 47 15 96 69 50 46 24 | 5 83 16 52 57 27 98 43 78 1 66 90 19 6 58 3 49 94 85 62 44 54 75 14 9 +Card 58: 42 77 37 13 74 40 31 92 36 46 | 16 74 80 59 51 31 95 85 40 93 23 15 32 18 46 97 36 13 79 10 37 99 77 25 92 +Card 59: 39 1 78 7 57 46 91 26 12 94 | 46 13 26 83 21 1 67 78 50 94 8 12 39 61 86 91 35 29 32 72 30 97 57 16 7 +Card 60: 62 32 18 51 40 96 93 36 80 84 | 42 93 65 8 2 52 84 70 11 1 92 21 80 99 18 14 17 47 56 90 49 67 19 48 97 +Card 61: 6 83 74 89 44 73 39 42 47 88 | 72 74 42 21 88 77 18 6 83 85 49 73 5 39 78 44 64 10 47 14 89 53 98 13 92 +Card 62: 91 86 35 23 30 28 77 88 56 41 | 54 26 90 20 96 78 14 5 47 98 31 55 74 83 33 15 67 92 19 40 73 72 52 81 94 +Card 63: 87 91 78 92 33 71 80 47 13 65 | 32 33 56 55 2 4 61 71 91 97 93 78 83 74 3 13 47 70 54 80 65 60 49 26 96 +Card 64: 70 61 63 52 32 35 85 46 54 4 | 42 54 32 84 56 46 29 61 63 78 4 36 80 86 26 17 3 87 48 21 85 52 35 70 22 +Card 65: 83 95 45 97 49 67 13 92 1 90 | 68 75 20 96 6 33 73 1 50 14 17 66 34 78 54 84 92 9 64 61 85 88 72 42 12 +Card 66: 1 7 99 75 17 21 48 70 30 13 | 70 80 45 89 75 7 21 99 20 54 42 46 67 85 61 17 1 16 30 92 77 48 13 68 90 +Card 67: 69 55 20 91 47 31 33 75 56 39 | 69 31 62 20 58 1 93 48 35 55 47 13 56 60 50 75 25 37 91 81 10 39 32 33 54 +Card 68: 14 97 54 28 73 64 81 32 47 17 | 86 48 88 25 47 65 22 81 28 95 41 14 27 26 46 64 79 61 45 96 32 9 21 54 53 +Card 69: 6 21 89 82 75 48 46 56 68 47 | 48 32 74 30 13 56 93 90 68 33 41 58 21 47 8 17 65 6 89 97 75 82 46 26 59 +Card 70: 35 48 78 92 64 30 88 77 76 10 | 76 33 48 67 78 64 24 69 36 14 77 85 30 73 53 91 3 35 96 88 43 84 10 95 92 +Card 71: 59 78 57 66 15 18 41 83 70 35 | 7 62 19 30 48 97 89 71 40 27 11 63 60 47 23 86 10 84 4 75 80 69 61 67 25 +Card 72: 80 82 46 70 10 14 55 49 62 9 | 31 76 62 17 8 49 19 50 85 72 77 75 42 48 33 60 54 45 12 91 20 92 15 3 25 +Card 73: 38 83 96 47 42 99 13 82 36 85 | 74 86 59 16 49 45 81 61 44 39 3 91 9 26 35 25 55 21 19 41 90 70 10 29 4 +Card 74: 92 36 96 65 24 6 98 13 33 86 | 17 83 30 5 46 51 54 81 44 99 33 56 45 14 57 34 8 16 77 48 40 94 82 73 75 +Card 75: 14 21 57 66 33 8 90 7 4 28 | 91 61 3 84 89 45 60 56 51 10 58 20 96 78 73 93 97 44 19 15 12 90 35 87 42 +Card 76: 37 91 60 44 43 3 40 33 95 51 | 24 39 81 1 46 83 97 88 87 6 67 40 22 96 93 2 71 33 29 15 41 16 89 21 68 +Card 77: 91 84 43 9 87 96 37 64 41 31 | 35 13 30 43 78 32 23 85 84 19 88 68 10 63 27 77 61 50 41 94 54 12 97 86 33 +Card 78: 9 78 53 16 80 56 91 3 62 70 | 85 64 21 88 51 16 15 4 69 30 13 1 70 17 52 23 90 5 24 50 19 81 41 67 12 +Card 79: 59 28 42 51 66 58 63 9 24 47 | 69 95 26 36 14 62 13 20 35 25 34 74 40 41 9 39 45 77 5 10 55 96 22 81 49 +Card 80: 72 83 73 23 85 2 53 22 3 43 | 14 50 67 63 19 76 39 60 31 33 62 92 29 12 49 75 69 78 44 8 96 95 34 65 20 +Card 81: 2 46 29 50 65 57 55 83 74 12 | 4 70 97 54 68 99 81 5 84 10 73 61 88 66 27 8 56 33 79 47 85 49 17 16 34 +Card 82: 37 30 10 3 8 34 44 24 57 13 | 42 17 25 65 48 71 4 64 51 83 75 27 72 96 45 18 11 15 70 53 91 14 12 87 59 +Card 83: 82 81 15 4 54 96 74 72 37 70 | 37 78 72 25 4 66 81 97 6 83 43 96 61 44 15 71 40 54 27 70 82 98 74 93 7 +Card 84: 97 52 96 23 80 53 57 83 16 62 | 5 31 89 91 84 33 52 83 76 23 64 67 10 97 29 63 96 58 74 53 62 57 80 81 92 +Card 85: 53 33 76 24 81 68 51 47 40 89 | 70 38 51 50 85 57 89 40 30 61 1 24 54 75 32 33 96 19 14 53 76 20 7 99 47 +Card 86: 19 96 52 18 15 53 82 16 86 13 | 69 27 32 85 87 30 33 83 11 47 3 21 68 70 42 61 46 2 64 65 44 1 97 48 74 +Card 87: 18 40 55 62 39 95 60 11 76 46 | 82 81 22 46 92 80 62 91 12 40 76 60 69 78 17 18 11 93 56 39 37 88 3 64 95 +Card 88: 72 65 91 61 57 4 49 24 45 31 | 28 49 91 31 19 59 65 36 34 87 72 24 60 89 17 12 57 30 75 32 63 8 21 4 25 +Card 89: 18 24 64 43 33 56 6 67 8 16 | 40 21 27 52 3 23 65 89 16 7 96 31 48 73 33 37 18 99 12 50 74 26 71 84 8 +Card 90: 75 3 92 35 12 26 49 59 60 55 | 65 58 39 73 3 56 11 44 4 47 68 24 86 10 61 6 72 13 82 42 29 93 97 77 8 +Card 91: 78 40 49 75 60 15 59 7 31 93 | 71 9 48 10 69 29 65 40 21 57 68 87 12 35 81 70 30 94 36 97 51 43 8 82 5 +Card 92: 3 53 23 43 15 4 98 11 67 29 | 35 3 93 87 83 60 5 92 1 90 67 23 78 98 20 37 81 71 31 82 95 47 53 75 21 +Card 93: 20 61 6 36 52 77 59 16 18 81 | 66 29 4 87 61 92 78 30 68 69 67 57 88 83 71 54 24 21 13 56 84 35 60 86 53 +Card 94: 25 52 87 17 94 41 23 30 72 53 | 93 62 38 77 31 24 21 36 75 64 45 83 56 39 90 29 55 43 71 54 42 98 76 74 28 +Card 95: 84 66 91 8 26 82 85 96 31 36 | 93 51 40 98 69 74 53 67 86 23 77 41 62 89 64 34 5 26 50 73 42 43 13 19 91 +Card 96: 7 6 90 39 14 73 66 81 33 67 | 63 26 1 58 29 10 3 13 94 9 85 68 69 19 53 96 90 36 49 99 31 74 54 45 77 +Card 97: 66 64 77 7 88 18 40 24 10 63 | 28 22 62 41 30 21 19 12 50 43 46 42 56 6 60 36 95 82 97 2 73 55 38 53 8 +Card 98: 48 10 16 15 93 40 37 72 57 88 | 10 59 38 19 97 23 51 40 35 31 56 54 21 27 28 81 15 67 12 57 37 65 9 22 74 +Card 99: 45 57 7 23 86 82 15 14 75 35 | 55 19 84 37 82 39 15 77 42 52 44 18 75 45 7 69 67 23 86 6 89 14 43 57 35 +Card 100: 68 85 29 69 17 44 19 56 92 8 | 8 4 20 98 36 39 78 79 72 81 51 22 13 47 2 77 30 28 64 41 89 57 50 34 16 +Card 101: 6 91 90 43 85 1 19 2 28 9 | 63 25 2 9 83 85 87 43 91 6 62 64 74 28 19 82 92 29 36 1 71 90 60 99 84 +Card 102: 20 72 12 52 58 28 30 76 42 55 | 30 47 59 29 20 93 90 33 76 58 78 28 52 83 48 72 54 42 67 17 55 12 36 2 37 +Card 103: 58 18 40 8 73 69 22 74 26 63 | 61 40 63 41 82 87 22 8 34 6 73 95 69 44 45 85 62 74 27 28 26 4 96 58 15 +Card 104: 42 71 57 39 22 79 43 80 90 37 | 43 37 76 94 40 67 4 55 74 21 7 42 3 39 28 12 80 57 32 61 95 58 64 90 13 +Card 105: 60 9 50 14 56 11 54 33 77 84 | 77 81 17 99 11 84 70 60 5 43 83 19 80 13 54 33 50 30 87 31 9 4 37 56 14 +Card 106: 79 87 86 96 1 8 63 43 39 91 | 6 2 75 63 67 38 11 96 90 91 87 97 86 9 21 77 43 36 79 8 40 85 39 1 13 +Card 107: 97 83 21 39 74 64 79 70 77 14 | 85 32 55 18 24 14 79 57 51 12 4 21 23 70 26 83 39 66 63 1 64 73 30 8 77 +Card 108: 18 41 11 62 88 38 73 4 47 36 | 82 53 41 92 65 15 42 47 85 96 26 43 58 62 11 3 54 55 89 63 30 17 20 93 2 +Card 109: 28 34 55 39 22 99 98 89 86 54 | 58 76 46 70 91 43 2 79 16 25 89 42 78 52 12 56 44 69 80 85 84 99 62 19 15 +Card 110: 32 38 50 41 8 97 84 60 92 40 | 43 7 51 76 69 38 92 34 41 71 8 49 95 79 32 45 42 58 60 40 4 3 98 31 20 +Card 111: 61 7 67 98 74 21 79 4 85 68 | 90 80 4 8 46 55 40 28 30 38 64 86 73 51 42 66 69 15 29 6 52 78 82 49 41 +Card 112: 13 92 98 37 72 52 1 30 42 36 | 17 65 49 6 5 33 40 10 57 72 12 53 7 15 44 18 90 46 81 99 26 16 23 52 66 +Card 113: 39 30 46 62 55 42 32 77 9 37 | 37 21 50 40 63 97 28 11 51 26 75 86 80 32 16 69 77 60 6 99 9 72 22 55 79 +Card 114: 54 6 72 17 56 76 23 78 7 38 | 15 76 40 56 8 50 51 97 94 64 13 3 69 24 54 66 14 25 82 1 71 41 47 74 92 +Card 115: 50 66 30 89 46 20 35 59 22 88 | 96 72 32 97 61 64 25 70 4 11 88 34 46 6 10 73 71 79 45 33 66 50 24 13 42 +Card 116: 83 33 99 22 90 32 11 28 47 85 | 80 58 57 7 15 1 23 59 86 54 67 36 83 38 34 18 37 35 19 90 45 24 46 4 84 +Card 117: 95 23 58 8 76 82 60 1 15 80 | 75 77 10 85 36 52 91 54 44 96 97 89 25 67 16 31 99 51 68 83 55 29 3 20 33 +Card 118: 53 7 99 97 39 37 80 52 18 77 | 76 78 83 34 75 69 39 14 27 44 89 56 23 30 43 48 57 61 29 82 87 93 67 62 12 +Card 119: 19 22 6 97 71 68 59 95 67 75 | 91 40 20 74 87 46 4 85 63 64 50 88 14 1 54 39 3 62 58 10 28 55 27 86 60 +Card 120: 37 76 87 74 15 84 14 11 99 60 | 24 15 92 60 25 3 86 1 33 5 62 65 79 6 91 45 11 14 10 2 43 4 68 85 54 +Card 121: 74 43 96 14 67 85 19 51 80 95 | 27 53 14 15 72 99 85 30 33 20 13 58 12 25 36 18 45 67 34 79 32 76 96 95 55 +Card 122: 93 51 95 32 2 18 40 72 31 45 | 8 98 70 17 62 22 63 72 69 73 3 26 42 25 1 41 28 13 77 92 32 60 56 2 65 +Card 123: 9 82 93 20 35 69 87 40 30 67 | 87 10 67 63 76 23 45 35 54 5 75 79 66 40 1 89 71 20 77 43 90 65 9 82 37 +Card 124: 93 48 59 54 75 8 83 35 4 64 | 71 59 41 35 4 65 49 5 98 91 54 45 76 64 93 75 8 83 48 87 94 32 16 89 82 +Card 125: 24 14 40 22 2 57 67 35 36 98 | 36 82 19 88 23 55 15 97 78 35 94 24 67 52 14 30 40 56 38 57 2 31 22 98 71 +Card 126: 22 7 97 12 95 66 69 51 59 88 | 94 88 59 58 70 64 95 29 7 93 68 21 16 19 36 39 41 66 10 76 78 82 63 34 56 +Card 127: 46 9 32 85 22 20 14 68 98 61 | 69 25 4 70 64 57 14 89 41 98 22 53 27 77 20 56 84 42 85 40 90 6 61 71 60 +Card 128: 53 84 81 45 23 13 93 34 42 80 | 80 74 39 50 75 49 7 61 43 5 1 51 36 54 57 97 26 32 82 98 68 45 93 37 86 +Card 129: 40 29 85 88 86 7 49 67 91 92 | 86 38 79 31 57 34 78 17 52 53 22 36 62 75 21 70 88 7 3 49 28 6 85 14 4 +Card 130: 63 20 36 62 43 98 99 12 46 57 | 14 32 99 22 17 70 5 91 57 95 49 15 28 46 84 89 78 79 43 98 45 50 88 16 23 +Card 131: 7 16 87 36 73 82 11 40 14 69 | 25 31 82 24 50 38 2 28 4 23 72 6 51 79 86 46 55 97 42 90 84 1 39 32 27 +Card 132: 67 56 15 63 40 9 59 23 94 27 | 26 65 80 40 46 23 37 78 27 12 34 98 41 59 94 16 50 79 90 15 4 7 6 62 17 +Card 133: 18 91 27 52 4 34 12 32 65 41 | 45 55 7 3 84 79 54 91 75 80 17 49 42 9 18 48 59 6 8 22 94 10 93 53 57 +Card 134: 78 75 48 26 14 8 91 41 34 68 | 18 29 57 5 17 22 56 97 74 34 13 50 40 33 62 20 10 71 58 1 21 88 87 8 25 +Card 135: 5 97 16 92 74 51 61 65 3 14 | 15 50 86 24 99 90 59 32 45 81 97 75 6 25 29 80 9 89 46 70 40 57 42 63 60 +Card 136: 81 35 23 70 51 14 31 50 67 7 | 32 28 40 58 4 99 18 95 11 90 86 13 84 74 61 5 44 47 24 38 21 1 77 48 78 +Card 137: 74 99 57 81 5 1 90 9 69 30 | 88 23 97 7 25 68 78 91 53 15 55 81 92 90 12 18 50 71 61 75 8 76 36 19 34 +Card 138: 37 2 84 13 78 51 29 15 42 71 | 49 30 16 88 79 67 76 75 38 80 91 6 28 83 14 26 1 19 40 18 32 98 74 17 44 +Card 139: 49 75 16 61 39 4 51 55 17 97 | 11 45 56 47 81 78 67 21 57 42 84 58 8 13 10 91 7 19 46 14 90 87 26 1 18 +Card 140: 39 19 41 45 17 30 29 66 61 25 | 61 53 29 41 37 30 95 93 45 17 8 21 66 10 14 78 65 18 39 5 52 91 19 25 4 +Card 141: 7 66 29 40 9 14 34 64 4 31 | 98 63 65 6 92 56 81 67 48 88 49 18 38 61 13 95 28 85 20 17 21 30 58 52 89 +Card 142: 32 88 54 27 21 86 49 87 44 45 | 15 44 67 75 87 79 21 10 34 70 54 49 88 3 28 32 65 27 43 98 53 64 45 86 9 +Card 143: 14 7 67 53 37 73 45 18 62 34 | 87 68 3 22 40 86 26 85 70 4 61 78 1 29 48 12 37 10 77 54 99 36 94 79 15 +Card 144: 92 35 52 27 19 16 58 4 22 85 | 47 37 30 51 96 28 58 81 85 9 19 10 46 22 27 7 35 52 16 60 4 92 53 13 84 +Card 145: 71 32 62 83 43 20 97 57 78 24 | 88 34 23 25 67 52 11 9 49 80 70 29 43 2 44 45 62 56 33 3 20 98 28 77 79 +Card 146: 99 11 17 93 16 77 1 46 55 68 | 25 17 77 99 35 53 3 84 98 2 21 74 27 58 16 20 33 22 39 28 69 9 92 46 52 +Card 147: 56 26 30 23 66 94 82 47 14 49 | 68 41 6 13 99 7 71 67 35 93 57 84 44 40 70 89 42 63 74 22 20 55 33 91 64 +Card 148: 21 6 43 36 7 44 61 23 93 57 | 53 20 51 59 74 77 16 92 47 25 62 58 18 85 3 63 46 81 99 5 79 70 69 75 34 +Card 149: 31 36 91 20 17 50 1 18 64 52 | 66 90 80 33 26 24 30 58 45 77 25 29 44 48 6 35 96 13 78 65 68 98 93 89 94 +Card 150: 81 91 37 66 12 33 59 97 38 32 | 61 38 91 95 75 85 48 44 37 47 84 66 35 62 79 94 25 22 97 17 10 31 96 5 78 +Card 151: 32 35 11 75 63 61 42 62 10 56 | 4 44 53 12 50 76 51 5 82 25 30 8 89 41 34 98 54 96 37 74 35 16 31 57 65 +Card 152: 96 60 29 43 99 19 80 8 5 2 | 87 52 19 11 99 35 20 60 55 80 24 21 8 61 38 78 42 28 95 6 64 65 49 59 26 +Card 153: 53 30 75 13 87 77 56 89 63 6 | 7 54 93 80 47 4 72 9 69 44 97 96 23 24 94 67 55 8 33 30 37 6 14 5 3 +Card 154: 10 65 46 58 13 25 69 52 19 3 | 47 41 9 3 40 79 89 21 33 73 14 7 74 65 31 62 24 69 60 87 12 16 53 80 82 +Card 155: 24 51 35 95 93 73 36 65 27 20 | 14 83 97 94 29 39 19 38 33 32 44 92 60 25 76 64 49 71 65 34 91 31 53 74 23 +Card 156: 52 31 50 54 82 42 23 9 39 3 | 29 64 88 70 48 74 12 90 75 57 23 25 58 68 36 33 73 5 84 28 47 92 50 41 21 +Card 157: 66 20 50 96 6 84 54 67 59 81 | 77 60 38 65 37 44 15 73 23 83 18 71 89 53 90 36 40 32 2 39 78 63 8 51 19 +Card 158: 38 46 85 81 87 86 98 90 37 34 | 41 71 35 26 12 19 51 93 39 20 76 24 7 80 50 56 49 2 57 84 68 92 54 1 75 +Card 159: 61 36 84 47 4 22 49 17 31 75 | 77 83 49 55 84 80 18 44 31 47 22 67 4 68 69 35 75 5 59 13 61 39 36 54 17 +Card 160: 90 70 62 65 87 95 15 77 76 35 | 70 94 97 10 90 80 35 27 84 87 42 62 54 26 95 57 82 63 1 18 92 25 49 64 21 +Card 161: 44 6 28 50 79 16 15 83 45 53 | 79 72 12 45 50 35 67 6 89 28 15 61 16 7 46 36 44 55 27 92 1 59 83 53 94 +Card 162: 29 51 46 64 4 75 37 78 81 71 | 83 71 37 39 74 66 32 1 51 93 43 46 20 3 15 50 81 64 75 73 78 29 33 4 22 +Card 163: 1 52 37 97 88 47 94 10 98 5 | 85 31 33 46 15 1 16 61 98 59 64 94 83 68 35 11 44 80 38 36 84 72 86 40 29 +Card 164: 60 40 94 62 18 71 92 25 21 64 | 64 18 58 76 38 55 40 45 71 92 73 75 25 62 12 94 68 79 23 91 21 60 72 39 7 +Card 165: 63 88 91 22 85 18 39 55 33 84 | 95 88 37 5 39 46 33 61 32 45 74 20 27 35 76 85 84 18 54 86 91 75 22 55 63 +Card 166: 72 11 31 50 53 82 41 74 62 87 | 42 34 50 11 96 3 77 7 37 22 44 38 62 1 87 68 12 54 74 53 47 82 69 89 85 +Card 167: 79 26 70 95 25 16 18 37 75 61 | 39 11 68 61 44 53 42 94 37 45 75 78 62 18 95 26 79 92 38 13 16 64 21 91 57 +Card 168: 94 86 69 88 31 15 62 44 19 14 | 3 24 29 8 44 61 89 7 75 15 91 36 45 70 66 4 35 6 71 22 25 39 55 33 18 +Card 169: 86 68 72 15 42 99 9 35 2 74 | 42 84 59 86 6 15 53 89 85 79 20 68 62 61 10 2 9 51 99 54 33 35 13 48 93 +Card 170: 83 6 15 80 93 63 79 50 69 5 | 15 25 6 93 69 50 83 68 16 40 66 58 63 79 52 7 80 34 61 95 5 33 78 91 32 +Card 171: 33 85 4 12 72 62 49 67 17 53 | 4 17 53 72 47 6 49 56 82 48 12 26 30 85 61 15 36 70 64 25 2 33 67 46 62 +Card 172: 98 63 26 82 12 61 56 95 27 99 | 76 30 14 95 26 97 71 19 57 67 73 48 63 54 82 18 98 27 61 5 12 44 1 56 74 +Card 173: 7 32 34 4 22 79 27 10 78 65 | 3 81 65 36 91 62 94 54 41 32 12 28 39 34 18 61 78 79 80 66 9 63 43 72 97 +Card 174: 14 78 60 32 26 31 15 80 11 72 | 1 31 33 35 73 83 97 36 21 3 26 9 91 23 51 84 82 70 22 20 34 90 98 87 69 +Card 175: 73 14 7 11 20 64 30 90 62 23 | 60 53 15 73 63 19 71 92 48 89 80 44 78 79 2 76 45 64 42 35 81 27 10 21 26 +Card 176: 32 30 39 10 1 3 67 66 94 62 | 86 95 56 54 58 35 90 19 74 43 5 48 17 2 46 65 97 71 36 31 69 8 47 94 42 +Card 177: 24 90 40 47 51 75 63 29 57 10 | 49 68 61 43 30 26 84 59 99 75 44 41 17 24 12 38 90 37 36 35 91 9 89 46 8 +Card 178: 73 74 31 76 10 21 70 3 30 41 | 39 14 30 70 79 75 97 44 87 20 92 12 86 56 18 46 8 90 23 98 2 59 28 53 3 +Card 179: 78 44 89 84 50 97 55 90 77 99 | 79 1 88 65 2 50 72 68 7 15 85 41 64 93 37 16 53 44 42 48 89 97 59 60 8 +Card 180: 55 98 13 45 33 91 88 4 49 37 | 18 44 64 83 56 79 81 26 78 54 72 75 11 70 66 57 73 61 62 34 19 95 93 94 76 +Card 181: 94 47 65 55 8 45 1 67 71 25 | 99 34 43 64 36 50 6 51 27 59 37 40 3 98 72 78 38 74 82 46 85 90 48 32 84 +Card 182: 78 75 63 31 30 70 84 50 28 19 | 61 18 58 87 77 48 71 50 91 92 60 86 73 94 85 57 97 15 1 25 74 67 11 68 47 +Card 183: 94 27 68 41 8 72 48 85 97 49 | 81 35 90 69 76 18 53 1 59 25 88 31 4 93 84 32 9 55 66 50 22 62 43 60 17 +Card 184: 40 31 56 54 59 98 93 81 24 44 | 62 42 93 56 99 10 81 59 37 6 41 66 44 72 31 30 20 54 51 24 27 83 40 73 98 +Card 185: 38 73 79 48 3 46 99 93 50 24 | 65 34 40 2 20 92 10 32 67 57 22 47 96 11 7 31 87 6 28 95 77 25 58 29 27 +Card 186: 47 65 99 98 90 68 13 49 51 10 | 90 82 27 68 84 83 57 50 18 5 49 65 85 10 46 13 21 81 73 51 71 47 98 88 99 +Card 187: 25 56 18 15 59 47 20 86 50 83 | 25 57 83 36 56 87 50 34 9 70 4 64 77 45 92 13 20 47 48 15 97 18 86 28 59 +Card 188: 99 16 44 2 85 17 71 45 49 11 | 94 13 45 36 77 89 26 6 39 27 84 1 80 21 73 41 33 90 46 72 65 96 34 71 83 +Card 189: 34 24 76 68 47 19 85 15 50 46 | 43 67 4 44 14 34 19 61 47 68 50 46 99 94 16 76 15 28 36 27 52 85 88 24 89 +Card 190: 56 20 43 86 2 88 87 30 14 4 | 43 14 19 92 3 23 87 74 50 97 2 88 18 80 20 86 36 41 95 27 57 98 49 30 26 +Card 191: 47 2 18 84 91 66 24 6 42 56 | 12 93 7 50 42 45 2 91 66 4 32 47 19 56 49 18 15 24 44 84 97 6 16 31 25 +Card 192: 42 88 68 56 93 48 9 52 20 70 | 30 93 42 4 68 70 36 56 9 15 88 98 64 67 33 91 20 61 50 27 13 94 52 48 85 +Card 193: 46 57 19 40 9 7 47 33 86 11 | 65 54 38 43 82 55 79 51 77 73 74 97 75 96 6 47 62 88 92 18 84 48 41 29 52 +Card 194: 58 23 35 79 82 72 44 93 12 43 | 43 60 2 24 77 48 61 25 44 75 35 12 93 51 36 72 6 31 29 50 37 80 19 14 87 +Card 195: 15 77 78 50 36 83 68 52 86 26 | 16 72 67 88 14 81 34 24 71 32 91 77 90 1 98 95 7 28 49 84 86 20 44 73 56 +Card 196: 25 3 32 15 1 56 27 51 82 81 | 87 79 15 11 98 54 56 88 18 92 69 25 66 27 60 58 44 1 51 3 32 81 12 72 41 +Card 197: 3 99 81 8 93 28 76 7 27 48 | 78 98 85 5 93 77 72 62 69 82 50 9 35 74 18 10 33 67 90 31 79 84 58 29 17 +Card 198: 26 81 19 24 59 82 8 95 86 17 | 13 22 10 96 19 20 88 3 90 78 24 9 50 34 6 94 7 60 44 76 31 81 26 33 43 +Card 199: 77 91 58 16 47 94 23 30 88 5 | 38 66 12 25 95 67 72 89 36 45 63 15 54 98 74 57 32 39 59 28 7 62 82 13 26 +Card 200: 82 47 52 12 83 4 26 93 33 9 | 31 30 91 2 6 27 28 1 81 8 75 92 56 57 41 24 72 85 53 74 59 11 66 32 54 +Card 201: 4 13 26 57 84 17 63 10 98 56 | 72 85 68 47 44 60 54 34 38 16 8 11 23 84 32 18 69 13 26 35 9 73 43 15 89 +Card 202: 11 9 1 42 71 78 97 89 8 10 | 33 17 81 48 60 96 69 37 12 46 73 4 76 54 86 91 28 5 51 98 99 84 13 85 32 +Card 203: 37 80 7 87 79 60 6 49 16 12 | 23 34 15 46 38 20 27 45 33 97 37 14 68 83 49 79 43 70 57 60 11 63 24 35 73 +Card 204: 84 24 48 76 7 18 77 37 69 5 | 88 39 92 94 34 37 11 40 85 35 2 81 73 58 42 66 83 9 56 12 14 51 62 20 7 +Card 205: 5 84 4 6 95 77 59 67 74 35 | 58 47 29 34 79 86 35 89 71 96 27 64 90 48 37 78 1 39 46 21 98 91 43 8 56 +Card 206: 56 21 34 13 1 17 99 11 76 60 | 36 24 83 31 50 19 82 32 61 9 98 71 79 39 97 37 29 13 27 10 52 22 41 40 59 +Card 207: 62 7 22 90 51 96 12 13 36 52 | 48 37 70 24 73 51 83 3 5 77 29 87 23 18 26 76 19 97 20 86 84 14 63 33 21 +Card 208: 40 42 5 91 29 59 70 49 23 94 | 82 81 30 61 64 65 19 9 67 75 92 16 26 52 73 43 55 35 17 93 39 90 74 53 51 diff --git a/2023/day05/Main.hs b/2023/day05/Main.hs new file mode 100644 index 0000000..e7c71e8 --- /dev/null +++ b/2023/day05/Main.hs @@ -0,0 +1,24 @@ +import Data.List.Split +import Data.List + +toMapFn :: [(Int, Int)] -> Int -> Int +toMapFn map seed + | Just (d,s) <- find (\(drs, srs) -> srs == seed) map = d + | otherwise = seed + +main :: IO () +main = do + lines <- lines <$> getContents + + let sections = splitOn [""] lines + let seeds = map read $ tail $ splitOn [' '] (sections!!0!!0) :: [Int] + + let maps = map (\(_:xs) -> (map (\l -> map (\i -> (read i) :: Int) (splitOn [' '] l)) xs)) (tail sections) + let myMaps = map (\m -> concat (map (\[drs, srs, r] -> zip [drs..(drs+r)] [srs..(srs+r)]) m)) maps + let myMapFns = map (toMapFn) myMaps + let myFn = foldr (.) id (reverse myMapFns) + + print (minimum (map myFn seeds)) + + -- mapM_ putStrLn lines + diff --git a/2023/day05/Main2.hs b/2023/day05/Main2.hs new file mode 100644 index 0000000..3a57caa --- /dev/null +++ b/2023/day05/Main2.hs @@ -0,0 +1,52 @@ +import Data.List.Split +import Data.List +import Data.Maybe + +windows :: [a] -> [[a]] +windows = filter (\xs -> length xs == 2) . map (take 2) . tails + +genBetweens :: [[Int]] -> [[Int]] +genBetweens section = map (\[[dl, sl, rl], [du, su, ru]] -> [sl + rl, sl + rl, su + ru - sl]) (windows section) + +-- 79 14 +-- +-- 50 98 2 +-- 52 50 48 +sectionToRange :: [Int] -> [Int] -> [Int] +sectionToRange [d,s,r] [start,range] + | begin <= s + r - 1 && end >= s = [d + (begin - s), end - begin + 1] + | otherwise = [start, range] + where + begin = max start s + end = min (start+range -1) (s+r-1) + +toMapFn :: [[Int]] -> [[Int]] -> [[Int]] +toMapFn section seedPairs = nub $ filter (/= []) $ concat $ map (\f -> (map (f) seedPairs)) (map (sectionToRange) section) + +main :: IO () +main = do + lines <- lines <$> getContents + + let sections = splitOn [""] lines + let seeds = map read $ tail $ splitOn [' '] (sections!!0!!0) :: [Int] + let seedPairs = chunksOf 2 seeds + + let maps = map (\(_:xs) -> (map (\l -> map (\i -> (read i) :: Int) (splitOn [' '] l)) xs)) (tail sections) + let mapsBetweens = map (\x -> [0, 0, (x!!0!!2 -1)] ++ mapBetweens map ++ maps ++ [(last x)!!1 + (last x)!!2, (last x)!!1 + (last x)!!2, (maxBound :: Int) - (last x)!!1 + (last x)!!2] ) maps + let myMapFns = map (toMapFn) maps + let myFn = foldr (.) id (reverse myMapFns) + + let seedRanges = concat $ map (\seedPair -> myFn [seedPair]) seedPairs + + print ((myMapFns!!0) [seedPairs!!0]) + -- print ((myMapFns!!1) ((myMapFns!!0) [seedPairs!!0])) + -- print ((myFn) [seedPairs!!0]) + -- print ((map (head) ((myFn) [seedPairs!!0]))) + -- print ((map (head) ((myFn) [seedPairs!!0]))) + -- print seedRanges + -- print ((map (\[start, range] -> start) seedRanges)) + -- print (minimum (map (\[start, range] -> start) seedRanges)) + + + -- mapM_ putStrLn lines + diff --git a/2023/day05/MainOpt.hs b/2023/day05/MainOpt.hs new file mode 100644 index 0000000..9b883e6 --- /dev/null +++ b/2023/day05/MainOpt.hs @@ -0,0 +1,23 @@ +import Data.List.Split +import Data.List + +toMapFn :: [[Int]] -> Int -> Int +toMapFn map seed + | Just [d,s, r] <- find (\[drs, srs, r] -> (srs <= seed) && (seed <= srs + r)) map = d + (seed - s) + | otherwise = seed + +main :: IO () +main = do + lines <- lines <$> getContents + + let sections = splitOn [""] lines + let seeds = map read $ tail $ splitOn [' '] (sections!!0!!0) :: [Int] + + let maps = map (\(_:xs) -> (map (\l -> map (\i -> (read i) :: Int) (splitOn [' '] l)) xs)) (tail sections) + let myMapFns = map (toMapFn) maps + let myFn = foldr (.) id (reverse myMapFns) + + print (minimum (map myFn seeds)) + + -- mapM_ putStrLn lines + diff --git a/2023/day05/example.txt b/2023/day05/example.txt new file mode 100644 index 0000000..f756727 --- /dev/null +++ b/2023/day05/example.txt @@ -0,0 +1,33 @@ +seeds: 79 14 55 13 + +seed-to-soil map: +50 98 2 +52 50 48 + +soil-to-fertilizer map: +0 15 37 +37 52 2 +39 0 15 + +fertilizer-to-water map: +49 53 8 +0 11 42 +42 0 7 +57 7 4 + +water-to-light map: +88 18 7 +18 25 70 + +light-to-temperature map: +45 77 23 +81 45 19 +68 64 13 + +temperature-to-humidity map: +0 69 1 +1 0 69 + +humidity-to-location map: +60 56 37 +56 93 4 diff --git a/2023/day05/input.txt b/2023/day05/input.txt new file mode 100644 index 0000000..2fb1f85 --- /dev/null +++ b/2023/day05/input.txt @@ -0,0 +1,197 @@ +seeds: 3082872446 316680412 2769223903 74043323 4131958457 99539464 109726392 353536902 619902767 648714498 3762874676 148318192 1545670780 343889780 4259893555 6139816 3980757676 20172062 2199623551 196958359 + +seed-to-soil map: +2211745924 1281207339 39747980 +3648083739 2564129012 145170114 +4171944574 2333022880 44675857 +540694760 848661020 78793182 +256996824 588160543 260500477 +1870557289 1804847051 174857657 +3877597859 2853012070 228980636 +1634159465 2150723562 100770342 +3793253853 2293912908 39109972 +652571990 567856215 20304328 +2480343183 3372556760 130573730 +1831144195 528443121 39413094 +0 1690920197 113926854 +3145720856 3081992706 290564054 +624623106 1979704708 27948884 +3844601856 3751059243 32996003 +1260492360 1175075910 106131429 +1366623789 166330978 138490835 +1175000149 927454202 85492211 +696570061 1596389312 94530885 +2647046837 3784055246 498674019 +4216620431 2709299126 78346865 +953230443 1450000160 146389152 +791100946 1012946413 162129497 +1734929807 427093569 96214388 +672876318 403399826 23693743 +113926854 2007653592 143069970 +2045414946 0 166330978 +1099619595 328019272 75380554 +3832363825 4282729265 12238031 +619487942 523307957 5135164 +517497301 304821813 23197459 +2293912908 2377698737 186430275 +1505114624 1320955319 129044841 +2610916913 3714929319 36129924 +3436284910 3503130490 211798829 +4106578495 2787645991 65366079 + +soil-to-fertilizer map: +2733576308 471599794 76965554 +1171423854 1329782324 37554133 +2640052871 928987130 93523437 +2015828352 548565348 204028986 +3562821857 3651707516 643259780 +1208977987 2596877127 12575372 +778871551 2204324824 392552303 +1221553359 2609452499 201089363 +3520687457 3069361301 42134400 +4240454288 3542205804 54513008 +2219857338 1367336457 420195533 +3034988650 3111495701 430710103 +307271757 0 471599794 +1422642722 2082393746 121931078 +3465698753 3596718812 54988704 +0 1022510567 307271757 +1544573800 1787531990 294861756 +4206081637 3034988650 34372651 +1839435556 752594334 176392796 + +fertilizer-to-water map: +1807260819 3957534991 337432305 +774926879 2718324291 701236360 +2351569884 1690420176 794087185 +313174888 2484507361 233816930 +3145657069 541109949 949949029 +546991818 313174888 227935061 +2144693124 3750658231 206876760 +4095606098 1491058978 199361198 +1476163239 3419560651 331097580 + +water-to-light map: +3834982820 3688486185 202897824 +2016707141 372287565 116618935 +3386838019 3412408553 81116937 +1125723906 705568567 205087174 +4037880644 1840142480 150018623 +2359176858 4109550629 126312910 +3328178239 4050890849 58659780 +1801115923 3893484758 43944958 +1516002989 1645262885 194879595 +3501845456 488906500 216662067 +1373868013 2223115169 142134976 +3467954956 3641943956 33890500 +1845060881 3937429716 113461133 +3718507523 910655741 57371540 +3315526510 3675834456 12651729 +2936874590 2031117287 84929853 +1710882584 3551710617 90233339 +372287565 2365250145 753436341 +2133326076 968027281 225850782 +1330811080 1990161103 40956184 +1958522014 3493525490 58185127 +3021804443 3118686486 293722067 +2485489768 1193878063 451384822 +3775879063 4235863539 59103757 +1371767264 3891384009 2100749 +4187899267 2116047140 107068029 + +light-to-temperature map: +156743496 2059819668 37694357 +4058204935 4136802755 38991573 +2484168315 1803830764 54458297 +2053264847 2531370441 7735546 +586814267 2539105987 96956250 +2538626612 2097514025 117228608 +4097196508 3782742182 197770788 +1246999413 607900903 25957627 +1877009740 1752361784 30081637 +683770517 3121708332 89729874 +1835387899 343006762 41621841 +1806332066 3242032508 29055833 +2212907940 137512351 205494411 +809588378 2954088675 69458905 +1689902424 3271088341 436818 +3306521233 894737794 308504080 +3235066415 3050253514 71454818 +1147299995 1960120250 99699418 +2046683718 749851354 6581129 +3782742182 4222506720 5456115 +2061000393 756432483 138305311 +792839631 591152156 16748747 +1478425864 2742612115 211476560 +2793367571 2636062237 73608402 +2471831801 2214742633 12336514 +194437853 1622309324 130052460 +3901915150 3980512970 156289785 +2655855220 0 137512351 +324490313 1359985370 262323954 +3855202758 4175794328 46712392 +2445108285 1782443421 21387343 +2467550357 3211438206 4281444 +3788198297 4227962835 67004461 +2199305704 2709670639 13602236 +1272957040 385683332 205468824 +1690339242 633858530 115992824 +1907091377 2227079147 139592341 +0 1203241874 156743496 +2866975973 1858289061 24590288 +1120987137 3215719650 26312858 +2891566261 3271525159 343500154 +2466495628 384628603 1054729 +1043746236 1882879349 77240901 +879047283 2366671488 164698953 +773500391 2723272875 19339240 +2418402351 3023547580 26705934 + +temperature-to-humidity map: +159374282 333555332 155635040 +2263203984 507165487 202752561 +1337996197 836383358 269347352 +733930089 139752127 104367475 +2840449774 3878218681 416748615 +3373626730 3111757526 416998602 +3943881399 2795875886 241056063 +3790625332 2642619819 153256067 +3298801153 3036931949 30341941 +1671783850 1980182260 485774285 +0 313933177 19622155 +2642619819 3680388726 197829955 +2157558135 1398186167 105645849 +4283100212 3528756128 11867084 +843670838 1503832016 347905328 +1607343549 244119602 64440301 +315009322 709918048 126465310 +441474632 1105730710 292455457 +3257198389 3540623212 41602764 +838297564 308559903 5373274 +1320021082 489190372 17975115 +4184937462 3582225976 98162750 +1191576166 1851737344 128444916 +3329143094 3067273890 44483636 +19622155 0 139752127 + +humidity-to-location map: +3728200417 3220538748 36833684 +1907946842 1065499951 70751518 +1978698360 2011387412 298481649 +4048923771 3541262102 246043525 +1314245652 402299218 396512619 +577039234 798811837 266688114 +3249926596 2795059130 273974120 +1734859977 229212353 173086865 +2718652009 3787305627 454867466 +1710758271 1405898165 24101706 +843727348 1510857580 66114574 +3765034101 3257372432 283889670 +1179488618 1876630378 134757034 +909841922 1136251469 269646696 +3675406214 4242173093 52794203 +310070062 1576972154 266969172 +229212353 1429999871 80857709 +3523900716 3069033250 151505498 +3173519475 2718652009 76407121 +2277180009 1843941326 32689052 diff --git a/2023/day06/Main.hs b/2023/day06/Main.hs new file mode 100644 index 0000000..c7976b0 --- /dev/null +++ b/2023/day06/Main.hs @@ -0,0 +1,18 @@ +import Data.List.Split (splitOn) + +winsFromTimeDist :: (Int, Int) -> Int +winsFromTimeDist (time, dist) = length $ filter (> dist) $ zipWith (*) [0..time] (reverse [0..time]) + +main :: IO () +main = do + lines <- lines <$> getContents + + -- let values = map (map (\y -> read y :: Int) . splitOn [' '] . drop 9) lines + let values = map (map read . filter (/= "") . splitOn [' '] . drop 9) lines :: [[Int]] + let time_dist = zip (values!!0) (values!!1) + let wins = map winsFromTimeDist time_dist + let result = product wins + + print result + + diff --git a/2023/day06/Main2.hs b/2023/day06/Main2.hs new file mode 100644 index 0000000..ca975dd --- /dev/null +++ b/2023/day06/Main2.hs @@ -0,0 +1,16 @@ +import Data.List.Split (splitOn) + +winsFromTimeDist :: (Int, Int) -> Int +winsFromTimeDist (time, dist) = length $ filter (> dist) $ zipWith (*) [0..time] (reverse [0..time]) + +main :: IO () +main = do + lines <- lines <$> getContents + + -- let values = map (map (\y -> read y :: Int) . splitOn [' '] . drop 9) lines + let values = map (read . filter (/= ' ') . drop 9) lines :: [Int] + let wins = winsFromTimeDist (values!!0, values!!1) + + print wins + + diff --git a/2023/day06/example.txt b/2023/day06/example.txt new file mode 100644 index 0000000..28f5ae9 --- /dev/null +++ b/2023/day06/example.txt @@ -0,0 +1,2 @@ +Time: 7 15 30 +Distance: 9 40 200 diff --git a/2023/day06/input.txt b/2023/day06/input.txt new file mode 100644 index 0000000..bb5cfbc --- /dev/null +++ b/2023/day06/input.txt @@ -0,0 +1,2 @@ +Time: 38 94 79 70 +Distance: 241 1549 1074 1091 |