part1 (2302B)
1--- Day 7: Handy Haversacks --- 2 3You land at the regional airport in time for your next flight. In fact, it looks like you'll even 4have time to grab some food: all flights are currently delayed due to [1m[37missues in luggage 5processing[0m. 6 7Due to recent aviation regulations, many rules (your puzzle input) are being enforced about bags and 8their contents; bags must be color-coded and must contain specific quantities of other color-coded 9bags. Apparently, nobody responsible for these regulations considered how long they would take to 10enforce! 11 12For example, consider the following rules: 13 14light red bags contain 1 bright white bag, 2 muted yellow bags. dark orange bags contain 3 bright 15white bags, 4 muted yellow bags. bright white bags contain 1 shiny gold bag. muted yellow bags 16contain 2 shiny gold bags, 9 faded blue bags. shiny gold bags contain 1 dark olive bag, 2 vibrant 17plum bags. dark olive bags contain 3 faded blue bags, 4 dotted black bags. vibrant plum bags contain 185 faded blue bags, 6 dotted black bags. faded blue bags contain no other bags. dotted black bags 19contain no other bags. 20 21These rules specify the required contents for 9 bag types. In this example, every faded blue bag is 22empty, every vibrant plum bag contains 11 bags (5 faded blue and 6 dotted black), and so on. 23 24You have a [1m[37mshiny gold[0m bag. If you wanted to carry it in at least one other bag, how 25many different bag colors would be valid for the outermost bag? (In other words: how many colors 26can, eventually, contain at least one shiny gold bag?) 27 28In the above rules, the following options would be available to you: 29 30- A bright white bag, which can hold your shiny gold bag directly. - A muted yellow bag, which can 31hold your shiny gold bag directly, plus some other bags. - A dark orange bag, which can hold bright 32white and muted yellow bags, either of which could then hold your shiny gold bag. - A light red bag, 33which can hold bright white and muted yellow bags, either of which could then hold your shiny gold 34bag. 35 36So, in this example, the number of bag colors that can eventually contain at least one shiny gold 37bag is [1m[37m4[0m. 38 39[1m[37mHow many bag colors can eventually contain at least one shiny gold bag?[0m (The list of 40rules is quite long; make sure you get all of it.) 41 42