X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-20.git;a=blobdiff_plain;f=problems%2Fday07.html;fp=problems%2Fday07.html;h=debec9fe7f289f2532c3a488f31c5acfcc9cf818;hp=0000000000000000000000000000000000000000;hb=33ea1e47e48b789d631f543e48f37287f58ffc96;hpb=a391f550e2af9522e1c64d7695b4fa60257ca3a6 diff --git a/problems/day07.html b/problems/day07.html new file mode 100644 index 0000000..debec9f --- /dev/null +++ b/problems/day07.html @@ -0,0 +1,166 @@ + + + + +Day 7 - Advent of Code 2020 + + + + + + + +

Advent of Code

Neil Smith (AoC++) 14*

   $year=2020;

+ + + +
+ +

--- Day 7: Handy Haversacks ---

You land at the regional airport in time for your next flight. In fact, it looks like you'll even have time to grab some food: all flights are currently delayed due to issues in luggage processing.

+

Due to recent aviation regulations, many rules (your puzzle input) are being enforced about bags and their contents; bags must be color-coded and must contain specific quantities of other color-coded bags. Apparently, nobody responsible for these regulations considered how long they would take to enforce!

+

For example, consider the following rules:

+
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.
+
+

These rules specify the required contents for 9 bag types. In this example, every faded blue bag is empty, every vibrant plum bag contains 11 bags (5 faded blue and 6 dotted black), and so on.

+

You have a shiny gold bag. If you wanted to carry it in at least one other bag, how many different bag colors would be valid for the outermost bag? (In other words: how many colors can, eventually, contain at least one shiny gold bag?)

+

In the above rules, the following options would be available to you:

+ +

So, in this example, the number of bag colors that can eventually contain at least one shiny gold bag is 4.

+

How many bag colors can eventually contain at least one shiny gold bag? (The list of rules is quite long; make sure you get all of it.)

+
+

Your puzzle answer was 242.

--- Part Two ---

It's getting pretty expensive to fly these days - not because of ticket prices, but because of the ridiculous number of bags you need to buy!

+

Consider again your shiny gold bag and the rules from the above example:

+ +

So, a single shiny gold bag must contain 1 dark olive bag (and the 7 bags within it) plus 2 vibrant plum bags (and the 11 bags within each of those): 1 + 1*7 + 2 + 2*11 = 32 bags!

+

Of course, the actual rules have a small chance of going several levels deeper than this example; be sure to count all of the bags, even if the nesting becomes topologically impractical!

+

Here's another example:

+
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.
+
+

In this example, a single shiny gold bag must contain 126 other bags.

+

How many individual bags are required inside your single shiny gold bag?

+
+

Your puzzle answer was 176035.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your Advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also this puzzle.

+
+ + + + + + \ No newline at end of file