aoc2017-0.1.0.0: Advent of Code 2017 - my answers

Safe HaskellSafe
LanguageHaskell2010

Day7

Description

 

Synopsis

Documentation

parseTree :: String -> Maybe [(String, (Int, [String]))] Source #

Parses a string as a table of node name to node weight and children.

findRoot :: Ord a => [(a, (b, [a]))] -> Maybe a Source #

Finds a node with no parents.

mode :: Eq a => [a] -> Maybe a Source #

Returns the most common element.

weighTree :: (Monad m, MonadWriter (First b) m, Ord a, Eq b, Num b) => Map a (b, [a]) -> a -> m b Source #

Returns the total weight of the tree rooted at the given node.

As a side effect, also tell the corrected weight for nodes whose tree weight does not equal the majority of their siblings'.