Day10
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

Synopsis

Documentation

main :: IO () Source #

>>> :main
392043
1605968119

median :: Ord a => [a] -> a Source #

Return the median of an odd-length list

>>> median [1,2,0]
1

validate :: String -> String -> Either Char String Source #

Either find the first unexpected bracket, or return the expected sequence of closing characters.

>>> validate [] "{([(<{}[<>[]}>{[]{[(<()>"
Left '}'
>>> validate [] "[({(<(())[]>[[{[]{<()<>>"
Right "}}]])})]"

close :: Char -> Maybe Char Source #

Return the character that closes this bracket, if there is one.

cost2 :: String -> Int Source #

Compute the part 2 cost of the expected tail.

>>> cost2 "}}]])})]"
288957