AdventOfCode2018

Mes tentatives pour l'AdventOfCode2018 !!
Log | Files | Refs

commit b3ce22ce023a7c5cf768fe806d1f3f481347a839
parent 539a67035ede3f40787e3cbdde0106d80fd45c53
Author: Doshirae <doshirae@doshirae.fr>
Date:   Sun,  2 Dec 2018 17:54:22 +0100

Day 02

Diffstat:
Jour2/day2.hs | 37+++++++++++++++++++++++++++++++++++++
Jour2/input.txt | 250+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 287 insertions(+), 0 deletions(-)

diff --git a/Jour2/day2.hs b/Jour2/day2.hs @@ -0,0 +1,37 @@ +import Data.List.Split +import qualified Data.Map.Strict as M + +-- part1 {{{ +plusOne :: Maybe Int -> Maybe Int +plusOne (Just v) = Just (v+1) +plusOne Nothing = Just 1 + +countLetters :: M.Map String Int -> [String] -> (Int, Int) +countLetters map (h:t) = countLetters (M.alter plusOne h map) t +countLetters map [] = (M.size twoOcc, M.size threeOcc) + where twoOcc = M.filterWithKey f map + f k v = v == 2 + threeOcc = M.filterWithKey g map + g k v = v == 3 + +processWord :: String -> (Int,Int) +processWord word = countLetters M.empty $ splitOn "" word + +zipSum :: (Int, Int) -> [(Int,Int)] -> (Int, Int) +zipSum (x,y) ((f,s):tail) = zipSum (χ x f , χ y s) tail + where χ acc val -- χ parce que le principe ressemble à la fonction caractéristique/indicatrice, qu'on note χ en cours + | val >= 1 = acc+1 + | otherwise = acc +zipSum res [] = res + +mult (x,y) = x*y + +part1 = mult . zipSum (0,0) . fmap processWord . lines +-- }}} +-- part2 {{{ +-- Beaucoup trop dur omg, même avec le code de typochon et ses commentaires je comprends pas :/ +-- }}} + +main = do + input <- readFile "input.txt" + print $ part1 input diff --git a/Jour2/input.txt b/Jour2/input.txt @@ -0,0 +1,250 @@ +prtkqyluibmtcwqaezjmhgfndx +prtkqylusbsmcwvaezjmhgfndt +prgkqyluibsocwvamzjmhgkndx +prjkqyluibsocwvahzjmhgfnsx +prtkqylcibsocwvzezjohgfndx +prtkqyluiksocwziezjmhgfndx +prikqyluiksocwvaezjmkgfndx +prtkgyluibsocwvwezjehgfndx +prtkqyluiysocwvaezjghxfndx +prtkqwluibsoxwvaezjmhgfhdx +prtkqylgibsocwvabzjmhzfndx +prtknyltibnocwvaezjmhgfndx +prdkqyluibrocwvaezjmhgnndx +prtwqyluibsoctvcezjmhgfndx +mrtkqyluibgocwvakzjmhgfndx +prtkqaouibsocwvaezjmhwfndx +prtkqyluihjocwvaezjmhgfpdx +prtkqyluikfxcwvaezjmhgfndx +prtkqybuixsocwvaczjmhgfndx +pvtkayluibsocwxaezjmhgfndx +grtkqgluibsocdvaezjmhgfndx +prlkqyluibsochvaezjmhgzndx +prtkqylxibsocmvaezjmhgfkdx +prtkqyluibsqctvaezjmpgfndx +putkqyluibsocqvaezjmhgfndw +prtjqyluibsiclvaezjmhgfndx +prtkqylvpvsocwvaezjmhgfndx +prnkqyluibsocwvaezjmhefsdx +prtktyluibsocwvaezjkhgrndx +prtkqyluibcovwvaezjthgfndx +prtkqcluibiocwvaezjmhggndx +prtkqyluihsocwveezjmhgfydx +prtklyluibsocwqaszjmhgfndx +prtkqyluibsocwvaezjmfznndx +prtkjyluijsocwvaeejmhgfndx +prtkqtluibsonwvaexjmhgfndx +prtkqyluinsocwbaezjmjgfndx +prtkqyluibslckvaezjmhgyndx +prtkqyluibsodwlpezjmhgfndx +prtkquluibsfcwvaezjhhgfndx +prtkqyluhbsocweaezsmhgfndx +prrkqyluinsocxvaezjmhgfndx +prtkqyluibsoswvaezjmhgyqdx +prtkqbluibdocwvlezjmhgfndx +prtkqyfuibsocpvaezjmhgfnwx +prtkqlluibsqjwvaezjmhgfndx +prtkqyluibrocwvaehjmjgfndx +prtkqyluibsoowvaezgmhgendx +wrtjqyluibsocwvaezfmhgfndx +prtvqyluhbsocwvaezjmtgfndx +prtkqyllibspcwvaezjmkgfndx +pqtzqyeuibsocwvaezjmhgfndx +prtkqyluibsolpvaezjmegfndx +przkayguibsocwvaezjmhgfndx +prtkqyluidsocwvaezjmyufndx +prtuqyluibsocwvaezjmfgfnkx +prtkqwluibsrcwvaezjchgfndx +prtkqyluibsotwhaozjmhgfndx +erwkqylhibsocwvaezjmhgfndx +prtkqyluibsocwvgezjmkgfedx +prskqyluiesocwvaezjmggfndx +prtkqylmitsocwvaezjmhgfnox +prtkqyluinnocwvaezjmhgfkdx +prtktyluibsokwvaezjmhgfcdx +prtkqyluibsomwvakvjmhgfndx +prtkqyltibloawvaezjmhgfndx +prtkqyluibxocwvaezgmhgqndx +prtkqyluibskcmvaezjmhgfngx +artkqylubbsotwvaezjmhgfndx +prtkqyluibzocwvhezjmhgfnbx +prskqkluibsocwvaezjmhgfjdx +prtkqyluibwocwvaezjkhglndx +prukqyluissocwvzezjmhgfndx +puhkqyluibsocwvaezjmhgfsdx +qrtkqyluibsocwvaeujmhgfndd +prtkqyluibsoctvaezjmagfnda +prtkquluibsocwkaezjmhgfqdx +prtkqyluubswcwvaezjmhvfndx +prfkqyluibsocwvaemrmhgfndx +pmtkqyluibpocwvaezjmhggndx +prtkqvluibiocwvaezjqhgfndx +prtkgypuibsocwvaezcmhgfndx +prtpqyquibsovwvaezjmhgfndx +prtwqyluiasocwvaexjmhgfndx +mrtzqyluibbocwvaezjmhgfndx +prtkqyluibsocwmaegwmhgfndx +prtkqyluibvncwvaqzjmhgfndx +prtkqyluiusocwvaezjmhmfbgx +prtkqyljibvocwvaezjehgfndx +prtkqyloibsopavaezjmhgfndx +prckqyakibsocwvaezjmhgfndx +prtkqyluibsdcwvaezjmngfddx +prekqylupbsocwvaezemhgfndx +hrtkqyluibhocwvaezjmhgfnde +prmkqyluibsocwvaezzfhgfndx +prtkqyluiccfcwvaezjmhgfndx +pdtkqyluxbsocwvaezjmhgendx +prokqyluibsocwvuezjmsgfndx +prtkqyluibsacwvaezjyhgfndv +prtkqmluibsocavaezjmhgfndc +prtkqyluibsocwvmezjmhgtnqx +prtkqytuibiocyvaezjmhgfndx +pktkqyiuibsocwvwezjmhgfndx +grtrqyluibsocwvaezjmhgfbdx +prtkqylsibjocwvaezjmhgfnyx +prtkqyhutbsocwvaexjmhgfndx +prtknyluibsocmvaezumhgfndx +prtkwyluibsocwvahzjmhgpndx +prtkqywuibsolhvaezjmhgfndx +prtkcyluibsoccvaezjthgfndx +prtkqyrdibsocwvaezjbhgfndx +prtkqyhuqbsocwvaezjmhgfxdx +pytkqyluibsocwvagzjmhgfndv +prtkqyliibsocwvaexwmhgfndx +prtkqyluibshcwvaeljphgfndx +prtkqyluibsocwvaerjzhbfndx +prtkqyduibsocwvaezvmhgfnzx +drtkqylhibsocwvaezjmhmfndx +prtkqyluibsocwvaezamfvfndx +brtkqyluqbsocwvaezjmhgpndx +prtkqyiuibsocwvuezjmhgfngx +urtkqyluibsocqvaeljmhgfndx +prtkqyluikaocwvaezjmhgfjdx +prqkqzouibsocwvaezjmhgfndx +prtkqyluibsocxvaezjmhgfnxv +prlkqyluibsoxwvaeijmhgfndx +prthuyluibsocwvaezjmhgfnhx +potkqyluizsocwvaezjmhifndx +fstkqyduibsocwvaezjmhgfndx +prtkqxluibsocwvaezjmhgffdm +prtkqylpibsozwvaezmmhgfndx +prxkqylbibsocwvaezjphgfndx +srtkqyluibsicnvaezjmhgfndx +prtktyluibsocwvaezjvhgfnax +pctkqyluxbsocwvaezwmhgfndx +prtkqylusbsoclvaezsmhgfndx +pwtkqyluibsocrvaezjmggfndx +prtkqyluibswcwraezjmhgfndd +prtkqyluibtocwiaezjmhgfnax +prtuqyluibsocwvajzjmngfndx +pwtkqyluibsocwvaerjmogfndx +petkqexuibsocwvaezjmhgfndx +pztkqyluibsocwvaerqmhgfndx +prtkqyluobsocwvaezjmapfndx +prtkqyluiinocwvaeljmhgfndx +prtkqyluibsoowvxezjmhgfnnx +lrtkqyluibsocwvfezjmhgfndc +prtkqyluibokcwvahzjmhgfndx +prtkqmlufbsocwvaegjmhgfndx +prtkqylribsocwvanzjmhgfnda +prtkqyluibspxwvaezkmhgfndx +prtiqyluibsbcwvaezjmhgfntx +prikqzluinsocwvaezjmhgfndx +prtkqnldibsocwvaezjmhxfndx +prtkqyluixsocsvaezjmhwfndx +hrtkqyluibsocwvaezjhhgfodx +prtkqyluibsrcwvaezjmhpfwdx +prtkqyluibsocwyaezjmhgffdk +prtkqyluidsocwvalmjmhgfndx +prukquluabsocwvaezjmhgfndx +prckqyluinsmcwvaezjmhgfndx +prbkqymuibsocwvaezjmhgfndc +prtkfylaibsocwvaezjmkgfndx +zrtkqyluibsocwvrbzjmhgfndx +crtkqyluibsocwvaejjmkgfndx +prttqyluibsocyvaezymhgfndx +prtkqylugbsocwvaezjxhgfmdx +prtkqyluibsocwdlezjmhgfnbx +prtkqjluibsocwvaozjhhgfndx +prtcjyluibsocwbaezjmhgfndx +rrtkqyluiblocwvaezjmhgundx +prtkkyluibsocwfaezjmhgfnyx +prtkqyuuibsocwvaezjmhgfogx +prtkyyluvbsocwvaezjmhgfnox +prpkqyluibyocwvaezjmhggndx +pdtkqyluibdocwvaezjmhgfndy +prtklysuibsocwvaezjmhgfnwx +prtkqyluabsouwvaekjmhgfndx +phtkqyluibsocwvaezjmhgfnxt +prtkqyxuibsocwvaezjmhpfnqx +prtkqyluibsodwsaezdmhgfndx +prtkbyluibsohwvaezjmhgfndr +xrtkqylhibsocwvtezjmhgfndx +prtkqyluvysocwvaezbmhgfndx +prtkqieuibsocwvaeojmhgfndx +pctkqyluibsocwvanzjmhgfnux +vrtkqyluibsozwvaezjmhgandx +prtkqyluiusocwvaezjmhmfngx +prbkqyluibsockvaxzjmhgfndx +prtkqyluibsonwvaczjmhgfndi +prtkqyluiblocwvaezjmhgfnau +prtkqyluibsocwvafzuchgfndx +prdkqyluiysocwvaezjmhgfnax +prnkqyouibsocwvaezjmhgfndq +mrtkqgluibsocwvpezjmhgfndx +pvtkqyluibsocwvaczjmhgnndx +trtkqwluibsohwvaezjmhgfndx +prmkqyluibsofwvaezjmhgfrdx +prtyqyluibpdcwvaezjmhgfndx +ertkqylulbsocwvaezjmhgfnax +prtkqyluibsacwvaeijmhgfndf +prtkqyluibyocwvapzjmhgpndx +potkqyluibgocwvaezjmhzfndx +prtkqyluibsocwyaezxmhgfnpx +prtkqkjuibsncwvaezjmhgfndx +prtqqyluibsocwlaezjmhgkndx +prtkxyluibnocwvaezjmhgkndx +prtkqyluiosocwvapzjmxgfndx +prtkqylumbsocwvyezimhgfndx +prukqyluibsocwvyezjmhgindx +prtkqylbibstcwvaezjxhgfndx +pctkqyuuibsocwvaezjuhgfndx +vrtkqyluibsocwvaezjmhgfnll +urtkqyluibsopwvaezjphgfndx +prtkceluibsocwvaepjmhgfndx +prwkxyluibsocwvaezjmhgfnzx +prtkqyluitsocwvaezqzhgfndx +prtkqkauibsorwvaezjmhgfndx +prtkqyluibsocwvaezfmftfndx +prtkiybuibsocwvaezjkhgfndx +prtkzyluibsocwgaezjmvgfndx +prtkqyluibsocwvaezjmhgqnxg +prtkqyluimsocwvauzjwhgfndx +prtkqyluibsacwgaezjmhgfndd +pwtkuyluibsccwvaezjmhgfndx +prtkqyluibsoawvaezjmvgfnlx +prtkqyluabsocwwaezjmhgftdx +patkqylnibsocwvaezjmhgfnox +prtkqyluibsocwlaxzkmhgfndx +pbtkqpluibsfcwvaezjmhgfndx +prtkqyluibsoywsaezjmhgxndx +prtkqyluibfocwvaezjyhgfhdx +pltbqylcibsocwvaezjmhgfndx +prtkdyluiisocwvvezjmhgfndx +prtkqkxuibsokwvaezjmhgfndx +prtkqyluibsoawvaezzmhgfndm +petkqyluibsgcwvaezjmhgfndu +prtkqyluibsoyxvaezjmlgfndx +prtkqyluibxocwvaezgmhnfndx +prtkikluibsocwvwezjmhgfndx +prbkqyluibsocwvaezjhhgfnux +prtkqylufbsxcwvaezjmhgfnfx +prtkqyluibsdcdvaezjmhgxndx +potkiyluibsocwvaezjmhkfndx +prtkqyluiosocsvhezjmhgfndx +prtkqyluibsocqbaezomhgfndx +prtihyluibsocwvaeujmhgfndx +prtuquruibsocwvaezjmhgfndx +prtkqyloibsocwvaeztmhifndx +ertuqyluibsocwvaeajmhgfndx