Add problems for days 1-7

This commit is contained in:
Brian Buller 2020-12-07 08:58:19 -06:00
parent 43a091bd88
commit 9d01c42165
7 changed files with 798 additions and 0 deletions

81
2020/day01/problem Normal file
View File

@ -0,0 +1,81 @@
# Advent of Code
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice
resort on a tropical island. Surely, Christmas will go on without you.
The tropical island has its own currency and is entirely cash-only. The gold coins used
there have a little picture of a starfish; the locals just call them stars. None of the
currency exchanges seem to have heard of them, but somehow, you'll need to find fifty of
these coins by the time you arrive so you can pay the deposit on your room.
To save your vacation, you need to get all fifty stars by December 25th.
Collect stars by solving puzzles. Two puzzles will be made available on each day in the
Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle
grants one star. Good luck!
Before you leave, the Elves in accounting just need you to fix your expense report (your
puzzle input); apparently, something isn't quite adding up.
Specifically, they need you to find the two entries that sum to 2020 and then multiply
those two numbers together.
For example, suppose your expense report contained the following:
1721
979
366
299
675
1456
In this list, the two entries that sum to 2020 are 1721 and 299. Multiplying them together
produces 1721 * 299 = 514579, so the correct answer is 514579.
Of course, your expense report is much larger. Find the two entries that sum to 2020; what
do you get if you multiply them together?
Your puzzle answer was 157059.
--- Part Two ---
The Elves in accounting are thankful for your help; one of them even offers you a starfish
coin they had left over from a past vacation. They offer you a second one if you can find
three numbers in your expense report that meet the same criteria.
Using the above example again, the three entries that sum to 2020 are 979, 366, and 675.
Multiplying them together produces the answer, 241861950.
In your expense report, what is the product of the three entries that sum to 2020?
Your puzzle answer was 165080960.
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.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://github.com/
. https://adventofcode.com/events
. https://adventofcode.com/2020
. https://adventofcode.com/2020/day/1/input

87
2020/day02/problem Normal file
View File

@ -0,0 +1,87 @@
# Advent of Code
--- Day 2: Password Philosophy ---
Your flight departs in a few days from the coastal airport; the easiest way down to the
coast from here is via toboggan.
The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's
wrong with our computers; we can't log in!" You ask if you can take a look.
Their password database seems to be a little corrupted: some of the passwords wouldn't have
been allowed by the Official Toboggan Corporate Policy that was in effect when they were
chosen.
To try to debug the problem, they have created a list (your puzzle input) of passwords
(according to the corrupted database) and the corporate policy when that password was set.
For example, suppose you have the following list:
1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc
Each line gives the password policy and then the password. The password policy indicates
the lowest and highest number of times a given letter must appear for the password to be
valid. For example, 1-3 a means that the password must contain a at least 1 time and at
most 3 times.
In the above example, 2 passwords are valid. The middle password, cdefg, is not; it
contains no instances of b, but needs at least 1. The first and third passwords are valid:
they contain one a or nine c, both within the limits of their respective policies.
How many passwords are valid according to their policies?
Your puzzle answer was 636.
--- Part Two ---
While it appears you validated the passwords correctly, they don't seem to be what the
Official Toboggan Corporate Authentication System is expecting.
The shopkeeper suddenly realizes that he just accidentally explained the password policy
rules from his old job at the sled rental place down the street! The Official Toboggan
Corporate Policy actually works a little differently.
Each policy actually describes two positions in the password, where 1 means the first
character, 2 means the second character, and so on. (Be careful; Toboggan Corporate
Policies have no concept of "index zero"!) Exactly one of these positions must contain the
given letter. Other occurrences of the letter are irrelevant for the purposes of policy
enforcement.
Given the same example list from above:
 1-3 a: abcde is valid: position 1 contains a and position 3 does not.
 1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b.
 2-9 c: ccccccccc is invalid: both position 2 and position 9 contain c.
How many passwords are valid according to the new interpretation of the policies?
Your puzzle answer was 588.
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.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://en.wikipedia.org/wiki/Toboggan
. https://adventofcode.com/2020
. https://adventofcode.com/2020/day/2/input

119
2020/day03/problem Normal file
View File

