diff --git a/2022/app/Main.hs b/2022/app/Main.hs index 8de16ed..d3ee9ee 100644 --- a/2022/app/Main.hs +++ b/2022/app/Main.hs @@ -21,5 +21,5 @@ main = do 4 -> Aoc.Day4.solve _ -> error "unknown day" - putStrLn $ show $ f part contents + putStrLn $ f part contents diff --git a/2022/src/Aoc/Day1.hs b/2022/src/Aoc/Day1.hs index ac68712..e1fa7be 100644 --- a/2022/src/Aoc/Day1.hs +++ b/2022/src/Aoc/Day1.hs @@ -19,6 +19,7 @@ part2 = sum . take 3 . sortDesc . inputSums where sortDesc = sortBy (comparing Down) -solve :: Integer -> String -> Integer -solve 1 input = part1 input -solve 2 input = part2 input +solve :: Integer -> String -> String +solve 1 input = show $ part1 input +solve 2 input = show $ part2 input +solve _ _ = "?" diff --git a/2022/src/Aoc/Day2.hs b/2022/src/Aoc/Day2.hs index 96db79b..b5d118a 100644 --- a/2022/src/Aoc/Day2.hs +++ b/2022/src/Aoc/Day2.hs @@ -19,8 +19,8 @@ scoreGame _ = 0 totalScore :: [[String]] -> Integer totalScore = sum . map scoreGame -solve :: Integer -> String -> Integer -solve 1 input = totalScore games +solve :: Integer -> String -> String +solve 1 input = show $ totalScore games where games = map convertGuide $ parseInput input @@ -29,7 +29,7 @@ solve 1 input = totalScore games convertGuide [p, "Z"] = [p, "C"] convertGuide xs = xs -solve 2 input = totalScore games +solve 2 input = show $ totalScore games where games = map solveGuide $ parseInput input @@ -45,4 +45,4 @@ solve 2 input = totalScore games solveGuide ["C", "Z"] = ["C", "A"] solveGuide xs = xs -solve _ _ = 0 +solve _ _ = "?" diff --git a/2022/src/Aoc/Day3.hs b/2022/src/Aoc/Day3.hs index f8eccf4..c8818ea 100644 --- a/2022/src/Aoc/Day3.hs +++ b/2022/src/Aoc/Day3.hs @@ -21,9 +21,9 @@ charToInt c | 'A' <= c && c <= 'Z' = ord c - ord 'A' + 27 | otherwise = -1 -solve :: Integer -> String -> Integer -solve 1 input = sum $ map (toInteger . charToInt . head . shared . halve) $ lines input +solve :: Integer -> String -> String +solve 1 input = show $ sum $ map (toInteger . charToInt . head . shared . halve) $ lines input -solve 2 input = sum $ map (toInteger . charToInt . head . shared) $ chunksOf 3 $ lines input +solve 2 input = show $ sum $ map (toInteger . charToInt . head . shared) $ chunksOf 3 $ lines input -solve _ _ = 0 +solve _ _ = "?" diff --git a/2022/src/Aoc/Day4.hs b/2022/src/Aoc/Day4.hs index 015d177..1396a3d 100644 --- a/2022/src/Aoc/Day4.hs +++ b/2022/src/Aoc/Day4.hs @@ -45,8 +45,8 @@ overlap ((a, b), (c, d)) solve' :: String -> (Row -> Bool) -> Integer solve' input predicate = fromIntegral $ length $ filter predicate $ parse input -solve :: Integer -> String -> Integer -solve 1 input = solve' input fullOverlap -solve 2 input = solve' input overlap +solve :: Integer -> String -> String +solve 1 input = show $ solve' input fullOverlap +solve 2 input = show $ solve' input overlap -solve _ _ = 0 +solve _ _ = "?"