aboutsummaryrefslogtreecommitdiff
path: root/2020/07-Handy_Haversacks
diff options
context:
space:
mode:
Diffstat (limited to '2020/07-Handy_Haversacks')
-rw-r--r--2020/07-Handy_Haversacks/example9
-rw-r--r--2020/07-Handy_Haversacks/example27
-rw-r--r--2020/07-Handy_Haversacks/first.hs77
-rw-r--r--2020/07-Handy_Haversacks/input594
-rw-r--r--2020/07-Handy_Haversacks/second.hs80
5 files changed, 767 insertions, 0 deletions
diff --git a/2020/07-Handy_Haversacks/example b/2020/07-Handy_Haversacks/example
new file mode 100644
index 0000000..1cec74f
--- /dev/null
+++ b/2020/07-Handy_Haversacks/example
@@ -0,0 +1,9 @@
+light red bags contain 1 bright white bag, 2 muted yellow bags.
+dark orange bags contain 3 bright white bags, 4 muted yellow bags.
+bright white bags contain 1 shiny gold bag.
+muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
+shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
+dark olive bags contain 3 faded blue bags, 4 dotted black bags.
+vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
+faded blue bags contain no other bags.
+dotted black bags contain no other bags.
diff --git a/2020/07-Handy_Haversacks/example2 b/2020/07-Handy_Haversacks/example2
new file mode 100644
index 0000000..2723ca0
--- /dev/null
+++ b/2020/07-Handy_Haversacks/example2
@@ -0,0 +1,7 @@
+shiny gold bags contain 2 dark red bags.
+dark red bags contain 2 dark orange bags.
+dark orange bags contain 2 dark yellow bags.
+dark yellow bags contain 2 dark green bags.
+dark green bags contain 2 dark blue bags.
+dark blue bags contain 2 dark violet bags.
+dark violet bags contain no other bags.
diff --git a/2020/07-Handy_Haversacks/first.hs b/2020/07-Handy_Haversacks/first.hs
new file mode 100644
index 0000000..2abd1dc
--- /dev/null
+++ b/2020/07-Handy_Haversacks/first.hs
@@ -0,0 +1,77 @@
+-- requires cabal install --lib megaparsec parser-combinators
+module Main (main) where
+import Control.Monad (void, when)
+import qualified Data.Set as S
+import Data.Void (Void)
+import Text.Megaparsec
+import Text.Megaparsec.Char
+import System.Exit (die)
+
+exampleExpectedOutput = 4
+
+data Bag = Bag { name :: String
+ , contents :: [(Int, String)]
+ } deriving (Show)
+
+type Parser = Parsec Void String
+
+parseName :: Parser String
+parseName = do
+ adjective <- some letterChar
+ void (char ' ')
+ color <- some letterChar
+ return $ adjective ++ " " ++ color
+
+parseInt :: Parser Int
+parseInt = do
+ i <- some digitChar
+ return $ read i
+
+parseContent :: Parser (Int, String)
+parseContent = do
+ i <- parseInt
+ void (char ' ')
+ name <- parseName
+ void (string " bag")
+ void (optional $ char 's')
+ void (string ", " <|> string ".")
+ return (i, name)
+
+parseContents :: Parser [(Int, String)]
+parseContents = some parseContent <|> (string "no other bags." *> return [])
+
+parseBag :: Parser Bag
+parseBag = do
+ name <- parseName
+ void $ string " bags contain "
+ contents <- parseContents
+ void (char '\n')
+ return $ Bag { name=name, contents=contents }
+
+parseBags :: Parser [Bag]
+parseBags = some parseBag <* eof
+
+parseInput :: String -> IO [Bag]
+parseInput filename = do
+ input <- readFile filename
+ case runParser parseBags filename input of
+ Left bundle -> die $ errorBundlePretty bundle
+ Right bags -> return bags
+
+compute :: [Bag]-> Int
+compute bags = (length . compute' $ S.fromList ["shiny gold"]) - 1
+ where
+ bagsContaining :: S.Set String -> S.Set String
+ bagsContaining s = S.union s $ S.fromList . (map name) $ filter (\x -> not . S.null . S.intersection s $ S.fromList . (map snd) . contents $ x) bags
+ compute' :: S.Set String -> S.Set String
+ compute' s = if s == s' then s else compute' s'
+ where
+ s' = bagsContaining s
+
+main :: IO ()
+main = do
+ example <- parseInput "example"
+ let exampleOutput = compute example
+ when (exampleOutput /= exampleExpectedOutput) (die $ "example failed: got " ++ show exampleOutput ++ " instead of " ++ show exampleExpectedOutput)
+ input <- parseInput "input"
+ print $ compute input
diff --git a/2020/07-Handy_Haversacks/input b/2020/07-Handy_Haversacks/input
new file mode 100644
index 0000000..c5b0b61
--- /dev/null
+++ b/2020/07-Handy_Haversacks/input
@@ -0,0 +1,594 @@
+shiny lime bags contain 3 muted magenta bags, 3 clear cyan bags.
+shiny violet bags contain 1 faded brown bag, 1 dull red bag.
+muted maroon bags contain 4 pale lime bags.
+pale magenta bags contain 2 striped coral bags, 1 shiny orange bag, 3 vibrant white bags, 4 posh cyan bags.
+vibrant crimson bags contain 4 bright white bags, 3 dark brown bags, 4 plaid crimson bags.
+mirrored red bags contain 2 bright orange bags, 3 dull brown bags, 4 dotted brown bags.
+muted red bags contain 2 bright green bags.
+faded chartreuse bags contain 5 bright cyan bags.
+wavy red bags contain 4 drab white bags, 1 plaid silver bag.
+pale purple bags contain 4 muted yellow bags, 2 mirrored chartreuse bags, 5 mirrored purple bags, 2 mirrored red bags.
+dull blue bags contain 4 dark brown bags, 2 faded blue bags, 4 dim aqua bags.
+mirrored tomato bags contain 1 posh turquoise bag, 2 bright aqua bags.
+clear lavender bags contain 3 plaid bronze bags, 4 faded plum bags, 2 muted coral bags, 1 posh chartreuse bag.
+light cyan bags contain 1 plaid tan bag, 2 muted cyan bags, 3 dim cyan bags, 1 pale gray bag.
+plaid lavender bags contain 4 bright cyan bags, 1 dim aqua bag, 3 muted orange bags.
+dotted bronze bags contain 5 drab lime bags, 3 striped plum bags, 3 faded blue bags, 5 faded purple bags.
+clear indigo bags contain 3 dotted purple bags.
+vibrant cyan bags contain 4 dim tomato bags, 1 dull green bag, 5 light silver bags, 2 striped gold bags.
+pale yellow bags contain no other bags.
+drab gray bags contain 4 shiny maroon bags.
+clear turquoise bags contain 3 dotted blue bags, 3 faded cyan bags.
+plaid bronze bags contain 3 light tomato bags, 2 faded chartreuse bags.
+mirrored turquoise bags contain 2 plaid purple bags, 5 mirrored tomato bags, 2 drab tan bags.
+wavy turquoise bags contain 2 plaid salmon bags.
+shiny yellow bags contain 2 striped aqua bags, 5 drab gray bags, 4 pale aqua bags, 5 dim purple bags.
+clear magenta bags contain 1 striped brown bag, 1 dull black bag, 5 light lime bags.
+plaid indigo bags contain 5 wavy purple bags, 2 pale blue bags.
+plaid brown bags contain 4 striped salmon bags.
+dull gold bags contain 2 mirrored green bags, 1 shiny coral bag, 4 shiny red bags.
+dark white bags contain 3 muted black bags, 1 vibrant yellow bag, 4 dotted chartreuse bags, 3 mirrored white bags.
+drab blue bags contain 3 wavy tomato bags.
+dull teal bags contain 5 drab fuchsia bags, 4 dim black bags.
+drab aqua bags contain 3 dark red bags.
+faded gold bags contain 1 pale bronze bag, 4 dim gold bags, 1 vibrant aqua bag, 2 bright aqua bags.
+drab black bags contain 3 light cyan bags.
+dim purple bags contain 5 mirrored bronze bags, 3 shiny bronze bags, 3 shiny turquoise bags, 4 clear maroon bags.
+dim lime bags contain 4 vibrant yellow bags.
+dotted white bags contain 5 faded lime bags.
+muted lavender bags contain 3 dotted bronze bags, 2 faded chartreuse bags, 5 drab gold bags, 5 dark white bags.
+drab white bags contain 1 clear lavender bag, 3 posh maroon bags.
+bright tan bags contain 5 mirrored gray bags, 4 posh plum bags, 4 dull brown bags.
+pale beige bags contain 4 muted indigo bags.
+bright turquoise bags contain 5 wavy violet bags, 4 wavy indigo bags, 2 faded beige bags, 2 dim yellow bags.
+muted violet bags contain 4 drab lime bags.
+posh chartreuse bags contain 5 wavy silver bags, 4 light aqua bags.
+faded green bags contain 5 muted magenta bags, 4 dark fuchsia bags.
+dull orange bags contain 2 mirrored tomato bags, 4 wavy orange bags.
+posh red bags contain 5 dim chartreuse bags, 1 shiny aqua bag, 1 wavy black bag.
+clear crimson bags contain 5 dotted tan bags, 2 wavy crimson bags, 4 dim orange bags, 5 drab turquoise bags.
+striped lavender bags contain 5 plaid teal bags, 4 dull crimson bags, 4 posh lavender bags.
+faded lavender bags contain 2 vibrant coral bags.
+posh lavender bags contain 2 drab silver bags, 1 drab cyan bag.
+plaid olive bags contain 5 vibrant yellow bags, 1 striped bronze bag.
+light indigo bags contain 3 shiny cyan bags, 3 vibrant yellow bags.
+light orange bags contain 2 dark indigo bags.
+dim teal bags contain 3 bright lavender bags, 4 wavy tomato bags, 2 shiny gray bags, 5 bright blue bags.
+dull tomato bags contain 5 drab lime bags, 3 dark olive bags, 4 drab turquoise bags.
+muted indigo bags contain 5 posh chartreuse bags, 1 mirrored green bag, 3 dark brown bags, 1 dark orange bag.
+wavy fuchsia bags contain 3 mirrored magenta bags, 5 drab fuchsia bags, 5 dull green bags.
+dim violet bags contain 2 posh crimson bags.
+faded lime bags contain no other bags.
+wavy salmon bags contain 5 posh red bags.
+drab cyan bags contain 3 dull indigo bags, 1 vibrant indigo bag.
+striped purple bags contain 1 faded blue bag, 3 faded fuchsia bags, 3 pale maroon bags.
+dim aqua bags contain no other bags.
+pale olive bags contain 1 muted indigo bag.
+striped tan bags contain 4 light coral bags, 4 dull violet bags, 3 dim purple bags, 5 dull yellow bags.
+dull black bags contain 1 dotted beige bag.
+bright lime bags contain 2 light yellow bags.
+faded red bags contain 2 drab teal bags, 2 pale coral bags, 5 dotted black bags.
+vibrant green bags contain 4 drab bronze bags.
+posh gold bags contain 2 pale cyan bags, 3 clear lavender bags, 2 plaid bronze bags.
+muted magenta bags contain 5 shiny blue bags, 1 faded olive bag, 4 drab brown bags, 3 dull violet bags.
+muted lime bags contain 5 light blue bags, 1 vibrant lavender bag.
+muted tan bags contain 3 vibrant coral bags, 5 muted coral bags, 3 light bronze bags.
+drab teal bags contain 3 dotted fuchsia bags, 4 drab aqua bags, 3 dim aqua bags.
+muted purple bags contain 1 drab tan bag.
+dim brown bags contain 4 dotted tan bags.
+drab lime bags contain 1 mirrored green bag, 5 clear lime bags, 3 posh yellow bags, 5 pale yellow bags.
+wavy aqua bags contain 1 faded silver bag.
+striped magenta bags contain 2 mirrored aqua bags, 1 dotted gold bag.
+dull maroon bags contain 2 drab maroon bags, 3 shiny lavender bags.
+dotted yellow bags contain 2 dark indigo bags, 3 shiny gold bags, 2 muted coral bags, 5 pale maroon bags.
+shiny plum bags contain 5 vibrant coral bags, 3 dotted gray bags, 1 pale lime bag, 4 plaid green bags.
+faded violet bags contain 1 dark crimson bag, 5 pale gray bags, 1 pale olive bag.
+faded olive bags contain 4 wavy indigo bags.
+drab green bags contain 1 vibrant yellow bag, 1 posh tomato bag, 1 dull yellow bag, 5 shiny bronze bags.
+shiny black bags contain 3 clear gray bags, 4 dim tomato bags.
+dull coral bags contain 1 pale cyan bag, 1 light brown bag.
+mirrored coral bags contain 1 dark tomato bag, 3 vibrant coral bags, 3 posh lime bags, 3 pale fuchsia bags.
+faded white bags contain 1 light silver bag, 3 striped turquoise bags, 3 dark green bags, 3 posh orange bags.
+wavy orange bags contain 2 dotted indigo bags, 1 vibrant indigo bag, 4 dull teal bags, 3 striped gold bags.
+plaid beige bags contain 4 pale blue bags.
+plaid green bags contain 1 mirrored bronze bag, 3 mirrored purple bags, 5 shiny coral bags, 5 posh yellow bags.
+mirrored tan bags contain 1 faded blue bag.
+plaid violet bags contain 2 faded blue bags.
+shiny coral bags contain 3 vibrant bronze bags, 5 dull salmon bags.
+dim beige bags contain 3 plaid magenta bags, 2 light gold bags, 1 shiny blue bag, 5 bright teal bags.
+pale coral bags contain 1 faded orange bag, 3 dark turquoise bags.
+mirrored crimson bags contain 2 dull silver bags.
+dim tan bags contain 3 light tomato bags, 4 dotted chartreuse bags.
+striped cyan bags contain 1 faded violet bag, 3 dotted lavender bags, 4 light lavender bags, 1 drab fuchsia bag.
+dull turquoise bags contain 3 bright teal bags, 1 faded blue bag, 5 bright magenta bags.
+bright magenta bags contain 2 wavy indigo bags.
+wavy magenta bags contain 2 dim cyan bags, 2 dim violet bags, 4 dark salmon bags, 2 vibrant bronze bags.
+wavy lavender bags contain 4 pale cyan bags, 4 vibrant yellow bags, 1 vibrant white bag.
+pale green bags contain 3 dark indigo bags, 3 shiny gray bags.
+dark aqua bags contain 3 faded turquoise bags, 3 vibrant indigo bags, 3 dull salmon bags, 1 dotted gray bag.
+dim gray bags contain 1 faded silver bag, 3 muted red bags, 2 wavy orange bags, 1 posh beige bag.
+clear black bags contain 4 vibrant plum bags, 3 bright brown bags, 2 dark gray bags, 1 clear teal bag.
+drab indigo bags contain 2 dim aqua bags, 5 vibrant blue bags, 5 dull salmon bags, 5 drab violet bags.
+mirrored orange bags contain 5 posh olive bags, 5 dotted tan bags, 5 mirrored salmon bags, 4 posh red bags.
+plaid fuchsia bags contain 4 drab green bags, 3 mirrored tomato bags, 5 light white bags, 5 muted cyan bags.
+shiny teal bags contain 5 bright white bags, 5 mirrored red bags.
+light maroon bags contain 1 drab cyan bag.
+vibrant fuchsia bags contain 5 drab crimson bags.
+faded gray bags contain 3 mirrored aqua bags.
+wavy chartreuse bags contain 4 muted orange bags, 2 clear blue bags, 1 muted tan bag, 2 clear lime bags.
+dark yellow bags contain 5 wavy orange bags, 4 mirrored beige bags.
+wavy green bags contain 5 vibrant tan bags.
+dotted magenta bags contain 2 shiny red bags.
+faded crimson bags contain 4 muted gray bags, 3 dim black bags.
+dull cyan bags contain 3 posh tomato bags, 3 drab indigo bags, 2 vibrant blue bags.
+posh aqua bags contain 2 posh yellow bags.
+muted white bags contain 1 faded tomato bag.
+vibrant tomato bags contain 5 vibrant white bags.
+dim black bags contain 2 drab indigo bags.
+mirrored lime bags contain 4 dull brown bags.
+drab plum bags contain 5 plaid green bags, 5 striped lime bags, 1 dotted teal bag.
+dark olive bags contain 2 wavy plum bags.
+pale lime bags contain 4 dark orange bags, 5 dim black bags, 1 dull white bag.
+striped fuchsia bags contain 4 bright orange bags, 3 pale maroon bags.
+plaid maroon bags contain 1 dull coral bag.
+clear white bags contain 5 plaid lavender bags, 1 faded turquoise bag, 1 mirrored tomato bag, 5 faded silver bags.
+dark tan bags contain 4 striped gold bags.
+muted beige bags contain 3 dark gold bags.
+faded cyan bags contain 5 vibrant yellow bags, 2 shiny plum bags.
+drab beige bags contain 4 dotted orange bags, 2 dark black bags, 2 bright olive bags, 4 dark gold bags.
+drab turquoise bags contain 2 clear blue bags, 2 muted cyan bags, 4 faded turquoise bags.
+striped green bags contain 4 striped plum bags, 5 dark gold bags.
+bright coral bags contain 4 posh teal bags, 3 shiny crimson bags, 5 dim magenta bags.
+plaid plum bags contain 5 wavy teal bags, 3 mirrored beige bags, 3 faded silver bags.
+drab red bags contain 3 light magenta bags, 1 drab salmon bag, 4 shiny tan bags.
+dotted coral bags contain 1 faded black bag.
+wavy coral bags contain 2 posh white bags, 1 shiny gold bag, 1 striped aqua bag.
+bright aqua bags contain 1 dotted olive bag, 1 striped gold bag.
+bright purple bags contain 1 vibrant purple bag, 2 clear orange bags.
+vibrant lime bags contain 1 dotted turquoise bag, 5 dotted magenta bags, 5 light black bags.
+pale indigo bags contain 5 vibrant chartreuse bags, 5 clear white bags, 1 light lime bag, 3 dull silver bags.
+dull bronze bags contain 4 dark indigo bags, 3 plaid bronze bags, 2 pale yellow bags.
+wavy plum bags contain 5 bright chartreuse bags, 5 pale maroon bags, 1 clear lime bag.
+dull purple bags contain 4 muted gray bags.
+drab brown bags contain 3 drab lime bags, 3 dull silver bags, 2 dark gold bags, 3 drab beige bags.
+dotted crimson bags contain 1 dotted black bag.
+bright violet bags contain 5 dull olive bags, 2 striped turquoise bags, 3 vibrant aqua bags, 4 clear maroon bags.
+dark fuchsia bags contain 2 wavy purple bags, 4 pale tan bags, 2 vibrant coral bags, 5 dark brown bags.
+wavy maroon bags contain 2 striped fuchsia bags.
+light white bags contain 2 dull green bags.
+dotted indigo bags contain 2 clear lavender bags, 4 shiny coral bags.
+shiny turquoise bags contain 1 posh crimson bag, 1 posh salmon bag, 4 vibrant bronze bags.
+dull fuchsia bags contain 1 mirrored red bag, 3 posh gray bags, 4 plaid maroon bags, 4 clear gold bags.
+light magenta bags contain 3 plaid tan bags.
+faded beige bags contain 5 bright indigo bags, 1 pale yellow bag, 2 vibrant yellow bags.
+mirrored gold bags contain 1 mirrored blue bag, 2 posh fuchsia bags, 5 dark red bags.
+light salmon bags contain 5 muted black bags, 5 dull blue bags, 2 light aqua bags, 1 pale tomato bag.
+wavy gray bags contain 3 light red bags.
+bright gray bags contain 4 dotted blue bags.
+pale white bags contain 3 drab aqua bags, 3 wavy maroon bags, 4 shiny blue bags, 4 dotted lime bags.
+dim turquoise bags contain 3 striped crimson bags, 2 faded silver bags.
+clear silver bags contain 4 plaid gray bags, 1 dark black bag.
+bright brown bags contain 5 faded chartreuse bags.
+muted olive bags contain 1 dotted red bag, 1 posh green bag.
+striped silver bags contain 3 dotted tomato bags, 1 plaid cyan bag, 4 clear white bags, 5 mirrored indigo bags.
+drab yellow bags contain 5 wavy silver bags, 5 dark orange bags, 3 dark brown bags, 2 bright magenta bags.
+vibrant red bags contain 5 vibrant bronze bags, 2 posh tomato bags, 3 dull lime bags, 2 striped violet bags.
+dotted maroon bags contain 2 vibrant silver bags.
+faded teal bags contain 4 clear lavender bags.
+dim crimson bags contain 1 faded chartreuse bag.
+faded orange bags contain 3 bright magenta bags, 4 mirrored brown bags.
+dotted lime bags contain 4 light brown bags, 1 bright white bag, 5 dim lime bags.
+posh turquoise bags contain 4 striped indigo bags, 2 dim white bags.
+dark beige bags contain 1 dark olive bag.
+dotted black bags contain 2 posh turquoise bags, 3 wavy indigo bags, 4 dotted violet bags.
+dotted fuchsia bags contain 5 dark black bags, 1 clear lime bag.
+plaid magenta bags contain 3 posh maroon bags, 4 drab green bags.
+muted coral bags contain 5 light brown bags, 2 posh chartreuse bags, 1 vibrant tan bag.
+striped yellow bags contain 1 light brown bag.
+posh violet bags contain 3 bright magenta bags.
+dark brown bags contain 2 faded blue bags, 2 dim aqua bags, 5 posh yellow bags, 5 drab violet bags.
+drab fuchsia bags contain 3 shiny aqua bags, 2 plaid lavender bags, 1 muted cyan bag.
+striped maroon bags contain 4 clear lime bags, 5 striped gold bags, 3 clear plum bags, 3 dull tan bags.
+muted yellow bags contain 1 shiny turquoise bag.
+bright silver bags contain 5 striped red bags, 4 dark aqua bags.
+light beige bags contain 1 shiny gold bag, 4 dark orange bags.
+light coral bags contain 3 clear beige bags, 4 shiny maroon bags.
+plaid cyan bags contain 4 pale yellow bags, 1 drab beige bag, 1 bright chartreuse bag, 1 clear coral bag.
+shiny tomato bags contain 3 muted indigo bags, 2 faded indigo bags.
+dark maroon bags contain 1 posh white bag, 2 wavy aqua bags, 5 muted brown bags.
+plaid teal bags contain 1 dull lime bag, 3 faded blue bags, 4 drab cyan bags, 3 clear cyan bags.
+vibrant magenta bags contain 2 wavy tan bags.
+pale tomato bags contain 2 bright silver bags, 1 dull teal bag, 5 dull lime bags, 5 muted aqua bags.
+dim orange bags contain 1 vibrant white bag, 5 bright tomato bags.
+plaid crimson bags contain 2 wavy brown bags, 2 striped maroon bags, 4 dark magenta bags.
+posh beige bags contain 1 faded blue bag.
+dotted gray bags contain 3 drab silver bags, 4 faded silver bags, 2 light coral bags.
+shiny blue bags contain 1 bright magenta bag.
+pale gold bags contain 1 light coral bag, 5 vibrant aqua bags, 2 wavy plum bags, 5 dim lavender bags.
+striped chartreuse bags contain 3 wavy bronze bags.
+vibrant lavender bags contain 3 clear bronze bags, 4 dull yellow bags.
+drab tomato bags contain 1 mirrored aqua bag, 3 drab yellow bags, 2 muted white bags.
+vibrant brown bags contain 3 pale white bags.
+dark salmon bags contain 3 dull salmon bags, 5 drab violet bags, 4 striped indigo bags.
+dotted tomato bags contain 5 muted fuchsia bags, 3 pale aqua bags, 1 dim aqua bag, 3 dull yellow bags.
+wavy gold bags contain 2 light aqua bags, 3 dull white bags.
+pale salmon bags contain 2 dotted lime bags, 2 shiny gold bags.
+bright cyan bags contain no other bags.
+clear maroon bags contain 3 mirrored white bags, 5 faded blue bags, 3 drab yellow bags, 4 light aqua bags.
+dull indigo bags contain 3 vibrant indigo bags, 4 pale yellow bags.
+plaid black bags contain 2 faded orange bags, 2 drab aqua bags.
+striped salmon bags contain 5 drab violet bags, 3 dark brown bags, 4 dull white bags, 4 clear lime bags.
+wavy bronze bags contain 4 wavy silver bags, 4 light bronze bags, 2 shiny coral bags.
+dull lime bags contain 1 dull green bag, 3 dark orange bags, 4 shiny maroon bags.
+drab chartreuse bags contain 2 clear lime bags, 3 dim cyan bags, 3 faded cyan bags.
+dotted lavender bags contain 5 dull indigo bags.
+striped aqua bags contain 4 dotted lime bags, 4 dotted brown bags.
+plaid gold bags contain 2 dim lime bags, 1 dull bronze bag, 5 faded fuchsia bags, 2 drab yellow bags.
+faded coral bags contain 1 vibrant green bag, 1 drab yellow bag, 4 wavy teal bags.
+faded bronze bags contain 2 dim lime bags, 4 wavy magenta bags.
+striped turquoise bags contain 5 mirrored magenta bags.
+plaid yellow bags contain 4 mirrored maroon bags, 1 dim silver bag, 3 striped gold bags.
+vibrant coral bags contain 2 mirrored white bags, 1 dull lime bag.
+posh black bags contain 3 clear beige bags, 2 drab gold bags, 3 mirrored indigo bags, 1 dim black bag.
+wavy beige bags contain 1 vibrant purple bag, 4 light green bags, 3 light red bags.
+pale blue bags contain no other bags.
+light silver bags contain 1 posh chartreuse bag, 5 vibrant tan bags.
+mirrored teal bags contain 1 dark tomato bag, 1 wavy teal bag, 3 vibrant maroon bags, 5 pale red bags.
+pale gray bags contain 3 mirrored bronze bags, 3 faded crimson bags, 3 dotted red bags, 2 striped yellow bags.
+vibrant chartreuse bags contain 4 mirrored yellow bags.
+clear gold bags contain 1 bright magenta bag, 3 dotted olive bags, 2 posh yellow bags, 2 dull blue bags.
+wavy tomato bags contain 3 shiny coral bags, 4 posh chartreuse bags, 2 light aqua bags, 3 dark orange bags.
+posh yellow bags contain 5 vibrant bronze bags, 5 faded lime bags, 4 posh chartreuse bags, 2 bright cyan bags.
+dark lime bags contain 3 drab tomato bags.
+pale crimson bags contain 2 pale maroon bags, 5 clear lime bags.
+mirrored beige bags contain 5 clear maroon bags, 2 wavy maroon bags, 2 drab indigo bags.
+light lime bags contain 1 light bronze bag.
+vibrant silver bags contain 4 pale tan bags.
+dull plum bags contain 3 vibrant yellow bags, 1 striped plum bag, 2 dim aqua bags.
+mirrored chartreuse bags contain 3 wavy black bags.
+plaid white bags contain 5 dark aqua bags, 1 muted orange bag.
+bright fuchsia bags contain 5 vibrant tan bags.
+drab gold bags contain 1 faded blue bag.
+bright tomato bags contain 1 dim white bag, 1 drab yellow bag.
+dotted chartreuse bags contain 4 dim aqua bags.
+faded fuchsia bags contain 2 light tomato bags, 1 posh yellow bag, 4 faded chartreuse bags, 1 pale blue bag.
+pale silver bags contain 1 drab orange bag, 5 clear salmon bags, 2 plaid violet bags.
+mirrored purple bags contain 4 clear lime bags.
+mirrored green bags contain 4 dim aqua bags.
+vibrant violet bags contain 3 dark orange bags.
+plaid blue bags contain 4 striped crimson bags, 2 vibrant lavender bags, 4 faded plum bags, 5 dull salmon bags.
+muted orange bags contain 1 bright indigo bag, 4 posh yellow bags, 4 bright cyan bags.
+vibrant blue bags contain no other bags.
+light gray bags contain 2 striped green bags, 3 clear blue bags, 3 shiny coral bags.
+dark plum bags contain 2 faded crimson bags, 2 dark salmon bags, 2 shiny gray bags.
+drab violet bags contain no other bags.
+dim chartreuse bags contain 3 dotted brown bags, 5 faded plum bags, 4 wavy tomato bags.
+wavy cyan bags contain 5 faded aqua bags, 1 striped blue bag, 5 posh olive bags.
+clear teal bags contain 1 mirrored olive bag, 5 dim tomato bags.
+light violet bags contain 2 posh gray bags, 5 dotted cyan bags.
+dark tomato bags contain 5 plaid white bags, 1 wavy indigo bag.
+wavy purple bags contain 3 drab green bags.
+pale black bags contain 3 drab indigo bags.
+drab orange bags contain 5 striped turquoise bags.
+mirrored white bags contain 4 dim aqua bags.
+light purple bags contain 2 wavy green bags, 5 bright brown bags, 5 muted crimson bags, 3 dotted purple bags.
+shiny orange bags contain 2 muted indigo bags.
+bright green bags contain 3 mirrored tomato bags, 3 dim bronze bags.
+light black bags contain 4 dotted yellow bags, 3 dark turquoise bags, 3 vibrant blue bags, 4 clear maroon bags.
+shiny fuchsia bags contain 1 clear cyan bag, 1 striped silver bag, 2 bright black bags.
+striped bronze bags contain 1 dotted lime bag, 4 dark chartreuse bags, 3 shiny bronze bags.
+light tomato bags contain 5 dull salmon bags.
+drab crimson bags contain 3 clear coral bags, 5 drab bronze bags, 3 clear black bags, 2 pale maroon bags.
+vibrant aqua bags contain 2 dark black bags, 2 mirrored green bags.
+clear bronze bags contain 2 mirrored aqua bags, 4 dark green bags, 5 dotted red bags.
+bright chartreuse bags contain 1 dim lime bag.
+mirrored fuchsia bags contain 1 faded chartreuse bag, 3 pale olive bags, 4 pale cyan bags, 2 muted beige bags.
+dim plum bags contain 5 dotted bronze bags, 2 drab yellow bags, 5 shiny blue bags, 5 dotted cyan bags.
+dark indigo bags contain 4 dark brown bags, 2 dull cyan bags, 4 faded chartreuse bags.
+pale fuchsia bags contain 1 dim purple bag, 5 dark gray bags, 2 dim brown bags, 3 wavy tomato bags.
+dull green bags contain 2 dark brown bags, 4 drab indigo bags, 1 mirrored green bag, 2 drab lime bags.
+dotted aqua bags contain 2 plaid lavender bags.
+striped white bags contain 2 drab cyan bags.
+dim maroon bags contain 5 dull indigo bags, 3 pale aqua bags.
+shiny olive bags contain 2 wavy aqua bags, 4 mirrored crimson bags.
+dotted blue bags contain 4 bright brown bags, 5 dotted black bags, 2 faded teal bags, 3 pale yellow bags.
+plaid salmon bags contain 5 dull purple bags, 4 faded lime bags, 2 striped aqua bags.
+dotted gold bags contain 4 bright black bags.
+dark black bags contain 2 dull blue bags.
+posh cyan bags contain 5 shiny yellow bags.
+posh green bags contain 4 plaid beige bags.
+dim fuchsia bags contain 1 dull salmon bag, 1 dull olive bag, 5 shiny yellow bags.
+wavy brown bags contain 1 clear plum bag.
+plaid red bags contain 1 dim indigo bag, 4 muted blue bags.
+light chartreuse bags contain 1 dotted yellow bag, 4 clear gold bags, 1 bright magenta bag, 5 dark tan bags.
+vibrant white bags contain 1 muted gray bag.
+light red bags contain 1 dark bronze bag, 3 shiny lavender bags.
+light bronze bags contain 1 wavy silver bag, 3 plaid lavender bags, 4 drab violet bags, 5 mirrored green bags.
+dark magenta bags contain 5 pale aqua bags.
+striped gray bags contain 1 posh cyan bag.
+dark cyan bags contain 2 drab fuchsia bags, 1 clear cyan bag, 2 plaid gold bags.
+plaid silver bags contain 3 bright beige bags.
+shiny gray bags contain 2 dull blue bags, 2 faded chartreuse bags.
+shiny cyan bags contain 1 striped salmon bag, 4 vibrant tan bags.
+plaid gray bags contain 5 wavy aqua bags, 5 vibrant yellow bags, 1 mirrored indigo bag, 1 faded silver bag.
+drab salmon bags contain 2 muted aqua bags.
+posh gray bags contain 3 posh tan bags, 4 wavy indigo bags, 5 dark gray bags.
+shiny brown bags contain 3 muted gray bags, 2 muted tomato bags.
+drab maroon bags contain 1 bright chartreuse bag, 2 dark aqua bags, 3 dim black bags, 5 wavy silver bags.
+light yellow bags contain 5 striped purple bags, 1 faded fuchsia bag, 2 plaid gold bags, 2 dotted olive bags.
+clear salmon bags contain 3 faded chartreuse bags, 5 posh salmon bags, 5 mirrored red bags.
+bright orange bags contain 2 posh tomato bags.
+clear purple bags contain 3 dim olive bags, 2 mirrored violet bags, 1 muted tomato bag.
+dull brown bags contain 2 faded lime bags, 5 drab violet bags, 1 mirrored green bag.
+vibrant salmon bags contain 5 muted green bags, 4 faded bronze bags, 1 vibrant indigo bag.
+dull silver bags contain 2 light green bags.
+vibrant beige bags contain 2 dull cyan bags.
+muted salmon bags contain 3 bright aqua bags, 2 pale maroon bags, 1 light aqua bag.
+clear tomato bags contain 5 clear lavender bags, 4 dull tan bags, 2 dotted turquoise bags.
+striped brown bags contain 3 drab lavender bags, 5 clear lavender bags.
+dotted turquoise bags contain 1 light tan bag, 2 dull tomato bags.
+posh orange bags contain 1 mirrored cyan bag, 3 shiny cyan bags, 5 bright beige bags, 4 striped lime bags.
+dull olive bags contain 5 light silver bags, 3 wavy olive bags, 3 bright magenta bags, 4 mirrored bronze bags.
+posh maroon bags contain 2 striped violet bags, 3 plaid lavender bags, 2 clear beige bags.
+pale chartreuse bags contain 1 faded lime bag, 2 light aqua bags, 1 muted coral bag.
+dim magenta bags contain 1 faded chartreuse bag.
+striped tomato bags contain 5 plaid lavender bags, 1 posh beige bag, 1 clear lavender bag, 4 muted indigo bags.
+shiny aqua bags contain 1 wavy gold bag, 1 plaid gold bag.
+posh magenta bags contain 3 shiny beige bags, 3 clear gold bags.
+muted black bags contain 5 dull yellow bags, 4 faded beige bags.
+plaid tomato bags contain 3 dotted crimson bags, 3 shiny tan bags.
+dim red bags contain 4 light beige bags, 5 shiny gold bags, 5 posh blue bags, 4 dotted indigo bags.
+drab lavender bags contain 4 striped indigo bags, 3 vibrant tan bags, 3 plaid aqua bags, 3 plaid bronze bags.
+vibrant orange bags contain 3 dotted lavender bags, 1 posh purple bag, 5 dull cyan bags.
+light lavender bags contain 4 drab cyan bags, 5 posh maroon bags, 3 dotted red bags.
+dark red bags contain 4 faded plum bags.
+plaid chartreuse bags contain 1 posh blue bag.
+clear tan bags contain 2 dull purple bags, 2 plaid purple bags.
+muted bronze bags contain 2 plaid salmon bags, 2 muted crimson bags, 4 dotted olive bags.
+pale lavender bags contain 1 vibrant plum bag, 5 vibrant yellow bags.
+posh crimson bags contain 2 light brown bags.
+dark blue bags contain 5 mirrored tomato bags, 1 drab coral bag, 3 wavy purple bags.
+dim silver bags contain 5 drab yellow bags, 5 posh purple bags, 3 light tomato bags, 3 wavy blue bags.
+faded maroon bags contain 3 dark salmon bags, 3 faded aqua bags, 1 clear olive bag, 2 clear brown bags.
+dark bronze bags contain 3 dim white bags, 3 bright cyan bags, 4 clear olive bags, 2 faded crimson bags.
+pale orange bags contain 1 light yellow bag, 5 bright olive bags, 2 pale olive bags.
+bright maroon bags contain 3 bright white bags, 1 dotted orange bag.
+dull yellow bags contain 5 light bronze bags, 4 faded beige bags, 2 dark orange bags, 2 dull cyan bags.
+wavy violet bags contain 2 dim aqua bags, 5 posh chartreuse bags.
+dull beige bags contain 1 shiny bronze bag, 1 striped crimson bag, 5 plaid indigo bags.
+clear yellow bags contain 3 dim brown bags, 4 dotted lavender bags.
+clear red bags contain 3 shiny indigo bags, 1 vibrant plum bag, 1 dim fuchsia bag, 5 striped teal bags.
+dotted silver bags contain 5 wavy bronze bags, 4 vibrant cyan bags, 2 dull blue bags, 2 posh yellow bags.
+shiny maroon bags contain 3 muted indigo bags, 5 light white bags, 3 posh yellow bags, 4 posh tomato bags.
+dark lavender bags contain 1 vibrant tan bag, 5 plaid lime bags.
+vibrant plum bags contain 1 faded teal bag, 5 shiny plum bags, 3 bright fuchsia bags, 1 shiny coral bag.
+bright beige bags contain 2 mirrored green bags.
+clear beige bags contain 1 posh chartreuse bag, 4 drab cyan bags, 3 light beige bags.
+mirrored yellow bags contain 3 faded beige bags, 2 shiny cyan bags, 2 wavy silver bags, 2 dull yellow bags.
+shiny lavender bags contain 4 clear cyan bags.
+muted cyan bags contain 5 posh tomato bags, 2 drab gray bags, 1 dull indigo bag, 3 pale blue bags.
+light teal bags contain 3 dull yellow bags, 2 striped fuchsia bags.
+vibrant black bags contain 3 bright white bags.
+light turquoise bags contain 4 muted indigo bags, 3 mirrored silver bags, 5 dark tomato bags.
+light gold bags contain 5 mirrored magenta bags.
+dull lavender bags contain 2 wavy chartreuse bags, 3 dull crimson bags, 3 pale tomato bags.
+light olive bags contain 4 dark orange bags, 4 clear olive bags.
+pale red bags contain 3 plaid lavender bags, 4 plaid beige bags, 1 plaid coral bag, 1 shiny chartreuse bag.
+wavy lime bags contain 2 muted coral bags, 2 clear teal bags, 3 dull maroon bags, 4 dim lime bags.
+pale bronze bags contain 4 vibrant cyan bags.
+wavy tan bags contain 3 drab lavender bags, 2 dotted aqua bags, 2 bright white bags.
+faded aqua bags contain 4 wavy black bags.
+mirrored maroon bags contain 2 bright white bags, 4 dotted maroon bags, 5 light coral bags, 5 striped turquoise bags.
+striped teal bags contain 4 bright chartreuse bags, 3 striped indigo bags, 5 dark lavender bags, 4 posh white bags.
+striped coral bags contain 2 striped lime bags, 2 wavy purple bags, 1 striped plum bag.
+mirrored brown bags contain 1 faded lime bag, 5 drab indigo bags, 4 bright white bags.
+faded tomato bags contain 1 dim indigo bag, 5 shiny plum bags, 1 drab yellow bag, 4 drab indigo bags.
+shiny tan bags contain 3 dark turquoise bags, 3 muted aqua bags.
+posh tomato bags contain no other bags.
+clear chartreuse bags contain 4 shiny indigo bags, 2 dim cyan bags.
+bright olive bags contain 2 faded blue bags.
+dull tan bags contain 4 striped red bags.
+muted aqua bags contain 3 dark black bags, 4 faded crimson bags, 2 plaid white bags, 3 bright black bags.
+shiny red bags contain 1 dull blue bag, 2 bright white bags.
+bright white bags contain 2 faded blue bags.
+dotted salmon bags contain 1 dotted indigo bag.
+faded turquoise bags contain 5 dark orange bags.
+posh plum bags contain 5 faded white bags.
+wavy olive bags contain 5 light aqua bags, 1 pale lavender bag, 5 pale green bags.
+light crimson bags contain 1 muted indigo bag, 2 plaid beige bags.
+mirrored gray bags contain 1 posh lavender bag, 5 wavy indigo bags, 4 dotted crimson bags.
+striped crimson bags contain 2 striped salmon bags, 5 mirrored magenta bags, 4 drab fuchsia bags.
+posh olive bags contain 4 posh fuchsia bags, 1 drab brown bag, 4 dotted red bags.
+clear brown bags contain 1 striped plum bag.
+dark coral bags contain 1 shiny gold bag, 2 faded turquoise bags.
+mirrored violet bags contain 1 dotted gold bag, 3 striped salmon bags, 3 faded crimson bags.
+mirrored black bags contain 5 dull cyan bags, 3 wavy silver bags, 1 posh fuchsia bag.
+bright blue bags contain 3 shiny coral bags.
+light blue bags contain 1 striped indigo bag, 4 dark aqua bags, 3 mirrored tomato bags, 2 vibrant blue bags.
+dark gray bags contain 2 posh chartreuse bags, 2 mirrored tan bags.
+wavy silver bags contain no other bags.
+dark crimson bags contain 5 mirrored blue bags, 4 drab green bags, 5 plaid purple bags, 4 clear beige bags.
+wavy indigo bags contain 4 faded lime bags, 4 mirrored green bags, 2 posh tomato bags.
+shiny purple bags contain 1 pale gold bag, 1 dull tomato bag.
+dotted olive bags contain 1 drab cyan bag, 4 shiny coral bags.
+faded plum bags contain 5 dotted cyan bags.
+striped orange bags contain 2 dotted purple bags, 2 dotted indigo bags.
+dim tomato bags contain 5 mirrored green bags.
+shiny gold bags contain 1 dull white bag, 4 dark orange bags.
+posh coral bags contain 2 pale olive bags, 5 clear gold bags, 5 posh turquoise bags, 5 wavy olive bags.
+muted crimson bags contain 3 dim black bags, 1 vibrant bronze bag, 3 light black bags.
+mirrored magenta bags contain 5 wavy silver bags, 5 shiny red bags, 5 pale black bags.
+dull white bags contain 5 bright indigo bags, 3 posh tomato bags, 2 clear lime bags, 5 drab lime bags.
+pale tan bags contain 5 wavy purple bags, 5 muted orange bags, 5 dark red bags.
+muted tomato bags contain 1 dim maroon bag, 2 dull yellow bags, 3 vibrant bronze bags, 5 dull blue bags.
+pale cyan bags contain 2 wavy violet bags, 1 clear maroon bag, 2 bright orange bags.
+posh white bags contain 4 dim aqua bags, 5 posh chartreuse bags, 4 drab gold bags.
+wavy crimson bags contain 2 posh maroon bags, 5 clear cyan bags, 1 shiny maroon bag, 2 plaid bronze bags.
+drab purple bags contain 1 shiny gold bag, 5 dotted bronze bags, 4 drab gray bags.
+dark green bags contain 3 bright chartreuse bags, 3 pale green bags, 5 dotted crimson bags, 2 clear plum bags.
+dim cyan bags contain 2 shiny gold bags, 3 light silver bags, 2 vibrant blue bags.
+pale maroon bags contain 5 mirrored brown bags, 3 vibrant indigo bags.
+vibrant turquoise bags contain 3 muted cyan bags, 3 dull white bags.
+dim olive bags contain 5 drab salmon bags.
+bright salmon bags contain 3 striped turquoise bags, 2 dark salmon bags.
+faded black bags contain 2 striped plum bags, 3 muted indigo bags.
+clear aqua bags contain 2 vibrant bronze bags, 1 vibrant indigo bag, 4 mirrored tomato bags.
+muted turquoise bags contain 3 muted cyan bags, 2 light brown bags, 4 light violet bags, 1 posh salmon bag.
+shiny green bags contain 2 posh tomato bags.
+mirrored indigo bags contain 3 clear lavender bags, 3 muted magenta bags, 3 posh yellow bags.
+dim white bags contain 1 clear gold bag.
+dark teal bags contain 4 light teal bags, 3 mirrored aqua bags, 5 faded teal bags.
+wavy yellow bags contain 2 dull chartreuse bags, 5 dull yellow bags, 3 vibrant gold bags.
+light fuchsia bags contain 5 plaid white bags, 2 mirrored magenta bags, 5 striped turquoise bags, 5 light bronze bags.
+dotted plum bags contain 1 muted orange bag.
+dark purple bags contain 3 dark brown bags.
+vibrant yellow bags contain 4 posh chartreuse bags, 1 vibrant bronze bag.
+bright gold bags contain 4 dotted tomato bags.
+faded brown bags contain 1 clear cyan bag, 4 faded purple bags.
+dotted orange bags contain 5 vibrant tan bags.
+light green bags contain 3 muted orange bags, 4 muted gray bags, 3 faded silver bags, 3 shiny blue bags.
+dark silver bags contain 5 dark tan bags, 4 light silver bags.
+vibrant teal bags contain 3 shiny bronze bags, 5 mirrored green bags, 3 plaid aqua bags, 1 bright olive bag.
+mirrored plum bags contain 1 dark crimson bag, 2 striped gray bags, 3 posh white bags.
+striped red bags contain 1 dotted black bag, 1 mirrored magenta bag, 3 shiny blue bags.
+shiny beige bags contain 5 striped salmon bags, 2 bright cyan bags, 4 striped crimson bags.
+clear orange bags contain 1 faded chartreuse bag.
+striped beige bags contain 2 plaid green bags, 1 bright turquoise bag, 1 drab chartreuse bag.
+muted fuchsia bags contain 4 dotted violet bags, 1 vibrant silver bag, 1 shiny cyan bag, 1 vibrant yellow bag.
+dim lavender bags contain 4 muted cyan bags, 1 striped violet bag.
+dull red bags contain 5 posh bronze bags, 3 clear turquoise bags, 1 bright green bag, 1 vibrant white bag.
+mirrored blue bags contain 5 faded olive bags, 5 light aqua bags.
+bright crimson bags contain 1 posh olive bag, 5 faded white bags.
+drab silver bags contain 1 muted orange bag, 3 dull green bags, 3 dim aqua bags, 2 striped fuchsia bags.
+clear fuchsia bags contain 4 drab gold bags.
+vibrant olive bags contain 2 light brown bags, 1 vibrant red bag.
+dim salmon bags contain 3 dark red bags, 5 dark lavender bags, 2 dotted turquoise bags, 2 light magenta bags.
+dull crimson bags contain 5 vibrant silver bags.
+wavy blue bags contain 5 faded turquoise bags, 4 clear beige bags, 4 light green bags, 5 dark gray bags.
+mirrored aqua bags contain 4 plaid bronze bags, 2 light coral bags, 4 faded orange bags, 5 posh tomato bags.
+dim blue bags contain 1 bright silver bag, 4 bright cyan bags.
+muted green bags contain 4 dotted tomato bags.
+pale violet bags contain 3 plaid fuchsia bags, 3 light coral bags, 4 dark gold bags.
+vibrant purple bags contain 3 vibrant white bags, 1 posh beige bag.
+light tan bags contain 4 pale maroon bags, 4 muted fuchsia bags, 3 mirrored aqua bags.
+dotted green bags contain 4 faded green bags, 2 striped black bags, 4 dull brown bags, 3 faded aqua bags.
+bright bronze bags contain 2 drab bronze bags, 2 pale beige bags.
+dull salmon bags contain 1 faded blue bag, 2 wavy silver bags, 3 posh chartreuse bags.
+pale teal bags contain 2 dotted beige bags.
+vibrant indigo bags contain 3 pale yellow bags, 4 vibrant bronze bags, 4 bright cyan bags.
+shiny silver bags contain 2 faded brown bags, 2 dotted lime bags, 5 faded chartreuse bags.
+bright red bags contain 1 posh turquoise bag, 4 clear aqua bags.
+posh teal bags contain 2 pale beige bags.
+clear lime bags contain 4 vibrant blue bags, 2 wavy silver bags, 5 pale yellow bags.
+faded purple bags contain 4 faded black bags.
+plaid aqua bags contain 4 bright cyan bags, 2 pale black bags, 3 dull salmon bags.
+dark violet bags contain 4 muted green bags, 2 dotted bronze bags.
+dull aqua bags contain 5 posh aqua bags, 2 clear plum bags, 2 dim maroon bags.
+shiny chartreuse bags contain 4 dim turquoise bags, 2 posh fuchsia bags, 3 dark blue bags, 4 shiny aqua bags.
+pale plum bags contain 4 drab black bags, 4 vibrant purple bags, 1 muted turquoise bag.
+shiny indigo bags contain 2 wavy magenta bags.
+pale brown bags contain 3 posh purple bags, 5 light aqua bags, 3 striped maroon bags.
+posh tan bags contain 4 striped salmon bags, 4 dark brown bags.
+plaid lime bags contain 3 drab green bags.
+clear olive bags contain 4 dark black bags, 4 drab indigo bags, 3 clear lime bags.
+striped olive bags contain 3 bright plum bags, 5 dotted gray bags.
+plaid turquoise bags contain 4 mirrored magenta bags, 3 clear lime bags, 5 dark turquoise bags, 4 dotted olive bags.
+dotted violet bags contain 4 striped fuchsia bags, 4 wavy tomato bags, 3 dim white bags, 2 clear gold bags.
+muted silver bags contain 5 plaid tan bags, 2 dim olive bags, 4 dull cyan bags, 5 posh violet bags.
+striped blue bags contain 1 striped chartreuse bag.
+muted plum bags contain 2 posh tomato bags, 4 faded lime bags, 5 dull bronze bags, 5 wavy lime bags.
+faded yellow bags contain 2 dotted tomato bags, 3 muted yellow bags, 1 dim bronze bag.
+dull chartreuse bags contain 2 striped red bags.
+dotted tan bags contain 4 light aqua bags.
+bright indigo bags contain 2 posh tomato bags, 5 vibrant indigo bags, 2 posh chartreuse bags, 1 wavy silver bag.
+bright plum bags contain 3 light green bags, 4 wavy gray bags, 3 mirrored red bags.
+wavy teal bags contain 4 vibrant blue bags, 4 posh turquoise bags.
+striped indigo bags contain 4 shiny gold bags, 3 dim aqua bags, 5 pale black bags.
+posh brown bags contain 4 muted crimson bags.
+dotted teal bags contain 4 bright beige bags, 3 posh olive bags, 2 dull coral bags.
+dim yellow bags contain 2 shiny gray bags, 3 faded fuchsia bags, 3 wavy tomato bags, 2 light brown bags.
+faded magenta bags contain 5 pale silver bags.
+dull magenta bags contain 5 dull fuchsia bags, 1 drab green bag, 1 wavy red bag, 1 wavy fuchsia bag.
+faded salmon bags contain 2 faded gray bags.
+dim bronze bags contain 4 dark gold bags, 3 bright orange bags, 2 striped indigo bags.
+faded tan bags contain 2 striped salmon bags, 5 muted violet bags, 4 dotted violet bags, 4 light green bags.
+posh salmon bags contain 1 dull green bag, 2 bright cyan bags, 1 mirrored bronze bag.
+light brown bags contain 3 posh chartreuse bags, 5 mirrored bronze bags.
+posh silver bags contain 1 dim yellow bag, 1 clear tan bag.
+muted brown bags contain 5 dotted maroon bags, 4 shiny yellow bags, 5 dark orange bags.
+drab coral bags contain 4 faded chartreuse bags, 1 vibrant bronze bag, 5 shiny bronze bags, 3 vibrant tan bags.
+vibrant maroon bags contain 2 striped yellow bags, 2 muted indigo bags, 3 muted aqua bags.
+dim gold bags contain 2 bright violet bags.
+plaid tan bags contain 5 muted gray bags, 5 muted coral bags, 2 wavy green bags.
+dim coral bags contain 1 clear bronze bag, 2 dark gold bags, 3 drab teal bags.
+vibrant gold bags contain 3 dark chartreuse bags, 1 posh purple bag, 1 striped white bag, 2 dotted chartreuse bags.
+mirrored olive bags contain 4 striped fuchsia bags, 2 wavy indigo bags, 3 drab gold bags.
+pale aqua bags contain 5 faded chartreuse bags, 3 faded crimson bags, 5 dotted orange bags, 3 light brown bags.
+mirrored cyan bags contain 4 dull blue bags, 4 striped gold bags, 2 plaid lavender bags, 4 light silver bags.
+bright yellow bags contain 4 posh yellow bags, 5 mirrored tan bags, 2 posh tomato bags, 4 light indigo bags.
+clear cyan bags contain 1 dark gray bag, 4 vibrant indigo bags.
+bright teal bags contain 3 mirrored tan bags.
+muted blue bags contain 2 clear white bags, 4 vibrant red bags, 2 faded orange bags, 2 clear plum bags.
+dark turquoise bags contain 1 drab violet bag, 5 drab gold bags, 1 mirrored green bag.
+vibrant bronze bags contain 3 dim aqua bags, 3 light aqua bags, 3 wavy silver bags, 2 posh tomato bags.
+posh fuchsia bags contain 3 dark brown bags, 5 striped indigo bags, 1 muted indigo bag, 4 mirrored bronze bags.
+posh blue bags contain 4 clear black bags.
+mirrored salmon bags contain 1 dotted gray bag, 3 clear gold bags, 5 dark indigo bags, 2 striped gold bags.
+dark gold bags contain 2 vibrant blue bags, 3 muted indigo bags.
+dark chartreuse bags contain 4 shiny tan bags, 1 wavy lavender bag, 3 vibrant olive bags, 3 light green bags.
+drab olive bags contain 4 faded salmon bags, 4 drab white bags.
+posh purple bags contain 3 wavy gold bags.
+plaid coral bags contain 3 pale bronze bags, 5 mirrored green bags, 2 muted tan bags, 2 wavy silver bags.
+shiny magenta bags contain 4 striped green bags, 5 mirrored brown bags.
+dull gray bags contain 5 vibrant indigo bags, 3 clear fuchsia bags, 4 dotted teal bags, 4 dim bronze bags.
+clear blue bags contain 4 shiny cyan bags, 1 striped fuchsia bag.
+shiny white bags contain 4 faded tan bags, 2 shiny gold bags, 1 shiny bronze bag, 1 dim coral bag.
+bright black bags contain 5 shiny gray bags, 3 dull bronze bags, 4 striped gold bags.
+faded silver bags contain 3 clear gold bags, 4 dotted cyan bags, 1 light white bag, 4 dull green bags.
+clear plum bags contain 2 drab silver bags.
+dark orange bags contain 4 dim aqua bags, 4 drab violet bags.
+shiny salmon bags contain 5 faded violet bags, 3 muted fuchsia bags.
+plaid orange bags contain 5 light beige bags, 1 dull salmon bag.
+posh bronze bags contain 4 faded blue bags, 5 bright orange bags, 3 dark gold bags.
+striped plum bags contain 2 vibrant bronze bags.
+vibrant gray bags contain 1 clear magenta bag.
+plaid purple bags contain 1 light aqua bag, 5 vibrant tan bags, 4 pale tan bags, 4 wavy bronze bags.
+faded blue bags contain no other bags.
+pale turquoise bags contain 1 vibrant gray bag, 3 plaid purple bags, 5 drab coral bags, 5 plaid indigo bags.
+vibrant tan bags contain 4 pale yellow bags.
+striped gold bags contain 1 dull salmon bag.
+faded indigo bags contain 4 faded chartreuse bags, 2 wavy silver bags, 1 shiny green bag.
+light plum bags contain 2 faded chartreuse bags, 1 plaid lime bag, 1 posh violet bag, 5 faded plum bags.
+dim indigo bags contain 2 dim black bags, 1 wavy plum bag, 4 dark blue bags.
+mirrored bronze bags contain 4 dark gold bags, 4 posh tomato bags, 2 plaid aqua bags.
+posh indigo bags contain 2 dim maroon bags, 1 dotted gray bag, 4 dark brown bags, 3 wavy indigo bags.
+mirrored silver bags contain 3 dull aqua bags, 5 mirrored purple bags.
+drab magenta bags contain 5 pale beige bags, 4 dotted indigo bags.
+drab bronze bags contain 1 dotted brown bag, 5 clear beige bags.
+mirrored lavender bags contain 4 posh purple bags, 2 mirrored cyan bags, 3 drab gold bags.
+dotted purple bags contain 2 striped teal bags, 5 clear plum bags, 2 striped lavender bags, 2 dull violet bags.
+light aqua bags contain 2 faded blue bags, 4 drab violet bags, 5 dim aqua bags.
+dim green bags contain 5 dark bronze bags, 3 light crimson bags, 2 bright yellow bags.
+dotted cyan bags contain 3 light aqua bags.
+muted gold bags contain 5 shiny maroon bags.
+shiny crimson bags contain 5 pale aqua bags, 4 dull salmon bags, 4 dark turquoise bags.
+dotted beige bags contain 2 drab cyan bags, 5 mirrored bronze bags, 4 vibrant bronze bags, 5 shiny blue bags.
+muted chartreuse bags contain 3 plaid beige bags.
+striped lime bags contain 2 muted orange bags.
+dull violet bags contain 2 dark gold bags, 4 posh maroon bags, 2 vibrant teal bags, 4 drab teal bags.
+shiny bronze bags contain 5 light tomato bags, 1 dull blue bag, 4 dark black bags, 1 posh chartreuse bag.
+clear green bags contain 1 light green bag, 5 dim plum bags.
+wavy black bags contain 3 clear fuchsia bags, 2 striped violet bags, 1 vibrant indigo bag.
+posh lime bags contain 5 pale cyan bags, 3 clear fuchsia bags, 1 posh white bag, 4 dark turquoise bags.
+striped violet bags contain 5 bright white bags, 5 dull blue bags, 3 light tomato bags, 3 mirrored green bags.
+dotted brown bags contain 5 posh tomato bags.
+dotted red bags contain 4 dim tomato bags, 1 drab beige bag.
+wavy white bags contain 5 plaid crimson bags, 2 light magenta bags.
+muted teal bags contain 5 dim crimson bags, 1 dim cyan bag.
+bright lavender bags contain 2 dark lavender bags, 2 mirrored cyan bags, 1 dim yellow bag, 5 vibrant teal bags.
+clear coral bags contain 2 drab beige bags, 1 drab yellow bag, 1 dotted tan bag.
+clear gray bags contain 3 plaid lime bags, 1 dull beige bag, 5 light beige bags.
+drab tan bags contain 3 dull salmon bags, 3 wavy tomato bags, 2 muted orange bags, 5 clear cyan bags.
+muted gray bags contain 5 dull cyan bags, 4 clear olive bags.
+striped black bags contain 4 dull plum bags, 3 faded gray bags, 3 faded cyan bags.
+clear violet bags contain 4 posh bronze bags, 1 pale gold bag.
diff --git a/2020/07-Handy_Haversacks/second.hs b/2020/07-Handy_Haversacks/second.hs
new file mode 100644
index 0000000..3d8dcda
--- /dev/null
+++ b/2020/07-Handy_Haversacks/second.hs
@@ -0,0 +1,80 @@
+-- requires cabal install --lib megaparsec parser-combinators
+module Main (main) where
+import Control.Monad (void, when)
+import Data.List (foldl')
+import qualified Data.Map as M
+import Data.Void (Void)
+import Text.Megaparsec
+import Text.Megaparsec.Char
+import System.Exit (die)
+
+exampleExpectedOutput = 32
+exampleExpectedOutput2 = 126
+
+data Bag = Bag { name :: String
+ , contents :: [(Int, String)]
+ } deriving (Show)
+
+type Parser = Parsec Void String
+
+parseName :: Parser String
+parseName = do
+ adjective <- some letterChar
+ void (char ' ')
+ color <- some letterChar
+ return $ adjective ++ " " ++ color
+
+parseInt :: Parser Int
+parseInt = do
+ i <- some digitChar
+ return $ read i
+
+parseContent :: Parser (Int, String)
+parseContent = do
+ i <- parseInt
+ void (char ' ')
+ name <- parseName
+ void (string " bag")
+ void (optional $ char 's')
+ void (string ", " <|> string ".")
+ return (i, name)
+
+parseContents :: Parser [(Int, String)]
+parseContents = some parseContent <|> (string "no other bags." *> return [])
+
+parseBag :: Parser Bag
+parseBag = do
+ name <- parseName
+ void $ string " bags contain "
+ contents <- parseContents
+ void (char '\n')
+ return $ Bag { name=name, contents=contents }
+
+parseBags :: Parser [Bag]
+parseBags = some parseBag <* eof
+
+parseInput :: String -> IO [Bag]
+parseInput filename = do
+ input <- readFile filename
+ case runParser parseBags filename input of
+ Left bundle -> die $ errorBundlePretty bundle
+ Right bags -> return bags
+
+compute :: [Bag]-> Int
+compute bags = (compute' "shiny gold") - 1
+ where
+ bagsMap :: M.Map String Bag
+ bagsMap = foldl' (\acc b -> M.insert (name b) b acc) M.empty bags
+ compute' :: String -> Int
+ compute' s = foldl' (\acc (i, s') -> acc + i * (compute' s')) 1 (contents $ bagsMap M.! s)
+
+main :: IO ()
+main = do
+ example <- parseInput "example"
+ let exampleOutput = compute example
+ when (exampleOutput /= exampleExpectedOutput) (die $ "example failed: got " ++ show exampleOutput ++ " instead of " ++ show exampleExpectedOutput)
+ example2 <- parseInput "example2"
+ let exampleOutput2 = compute example2
+ when (exampleOutput2 /= exampleExpectedOutput2) (die $ "example2 failed: got " ++ show exampleOutput ++ " instead of " ++ show exampleExpectedOutput)
+ input <- parseInput "input"
+ print $ compute input