-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solve Day 07 #12
Merged
Merged
Solve Day 07 #12
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* origin/main: Fix haskell language server tooling (#14)
Codecov Report
@@ Coverage Diff @@
## main #12 +/- ##
==========================================
+ Coverage 95.06% 95.31% +0.25%
==========================================
Files 14 15 +1
Lines 162 192 +30
Branches 13 13
==========================================
+ Hits 154 183 +29
- Misses 4 5 +1
Partials 4 4
Continue to review full report at Codecov.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
These rules specify the required contents for 9 bag types. In this example, every
faded blue
bag is empty, everyvibrant plum
bag contains 11 bags (5faded blue
and 6dotted 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 oneshiny gold
bag?)In the above rules, the following options would be available to you:
bright white
bag, which can hold yourshiny gold
bag directly.muted yellow
bag, which can hold yourshiny gold
bag directly, plus some other bags.dark orange
bag, which can holdbright white
andmuted yellow
bags, either of which could then hold yourshiny gold
bag.light red
bag, which can holdbright white
andmuted yellow
bags, either of which could then hold yourshiny 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.)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 contain0
other bags.dotted black
bags contain0
other bags.vibrant plum
bags contain11
other bags: 5faded blue
bags and 6dotted black
bags.dark olive
bags contain7
other bags: 3faded blue
bags and 4dotted black
bags.So, a single
shiny gold
bag must contain 1dark olive
bag (and the 7 bags within it) plus 2vibrant 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:
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?Link
https://adventofcode.com/2020/day/7