Skip to content

Instantly share code, notes, and snippets.

@evinism
Created December 1, 2022 19:09
Show Gist options
  • Save evinism/f090c89306854a8197c3c5965089086d to your computer and use it in GitHub Desktop.
Save evinism/f090c89306854a8197c3c5965089086d to your computer and use it in GitHub Desktop.
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