Safe Haskell | None |
---|
Day07
Description
General - Hhhmmm ... to get started, I am going to build two data structures: contains and then (from contains) the reverse of it (isIn).
Part 1 - Just use isIn (recursively) to find all outer bags for a given bag.
Part 2 - Just use contains (recursively) to count how many bag colors can eventually contain at least one shiny gold bag.
Synopsis
Documentation
The tree of bags described by it contains and isIn relationships.
collectOuters :: IsIn -> Bag -> [Bag] #
Returns all the bags this bag is in.
countingBags :: Contains -> InnerBag -> Int #
Returns the number of bags that are in the given bag.