diff --git a/.gitignore b/.gitignore index ec4d1ee..ce1720a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.fasl +*.o +*.hi data.txt \ No newline at end of file diff --git a/2023/1/Main.hs b/2023/1/Main.hs index e3ac098..6867d28 100644 --- a/2023/1/Main.hs +++ b/2023/1/Main.hs @@ -2,7 +2,7 @@ import Data.Char (isDigit, digitToInt) import Data.Function (on) import Data.List (tails, findIndex, isPrefixOf, minimumBy) import Data.Maybe (mapMaybe) -import Data.Bifunctor (first) +import Data.Bifunctor (first, bimap) type LineOp = String -> Int @@ -31,8 +31,8 @@ firstNumInLine l = fst . minimumBy (compare `on` snd) . mapMaybe numIndex opLineAdvanced :: LineOp opLineAdvanced l = (combineDigits `on` uncurry firstNumInLine) - (l, fullWordMap) - (reverse l, first reverse <$> fullWordMap) + <*> bimap reverse (map $ first reverse) + $ (l, fullWordMap) combineDigits :: Int -> Int -> Int combineDigits = (+) . (10 *)