Created
December 1, 2022 19:09
-
-
Save evinism/f090c89306854a8197c3c5965089086d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Text as T | |
import Data.List | |
main = do | |
input <- readFile "input.txt" | |
putStrLn $ show $ fn input | |
fn :: String -> Integer | |
fn = | |
sum | |
. take 3 | |
. sortOn (0-) | |
. fmap (sum . (fmap read) . (split "\n")) | |
. split "\n\n" | |
split :: String -> String -> [String] | |
split delim str = fmap T.unpack $ T.splitOn (T.pack delim) (T.pack str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment