Safe HaskellNone

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

type Bag = String #

type OuterBag = Bag #

type InnerBag = [Bag] #

type IsIn = Map Bag [Bag] #

data Bags #

The tree of bags described by it contains and isIn relationships.

Constructors

Bags Contains IsIn 

Instances

Instances details
Eq Bags # 
Instance details

Defined in Day07

Methods

(==) :: Bags -> Bags -> Bool

(/=) :: Bags -> Bags -> Bool

Show Bags # 
Instance details

Defined in Day07

Methods

showsPrec :: Int -> Bags -> ShowS

show :: Bags -> String

showList :: [Bags] -> ShowS

input :: String -> Bags #

Read the input file.

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.

part1 :: Bags -> Int #

Solve part1.

part2 :: Bags -> Int #

Solve part2.