@ -0,0 +1,119 @@
# Advent of Code
--- Day 3: Toboggan Trajectory ---
With the toboggan login problems resolved, you set off toward the airport. While travel by
toboggan might be easy, it's certainly not safe: there's very minimal steering and the area
is covered in trees. You'll need to see which angles will take you near the fewest trees.
Due to the local geology, trees in this area only grow on exact integer coordinates in a
grid. You make a map (your puzzle input) of the open squares (.) and trees (#) you can see.
For example:
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#
These aren't the only trees, though; due to something you read about once involving
arboreal genetics and biome stability, the same pattern repeats to the right many times:
..##.........##.........##.........##.........##.........##....... --->
#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.##.......#.##.......#.##.......#.##.......#.##..... --->
.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........#.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...##....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.# --->
You start on the open square (.) in the top-left corner and need to reach the bottom (below
the bottom-most row on your map).
The toboggan can only follow a few specific slopes (you opted for a cheaper model that
prefers rational numbers); start by counting all the trees you would encounter for the
slope right 3, down 1:
From your starting position at the top-left, check the position that is right 3 and down 1.
Then, check the position that is right 3 and down 1 from there, and so on until you go past
the bottom of the map.
The locations you'd check in the above example are marked here with O where there was an
open square and X where there was a tree:
..##.........##.........##.........##.........##.........##....... --->
#..O#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....X..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#O#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..X...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.X#.......#.##.......#.##.......#.##.......#.##..... --->
.#.#.#....#.#.#.#.O..#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........X.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.X#...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...#X....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...X.#.#..#...#.#.#..#...#.#.#..#...#.# --->
In this example, traversing the map using this slope would cause you to encounter 7 trees.
Starting at the top-left corner of your map and following a slope of right 3 and down 1,
how many trees would you encounter?
Your puzzle answer was 289.
--- Part Two ---
Time to check the rest of the slopes - you need to minimize the probability of a sudden
arboreal stop, after all.
Determine the number of trees you would encounter if, for each of the following slopes, you
start at the top-left corner and traverse the map all the way to the bottom:
 Right 1, down 1.
 Right 3, down 1. (This is the slope you already checked.)
 Right 5, down 1.
 Right 7, down 1.
 Right 1, down 2.
In the above example, these slopes would find 2, 7, 3, 4, and 2 tree(s) respectively;
multiplied together, these produce the answer 336.
What do you get if you multiply together the number of trees encountered on each of the
listed slopes?
Your puzzle answer was 5522401584.
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.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020
. https://adventofcode.com/2020/day/3/input

170
2020/day04/problem Normal file
View File

@ -0,0 +1,170 @@
# Advent of Code
--- Day 4: Passport Processing ---
You arrive at the airport only to realize that you grabbed your North Pole Credentials
instead of your passport. While these documents are extremely similar, North Pole
Credentials aren't issued by a country and therefore aren't actually valid documentation
for travel in most of the world.
It seems like you're not the only one having problems, though; a very long line has formed
for the automatic passport scanners, and the delay could upset your travel itinerary.
Due to some questionable network security, you realize you might be able to solve both of
these problems at the same time.
The automatic passport scanners are slow because they're having trouble detecting which
passports have all required fields. The expected fields are as follows:
 byr (Birth Year)
 iyr (Issue Year)
 eyr (Expiration Year)
 hgt (Height)
 hcl (Hair Color)
 ecl (Eye Color)
 pid (Passport ID)
 cid (Country ID)
Passport data is validated in batch files (your puzzle input). Each passport is represented
as a sequence of key:value pairs separated by spaces or newlines. Passports are separated
by blank lines.
Here is an example batch file containing four passports:
ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
byr:1937 iyr:2017 cid:147 hgt:183cm
iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
hcl:#cfa07d byr:1929
hcl:#ae17e1 iyr:2013
eyr:2024
ecl:brn pid:760753108 byr:1931
hgt:179cm
hcl:#cfa07d eyr:2025 pid:166559648
iyr:2011 ecl:brn hgt:59in
The first passport is valid - all eight fields are present. The second passport is invalid
- it is missing hgt (the Height field).
The third passport is interesting; the only missing field is cid, so it looks like data
from North Pole Credentials, not a passport at all! Surely, nobody would mind if you made
the system temporarily ignore missing cid fields. Treat this "passport" as valid.
The fourth passport is missing two fields, cid and byr. Missing cid is fine, but missing
any other field is not, so this passport is invalid.
According to the above rules, your improved system would report 2 valid passports.
Count the number of valid passports - those that have all required fields. Treat cid as
optional. In your batch file, how many passports are valid?
Your puzzle answer was 256.
--- Part Two ---
The line is moving more quickly now, but you overhear airport security talking about how
passports with invalid data are getting through. Better add some data validation, quick!
You can continue to ignore the cid field, but each other field has strict rules about what
values are valid for automatic validation:
 byr (Birth Year) - four digits; at least 1920 and at most 2002.
 iyr (Issue Year) - four digits; at least 2010 and at most 2020.
 eyr (Expiration Year) - four digits; at least 2020 and at most 2030.
 hgt (Height) - a number followed by either cm or in:
 If cm, the number must be at least 150 and at most 193.
 If in, the number must be at least 59 and at most 76.
 hcl (Hair Color) - a # followed by exactly six characters 0-9 or a-f.
 ecl (Eye Color) - exactly one of: amb blu brn gry grn hzl oth.
 pid (Passport ID) - a nine-digit number, including leading zeroes.
 cid (Country ID) - ignored, missing or not.
Your job is to count the passports where all required fields are both present and valid
according to the above rules. Here are some example values:
byr valid: 2002
byr invalid: 2003
hgt valid: 60in
hgt valid: 190cm
hgt invalid: 190in
hgt invalid: 190
hcl valid: #123abc
hcl invalid: #123abz
hcl invalid: 123abc
ecl valid: brn
ecl invalid: wat
pid valid: 000000001
pid invalid: 0123456789
Here are some invalid passports:
eyr:1972 cid:100
hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926
iyr:2019
hcl:#602927 eyr:1967 hgt:170cm
ecl:grn pid:012533040 byr:1946
hcl:dab227 iyr:2012
ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992 cid:277
hgt:59cm ecl:zzz
eyr:2038 hcl:74454a iyr:2023
pid:3556412378 byr:2007
Here are some valid passports:
pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980
hcl:#623a2f
eyr:2029 ecl:blu cid:129 byr:1989
iyr:2014 pid:896056539 hcl:#a97842 hgt:165cm
hcl:#888785
hgt:164cm byr:2001 iyr:2015 cid:88
pid:545766238 ecl:hzl
eyr:2022
iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719
Count the number of valid passports - those that have all required fields and valid values.
Continue to treat cid as optional. In your batch file, how many passports are valid?
Your puzzle answer was 198.
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 [Shareon Twitter Mastodon] this puzzle.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://github.com/
. https://adventofcode.com/2020
. https://adventofcode.com/2020/day/4/input

101
2020/day05/problem Normal file
View File

@ -0,0 +1,101 @@
# Advent of Code
--- Day 5: Binary Boarding ---
You board your plane only to discover a new problem: you dropped your boarding pass! You
aren't sure which seat is yours, and all of the flight attendants are busy with the flood
of people that suddenly made it through passport control.
You write a quick program to use your phone's camera to scan all of the nearby boarding
passes (your puzzle input); perhaps you can find your seat through process of elimination.
Instead of zones or groups, this airline uses binary space partitioning to seat people. A
seat might be specified like FBFBBFFRLR, where F means "front", B means "back", L means
"left", and R means "right".
The first 7 characters will either be F or B; these specify exactly one of the 128 rows on
the plane (numbered 0 through 127). Each letter tells you which half of a region the given
seat is in. Start with the whole list of rows; the first letter indicates whether the seat
is in the front (0 through 63) or the back (64 through 127). The next letter indicates
which half of that region the seat is in, and so on until you're left with exactly one row.
For example, consider just the first seven characters of FBFBBFFRLR:
 Start by considering the whole range, rows 0 through 127.
 F means to take the lower half, keeping rows 0 through 63.
 B means to take the upper half, keeping rows 32 through 63.
 F means to take the lower half, keeping rows 32 through 47.
 B means to take the upper half, keeping rows 40 through 47.
 B keeps rows 44 through 47.
 F keeps rows 44 through 45.
 The final F keeps the lower of the two, row 44.
The last three characters will be either L or R; these specify exactly one of the 8 columns
of seats on the plane (numbered 0 through 7). The same process as above proceeds again,
this time with only three steps. L means to keep the lower half, while R means to keep the
upper half.
For example, consider just the last 3 characters of FBFBBFFRLR:
 Start by considering the whole range, columns 0 through 7.
 R means to take the upper half, keeping columns 4 through 7.
 L means to take the lower half, keeping columns 4 through 5.
 The final R keeps the upper of the two, column 5.
So, decoding FBFBBFFRLR reveals that it is the seat at row 44, column 5.
Every seat also has a unique seat ID: multiply the row by 8, then add the column. In this
example, the seat has ID 44 * 8 + 5 = 357.
Here are some other boarding passes:
 BFFFBBFRRR: row 70, column 7, seat ID 567.
 FFFBBBFRRR: row 14, column 7, seat ID 119.
 BBFFBBFRLL: row 102, column 4, seat ID 820.
As a sanity check, look through your list of boarding passes. What is the highest seat ID
on a boarding pass?
Your puzzle answer was 991.
--- Part Two ---
Ding! The "fasten seat belt" signs have turned on. Time to find your seat.
It's a completely full flight, so your seat should be the only missing boarding pass in
your list. However, there's a catch: some of the seats at the very front and back of the
plane don't exist on this aircraft, so they'll be missing from your list as well.
Your seat wasn't at the very front or back, though; the seats with IDs +1 and -1 from yours
will be in your list.
What is the ID of your seat?
Your puzzle answer was 534.
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.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://www.youtube.com/watch?v=oAHbLRjF0vo
. https://adventofcode.com/2020
. https://adventofcode.com/2020/day/5/input

129
2020/day06/problem Normal file
View File

@ -0,0 +1,129 @@
# Advent of Code
--- Day 6: Custom Customs ---
As your flight approaches the regional airport where you'll switch to a much larger plane,
customs declaration forms are distributed to the passengers.
The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is
identify the questions for which anyone in your group answers "yes". Since your group is
just you, this doesn't take very long.
However, the person sitting next to you seems to be experiencing a language barrier and
asks if you can help. For each of the people in their group, you write down the questions
for which they answer "yes", one per line. For example:
abcx
abcy
abcz
In this group, there are 6 questions to which anyone answered "yes": a, b, c, x, y, and z.
(Duplicate answers to the same question don't count extra; each question counts at most
once.)
Another group asks for your help, then another, and eventually you've collected answers
from every group on the plane (your puzzle input). Each group's answers are separated by a
blank line, and within each group, each person's answers are on a single line. For example:
abc
a
b
c
ab
ac
a
a
a
a
b
This list represents answers from five groups:
 The first group contains one person who answered "yes" to 3 questions: a, b, and c.
 The second group contains three people; combined, they answered "yes" to 3 questions:
a, b, and c.
 The third group contains two people; combined, they answered "yes" to 3 questions: a,
b, and c.
 The fourth group contains four people; combined, they answered "yes" to only 1
question, a.
 The last group contains one person who answered "yes" to only 1 question, b.
In this example, the sum of these counts is 3 + 3 + 3 + 1 + 1 = 11.
For each group, count the number of questions to which anyone answered "yes". What is the
sum of those counts?
Your puzzle answer was 6763.
--- Part Two ---
As you finish the last group's customs declaration, you notice that you misread one word in
the instructions:
You don't need to identify the questions to which anyone answered "yes"; you need to
identify the questions to which everyone answered "yes"!
Using the same example as above:
abc
a
b
c
ab
ac
a
a
a
a
b
This list represents answers from five groups:
 In the first group, everyone (all 1 person) answered "yes" to 3 questions: a, b, and c.
 In the second group, there is no question to which everyone answered "yes".
 In the third group, everyone answered yes to only 1 question, a. Since some people did
not answer "yes" to b or c, they don't count.
 In the fourth group, everyone answered yes to only 1 question, a.
 In the fifth group, everyone (all 1 person) answered "yes" to 1 question, b.
In this example, the sum of these counts is 3 + 0 + 1 + 1 + 1 = 6.
For each group, count the number of questions to which everyone answered "yes". What is the
sum of those counts?
Your puzzle answer was 3512.
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.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://en.wikipedia.org/wiki/Customs_declaration
. https://adventofcode.com/2020
. https://adventofcode.com/2020/day/6/input

111
2020/day07/problem Normal file
View File

@ -0,0 +1,111 @@
# Advent of Code
--- 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:
 A bright white bag, which can hold your shiny gold bag directly.
 A muted yellow bag, which can hold your shiny gold bag directly, plus some other bags.
 A dark orange bag, which can hold bright white and muted yellow bags, either of which
could then hold your shiny gold bag.
 A light red bag, which can hold bright white and muted yellow bags, either of which
could then hold your shiny gold bag.
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 302.
The first half of this puzzle is complete! It provides one gold star: *
--- 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:
 faded blue bags contain 0 other bags.
 dotted black bags contain 0 other bags.
 vibrant plum bags contain 11 other bags: 5 faded blue bags and 6 dotted black bags.
 dark olive bags contain 7 other bags: 3 faded blue bags and 4 dotted black bags.
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 4165.
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.
References
Visible links
. https://adventofcode.com/
. https://adventofcode.com/2020/about
. https://adventofcode.com/2020/events
. https://adventofcode.com/2020/settings
. https://adventofcode.com/2020/auth/logout
. Advent of Code Supporter
https://adventofcode.com/2020/support
. https://adventofcode.com/2020
. https://adventofcode.com/2020
. https://adventofcode.com/2020/support
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/leaderboard
. https://adventofcode.com/2020/stats
. https://adventofcode.com/2020/sponsors
. https://adventofcode.com/2020/day/7/input