At the same time, while I’ve wanted to keep covering iOS, I also wanted to expand into other portable platforms, namely programming Android, smart watches, Raspberry Pi, and Arduino devices.
I’m going to scratch these two itches by re-tooling Tampa iOS Meetup into a new meetup called Programmers of Portables, or PoP for short. If you want to know what kind of platforms and programming this meetup will cover, just read its motto: “If it fits in your hand, it’s on-brand!”
Some of the topics I’m planning for this year:
iOS and watchOS programming with Swift
Android programming with Kotlin
Cross-platform mobile programming with Flutter
Raspberry Pi programming with Python
Arduino programming with Arduino’s C-like programming language
Wearables (after all, “portable” is related to the French verb porter, which means “to wear”)
I’m going to keep the beginner-friendly focus with this revamped meetup, but don’t let “beginner-friendly” fool you into thinking that it means “simple”! In some of my “beginner-friendly” classes, we wrote:
a machine learning app that tried to identify common objects,
a machine learning app that tried to identify the kind of room your were in, and
a machine learning app that could identify various members of the Avengers.
My plan is to return to regular meetups, which will be Zoom-based until the pandemic gets under control.
I’ll announce the first meetup shortly. In the meantime, let me know what topics you’d like me to cover at PoP. You can do it in the comments for this post, or on my Twitter or LinkedIn accounts.
Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 8 challenge.
Your flight to the major airline hub reaches cruising altitude without incident. While you consider checking the in-flight menu for one of those drinks that come with a little umbrella, you are interrupted by the kid sitting next to you.
You narrow the problem down to a strange infinite loop in the boot code (your puzzle input) of the device. You should be able to fix it, but first you need to be able to run the code in isolation.
The boot code is represented as a text file with one instruction per line of text. Each instruction consists of an operation (acc, jmp, or nop) and an argument (a signed number like +4 or -20).
acc increases or decreases a single global value called the accumulator by the value given in the argument. For example, acc +7 would increase the accumulator by 7. The accumulator starts at 0. After an acc instruction, the instruction immediately below it is executed next.
jmpjumps to a new instruction relative to itself. The next instruction to execute is found using the argument as an offset from the jmp instruction; for example, jmp +2 would skip the next instruction, jmp +1 would continue to the instruction immediately below it, and jmp -20 would cause the instruction 20 lines above to be executed next.
nop stands for No OPeration – it does nothing. The instruction immediately below it is executed next.
First, the nop +0 does nothing. Then, the accumulator is increased from 0 to 1 (acc +1) and jmp +4 sets the next instruction to the other acc +1 near the bottom. After it increases the accumulator from 1 to 2, jmp -4 executes, setting the next instruction to the only acc +3. It sets the accumulator to 5, and jmp -3 causes the program to continue back at the first acc +1.
This is an infinite loop: with this sequence of jumps, the program will run forever. The moment the program tries to run any instruction a second time, you know it will never terminate.
Immediately before the program would run an instruction a second time, the value in the accumulator is 5.
Run your copy of the boot code. Immediately before any instruction is executed a second time, what value is in the accumulator?
Importing the data
Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into a Jupyter Notebook running a Python kernel.
This involves pasting it into a triple-quoted string and then assigning its value to the variable main_raw_input:
With the data imported, the next step was to build an appropriate data structure. Since today’s puzzle was based on simplified microprocessor instructions, I thought that the data structure should do the same.
I wanted my data structure to look like the table below, which shows the instructions from extracted from the first five lines of the data given to me:
Index
Opcode
Operand
0
acc
37
1
acc
-4
2
nop
405
3
jmp
276
4
acc
39
Here’s the function that I wrote to convert the input data into the data structure:
I then wrote accumulator_value_at_first_repeat(), the function that would use the data structure contained within instructions to solve the first challenge:
def accumulator_value_at_first_repeat(instructions):
program_length = len(instructions)
program_counter = 0
accumulator = 0
executed_instructions = set()
repeat_instruction_encountered = False
while 0 <= program_counter < program_length:
current_instruction = instructions[program_counter]
if program_counter in executed_instructions:
repeat_instruction_encountered = True
break
else:
executed_instructions.add(program_counter)
if current_instruction["opcode"] == "jmp":
program_counter += current_instruction["operand"]
continue
elif current_instruction["opcode"] == "acc":
accumulator += current_instruction["operand"]
elif current_instruction["opcode"] == "nop":
pass
else:
print("Something went wrong in accumulator_value_at_first_repeated_instruction().")
print(f"pc = {program_counter} acc = {accumulator}")
print(f"instruction:\n{instruction}")
program_counter += 1
if repeat_instruction_encountered:
print(f"The accumulator's contents at the first repeated instruction is: {accumulator}.")
else:
print("Reached end of instructions without repeating any of them.")
When run, it sets up the following variables:
program_length: The number of instructions in the data structure.
program_counter: The program’s equivalent of the “program counter (PC)” register in a microprocessor; contains the index the instruction to be executed.
accumulator: The program’s equivalent of an accumulator in a microprocessor. For those of you who aren’t familiar with what happens at the microprocessor level, think of the accumulator as a “scratchpad” variable where you do all the math.
executed_instructions: A set (which means that every value in it is unique) of the indices of all the instructions that have already been executed. We use it to determine if a given instruction has already been run, at which point we should stop the program and see what the value in the accumulator is.
repeat_instruction_encountered: A flag that should be set to True when an instruction is about to be executed a second time.
The function’s main loop performs a greatly simplified version of a microprocessor’s “fetch-decode-execute” cycle:
Fetch the current instruction, which is the one whose index is specified by program_counter.
See if the instruction has been executed before. If this is the case, exit the loop; otherwise, recording this instruction as having been executed.
Decode the current instruction:
If the instruction is jmp, add the operand value to program_counter and go back to the start of the loop.
If the instruction is acc, add the operand value to accumulator.
If the instruction is nop, do nothing.
If the instruction is anything else, display an error message.
After the loop is done, if the repeat_instruction_encountered flag is set, we’ve found the value we’re looking for — display it! Otherwise, display a message saying that we’ve reached the end of the instructions without ever repeating one.
I ran the function…
>>> accumulator_value_at_first_repeat(instructions)
The accumulator's contents at the first repeated instruction is: 1801.
…and got my result: 1801.
The Day 8 challenge, part two
The challenge
After some careful analysis, you believe that exactly one instruction is corrupted.
Somewhere in the program, either a jmp is supposed to be a nop, or a nop is supposed to be a jmp. (No acc instructions were harmed in the corruption of this boot code.)
The program is supposed to terminate by attempting to execute an instruction immediately after the last instruction in the file. By changing exactly one jmp or nop, you can repair the boot code and make it terminate correctly.
For example, consider the same program from above:
If you change the first instruction from nop +0 to jmp +0, it would create a single-instruction infinite loop, never leaving that instruction. If you change almost any of the jmp instructions, the program will still eventually find another jmp instruction and loop forever.
However, if you change the second-to-last instruction (from jmp -4 to nop -4), the program terminates! The instructions are visited in this order:
After the last instruction (acc +6), the program terminates by attempting to run the instruction below the last instruction in the file. With this change, after the program terminates, the accumulator contains the value 8 (acc +1, acc +1, acc +6).
Fix the program so that it terminates normally by changing exactly one jmp (to nop) or nop (to jmp). What is the value of the accumulator after the program terminates?
Here’s the function I wrote to solve this challenge:
The function, accumulator_value_and_halt_at_first_repeat(), is an expanded version of the function from part one, accumulator_value_at_first_repeat().
In addition to a set of instructions, it takes an additional parameter: the address of an instruction that should be changed — either from jmp to nop, or from nop to jmp.
The function still performs the “fetch-decode-execute” loop, and it exits the loop if it’s about to execute an instruction that’s already been executed. The main difference is that if the current instruction is the one flagged for change, it changes the instruction appropriately.
I wrote the accumulator_value_and_halt_at_first_repeat() function to be used by the function below:
def run_instructions_with_mods(program):
for index in range(len(program)):
instruction = program[index]
if instruction["opcode"] != "acc":
print(f"Found jmp or nop at address: {index}")
result = accumulator_value_and_halt_at_first_repeat(program, index)
if result["halted"]:
print(f"Found it! {result}")
break
else:
print(f"Not the correct instruction.")
This function goes through all the instructions in the set, looking for any jmp or nop instructions. When it finds one, it runs the program using accumulator_value_and_halt_at_first_repeat(), marking the jmp or nop instruction as the one to be changed.
This lets us modify the program, one jmp or nop instruction at a time, in order to find which change to a jmp or nop instruction is the one that allows the program to reach the end of the instructions.
Here’s an abridged version of what happened when I ran the function:
>>> run_instructions_with_mods(instructions)
Found jmp or nop at address: 2
Changing opcode at address 2
- Changing nop to jmp
Not the correct instruction.
Found jmp or nop at address: 3
Changing opcode at address 3
- Changing jmp to nop
Not the correct instruction.
Found jmp or nop at address: 7
Not the correct instruction.
Found jmp or nop at address: 10
Changing opcode at address 10
- Changing jmp to nop
Not the correct instruction.
...
Found jmp or nop at address: 207
Changing opcode at address 207
- Changing jmp to nop
Not the correct instruction.
Found jmp or nop at address: 209
Changing opcode at address 209
- Changing jmp to nop
Not the correct instruction.
Found jmp or nop at address: 210
Changing opcode at address 210
- Changing jmp to nop
Found it! {'halted': True, 'program_counter': 623, 'accumulator': 2060}
I entered 2060 as my answer, and step two was complete.
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.)
Spoiler alert!
Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 7 challenge.
Importing the data
Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into a Jupyter Notebook running a Python kernel.
This involves pasting it into a triple-quoted string and then using Python’s splitlines() method to break it up into a list of strings. The result is main_raw_input:
main_raw_input = """light plum bags contain 1 faded blue bag.
muted salmon bags contain 4 faded lavender bags, 4 posh magenta bags.
wavy gray bags contain 2 dotted teal bags.
wavy tan bags contain 2 plaid aqua bags.
wavy purple bags contain 1 drab white bag, 4 muted yellow bags, 2 wavy aqua bags.
dull fuchsia bags contain 2 bright indigo bags, 3 plaid cyan bags, 1 light gold bag.
striped plum bags contain 1 dull coral bag, 2 drab salmon bags.
mirrored gold bags contain 2 faded tan bags, 1 dull aqua bag.
dim blue bags contain 3 dotted gray bags, 2 mirrored turquoise bags.
dark olive bags contain 2 bright cyan bags.
dotted orange bags contain 2 pale lime bags.
vibrant aqua bags contain 5 posh plum bags, 5 faded tomato bags, 5 shiny tomato bags, 1 mirrored orange bag.
striped gray bags contain 5 drab tomato bags.
light beige bags contain 1 drab aqua bag, 5 striped yellow bags, 5 bright indigo bags.
dotted brown bags contain 5 dim tan bags, 1 dim violet bag, 2 dull turquoise bags, 3 dark olive bags.
dark turquoise bags contain 1 light bronze bag.
vibrant beige bags contain 3 wavy indigo bags, 5 striped gray bags.
dotted plum bags contain 2 mirrored green bags, 2 dull crimson bags, 2 drab tan bags, 1 vibrant coral bag.
dull indigo bags contain 2 vibrant gold bags, 1 dim chartreuse bag, 3 bright brown bags, 2 dim turquoise bags.
wavy olive bags contain 2 dotted indigo bags, 4 vibrant beige bags, 1 dotted gray bag.
posh olive bags contain 4 muted magenta bags, 5 dim cyan bags, 3 drab bronze bags, 2 pale lime bags.
dotted silver bags contain 3 light brown bags.
dim purple bags contain 5 clear lavender bags, 4 drab aqua bags, 1 mirrored bronze bag.
wavy green bags contain 4 plaid white bags, 3 clear cyan bags, 1 striped gray bag, 4 clear coral bags.
dark brown bags contain 4 light brown bags, 2 light magenta bags, 3 dotted gold bags.
dark aqua bags contain 1 dull coral bag, 4 shiny coral bags, 3 vibrant crimson bags, 2 muted black bags.
shiny gray bags contain 1 dark gray bag, 4 pale purple bags.
posh brown bags contain 1 posh magenta bag, 5 wavy bronze bags, 5 posh yellow bags.
clear turquoise bags contain 1 shiny tan bag, 1 muted salmon bag.
dotted teal bags contain 5 bright tan bags, 5 vibrant crimson bags.
drab coral bags contain 1 striped brown bag, 1 light lime bag, 1 faded green bag.
dull plum bags contain 5 vibrant silver bags.
bright orange bags contain 2 dark yellow bags, 4 mirrored silver bags, 4 mirrored cyan bags, 2 striped tomato bags.
drab bronze bags contain 2 drab violet bags, 2 striped bronze bags.
dim tan bags contain 1 shiny black bag, 5 posh aqua bags.
clear indigo bags contain 4 clear tan bags, 5 vibrant silver bags, 2 striped orange bags, 2 dotted lavender bags.
muted violet bags contain 4 mirrored white bags, 1 dim blue bag, 4 faded beige bags.
posh aqua bags contain 4 striped fuchsia bags, 4 pale red bags, 5 muted coral bags.
mirrored purple bags contain 5 dim beige bags, 5 shiny brown bags, 5 posh indigo bags, 3 clear turquoise bags.
vibrant orange bags contain 1 dark turquoise bag, 1 dotted olive bag, 3 dull coral bags, 3 dark chartreuse bags.
light tomato bags contain 4 mirrored lime bags, 3 pale beige bags, 4 clear magenta bags.
drab indigo bags contain 5 mirrored blue bags, 1 dull salmon bag.
bright red bags contain 3 pale gold bags, 5 dim fuchsia bags, 5 mirrored aqua bags, 4 shiny gold bags.
clear silver bags contain 3 dotted brown bags, 3 dull olive bags.
vibrant salmon bags contain 3 shiny tan bags, 4 dotted gray bags, 3 wavy violet bags, 5 light gray bags.
vibrant tan bags contain 1 wavy purple bag, 2 bright plum bags, 3 dim turquoise bags.
wavy maroon bags contain 4 striped fuchsia bags.
mirrored red bags contain 3 vibrant coral bags, 2 dotted crimson bags, 3 striped orange bags, 2 clear olive bags.
shiny tan bags contain 5 striped fuchsia bags, 4 drab chartreuse bags, 2 drab tomato bags, 5 muted crimson bags.
dull black bags contain 2 shiny teal bags.
shiny coral bags contain 4 posh blue bags, 1 dotted coral bag.
mirrored blue bags contain 4 posh chartreuse bags.
striped fuchsia bags contain 4 muted lime bags, 2 shiny crimson bags.
shiny lavender bags contain 1 vibrant yellow bag, 1 clear turquoise bag.
dark tomato bags contain 5 clear brown bags.
shiny indigo bags contain 3 pale orange bags.
posh fuchsia bags contain 2 vibrant blue bags, 5 striped black bags, 3 dim turquoise bags, 5 pale black bags.
muted plum bags contain 5 dim turquoise bags, 1 posh fuchsia bag.
posh tomato bags contain 1 faded yellow bag, 1 vibrant blue bag, 1 clear coral bag.
dotted gold bags contain 3 dull tomato bags, 5 striped tomato bags, 5 wavy purple bags.
striped lime bags contain 3 faded salmon bags, 1 plaid gold bag, 4 wavy aqua bags, 3 bright beige bags.
posh violet bags contain 5 dim purple bags.
mirrored chartreuse bags contain 1 dark bronze bag.
posh purple bags contain 4 posh fuchsia bags, 4 posh magenta bags, 2 mirrored cyan bags.
bright indigo bags contain 5 drab white bags, 1 posh tan bag.
dark indigo bags contain 1 clear tan bag, 2 wavy teal bags.
dark beige bags contain 1 bright olive bag, 5 posh purple bags.
clear crimson bags contain 4 muted black bags, 4 posh purple bags, 1 striped black bag, 5 bright black bags.
shiny green bags contain 2 dark orange bags, 2 bright silver bags, 3 dim orange bags.
plaid crimson bags contain 5 muted cyan bags, 3 striped orange bags, 4 dull lavender bags, 5 wavy magenta bags.
clear tomato bags contain 2 posh fuchsia bags, 2 dark orange bags, 3 pale black bags, 2 dull aqua bags.
vibrant gold bags contain 1 faded brown bag.
pale salmon bags contain 4 dull coral bags, 2 posh fuchsia bags, 2 plaid tan bags.
light cyan bags contain 4 plaid magenta bags.
dim teal bags contain 1 posh bronze bag, 4 mirrored green bags, 5 dull black bags, 1 clear gray bag.
plaid lime bags contain 3 wavy orange bags, 5 pale blue bags, 1 plaid gold bag.
light tan bags contain 4 faded crimson bags, 1 plaid fuchsia bag, 1 bright aqua bag, 2 dotted blue bags.
shiny brown bags contain 3 mirrored bronze bags, 3 light coral bags.
bright plum bags contain 3 posh gray bags, 3 faded brown bags, 3 plaid magenta bags.
bright beige bags contain 5 dotted coral bags.
drab tomato bags contain no other bags.
pale beige bags contain 3 drab bronze bags.
dotted aqua bags contain 5 plaid yellow bags.
striped yellow bags contain 2 dull tan bags, 2 posh violet bags, 2 pale violet bags, 2 clear lavender bags.
vibrant maroon bags contain 4 muted green bags, 1 muted cyan bag, 1 mirrored tomato bag.
plaid green bags contain 2 dotted black bags.
dotted indigo bags contain 5 mirrored tan bags, 3 dim yellow bags.
vibrant coral bags contain 3 drab blue bags, 3 striped gray bags, 1 clear plum bag, 2 faded tomato bags.
pale maroon bags contain 5 shiny black bags.
posh black bags contain 2 posh green bags, 1 posh tomato bag, 4 dim gold bags, 5 wavy olive bags.
wavy aqua bags contain 5 faded green bags, 4 pale lavender bags, 5 plaid aqua bags, 3 mirrored brown bags.
clear green bags contain 3 pale lime bags.
dim beige bags contain 4 vibrant beige bags, 3 dull aqua bags, 1 mirrored orange bag, 2 dim yellow bags.
dim chartreuse bags contain 5 dark maroon bags, 1 dark crimson bag, 5 wavy teal bags, 3 clear aqua bags.
bright turquoise bags contain 1 dim turquoise bag, 3 dull turquoise bags.
bright magenta bags contain 2 striped fuchsia bags, 5 dim brown bags.
light fuchsia bags contain 2 drab tomato bags, 5 dim chartreuse bags.
vibrant magenta bags contain 2 pale red bags, 4 dim turquoise bags, 4 drab blue bags, 3 drab aqua bags.
muted gold bags contain 3 pale gray bags, 4 dim salmon bags.
vibrant violet bags contain 4 mirrored gray bags, 2 wavy aqua bags, 3 drab tan bags.
wavy cyan bags contain 3 pale fuchsia bags, 1 mirrored tan bag, 2 dull blue bags, 2 dull cyan bags.
light silver bags contain 2 faded brown bags, 3 mirrored white bags, 5 plaid maroon bags, 3 plaid plum bags.
mirrored lavender bags contain 1 shiny tan bag, 2 dim turquoise bags, 1 shiny coral bag, 1 striped brown bag.
dull teal bags contain 2 striped purple bags, 5 dark plum bags, 5 bright purple bags, 4 light bronze bags.
light indigo bags contain no other bags.
shiny silver bags contain 2 dim maroon bags.
wavy brown bags contain 1 posh lavender bag, 2 dark bronze bags, 4 mirrored chartreuse bags.
dull lavender bags contain 3 dull cyan bags, 1 drab lavender bag.
posh gold bags contain 1 mirrored cyan bag, 5 bright salmon bags, 4 dotted orange bags.
dim yellow bags contain no other bags.
vibrant crimson bags contain 1 drab lavender bag, 4 wavy purple bags, 5 clear red bags, 4 posh gray bags.
plaid gold bags contain 4 striped fuchsia bags, 5 drab tomato bags, 3 light indigo bags, 3 mirrored bronze bags.
vibrant indigo bags contain 4 faded yellow bags, 4 clear salmon bags, 4 plaid lavender bags.
dark crimson bags contain 1 posh fuchsia bag, 2 drab silver bags, 5 shiny coral bags.
vibrant white bags contain 3 dim orange bags, 2 shiny tomato bags, 5 dark teal bags, 5 faded aqua bags.
pale chartreuse bags contain 2 dim cyan bags, 2 faded red bags, 3 light yellow bags, 4 wavy yellow bags.
drab chartreuse bags contain 2 pale black bags.
drab gray bags contain 4 posh indigo bags, 3 muted maroon bags, 5 striped teal bags, 5 striped lime bags.
dim tomato bags contain 4 plaid tan bags, 4 vibrant turquoise bags, 2 mirrored salmon bags, 2 dull magenta bags.
plaid purple bags contain 3 posh blue bags.
dark lavender bags contain 4 muted green bags, 2 dim crimson bags, 5 dull gray bags.
bright maroon bags contain 5 drab tomato bags, 4 vibrant red bags, 5 light lime bags.
striped chartreuse bags contain 5 striped black bags.
dull salmon bags contain 3 drab lime bags, 5 wavy crimson bags.
clear beige bags contain 4 dim orange bags.
light orange bags contain 1 plaid gold bag, 5 shiny coral bags.
faded red bags contain 3 bright tan bags.
wavy violet bags contain 5 plaid chartreuse bags.
dim violet bags contain 1 pale lavender bag.
posh indigo bags contain 4 muted plum bags, 1 plaid cyan bag, 2 mirrored turquoise bags, 2 light teal bags.
muted aqua bags contain 5 striped black bags, 4 wavy purple bags, 4 mirrored silver bags, 4 wavy bronze bags.
faded gold bags contain 5 wavy indigo bags, 2 dark olive bags, 5 mirrored orange bags.
bright teal bags contain 5 dotted coral bags, 4 clear lavender bags, 1 pale black bag, 5 light indigo bags.
dotted green bags contain 3 dotted brown bags, 1 mirrored chartreuse bag, 5 vibrant gray bags, 2 mirrored tan bags.
drab yellow bags contain 1 wavy maroon bag, 4 posh chartreuse bags.
dull maroon bags contain 1 dotted blue bag, 4 pale chartreuse bags, 5 drab teal bags.
clear black bags contain 3 pale magenta bags, 5 vibrant silver bags.
dull orange bags contain 4 vibrant lime bags, 4 shiny gold bags, 4 light coral bags, 4 striped brown bags.
clear violet bags contain 3 muted plum bags, 3 dim teal bags.
muted bronze bags contain 5 mirrored salmon bags, 5 dim tan bags.
plaid lavender bags contain 3 posh violet bags.
muted brown bags contain 5 striped brown bags, 5 mirrored green bags, 2 light orange bags.
clear chartreuse bags contain 2 muted lime bags.
shiny chartreuse bags contain 1 wavy coral bag, 4 light salmon bags, 5 plaid cyan bags.
clear tan bags contain 4 dotted black bags.
dull tan bags contain 1 posh maroon bag, 1 dotted coral bag.
wavy black bags contain 1 dull chartreuse bag, 3 drab plum bags.
faded fuchsia bags contain 4 mirrored violet bags, 2 dim lavender bags.
pale brown bags contain 1 dotted olive bag, 2 bright fuchsia bags.
faded green bags contain 5 dim turquoise bags, 2 mirrored blue bags, 1 mirrored tan bag, 5 mirrored silver bags.
clear brown bags contain 3 vibrant lime bags, 2 muted maroon bags, 3 dull coral bags, 3 faded plum bags.
vibrant silver bags contain 2 clear coral bags, 1 muted yellow bag, 2 drab cyan bags, 4 mirrored orange bags.
bright crimson bags contain 1 posh olive bag, 3 faded beige bags, 1 dim black bag, 1 shiny silver bag.
dim gold bags contain 2 posh beige bags, 1 dull coral bag, 1 plaid aqua bag.
drab white bags contain 1 dim yellow bag, 2 posh gray bags.
dim indigo bags contain 3 shiny brown bags, 1 drab red bag, 2 pale aqua bags, 4 plaid lime bags.
dull blue bags contain 2 pale fuchsia bags, 1 faded tomato bag, 4 plaid aqua bags.
mirrored bronze bags contain 5 bright tan bags, 2 plaid magenta bags.
vibrant turquoise bags contain 5 shiny brown bags, 2 vibrant beige bags, 2 dotted magenta bags, 3 dull lavender bags.
dull turquoise bags contain 4 clear lavender bags, 3 striped gray bags, 3 posh gray bags.
dim lavender bags contain 3 plaid lime bags, 4 mirrored red bags, 3 pale orange bags.
clear lime bags contain 3 drab fuchsia bags, 3 plaid gray bags, 1 light beige bag, 3 muted violet bags.
wavy fuchsia bags contain 3 bright gray bags, 1 faded purple bag, 4 posh purple bags, 4 light tan bags.
plaid beige bags contain 2 drab bronze bags.
faded beige bags contain 1 posh bronze bag, 3 mirrored bronze bags, 3 shiny black bags.
posh blue bags contain 3 shiny gold bags, 2 shiny black bags.
dull silver bags contain 2 wavy crimson bags, 5 faded black bags.
pale fuchsia bags contain 5 dull black bags.
bright green bags contain 3 bright black bags, 4 drab tan bags.
mirrored violet bags contain 4 pale teal bags, 3 dotted crimson bags, 2 posh violet bags, 2 shiny silver bags.
pale violet bags contain 4 posh magenta bags, 5 wavy crimson bags, 3 drab aqua bags.
faded white bags contain 1 drab purple bag, 5 shiny chartreuse bags.
faded tomato bags contain 2 bright teal bags.
faded violet bags contain 2 plaid salmon bags.
drab turquoise bags contain 1 mirrored green bag.
mirrored silver bags contain 5 dull aqua bags, 1 dark orange bag, 3 pale red bags, 4 dim yellow bags.
dotted violet bags contain 5 plaid chartreuse bags, 1 mirrored tan bag, 5 dotted lavender bags.
plaid olive bags contain 1 mirrored cyan bag, 2 muted orange bags, 2 posh maroon bags.
pale silver bags contain 3 dull lavender bags, 4 mirrored olive bags, 4 muted coral bags.
mirrored coral bags contain 1 pale fuchsia bag, 1 dull turquoise bag.
drab crimson bags contain 1 wavy purple bag, 1 wavy violet bag, 2 vibrant gold bags, 3 bright salmon bags.
dull chartreuse bags contain 4 faded salmon bags, 3 light lime bags, 1 mirrored brown bag.
bright purple bags contain 2 light cyan bags.
dull brown bags contain 3 bright white bags.
muted magenta bags contain 3 shiny gold bags, 4 muted plum bags, 5 pale lime bags, 2 light cyan bags.
pale aqua bags contain 4 drab blue bags, 1 bright lavender bag.
drab purple bags contain 2 mirrored bronze bags, 1 drab violet bag.
dotted chartreuse bags contain 2 pale chartreuse bags, 5 clear beige bags.
shiny purple bags contain 5 clear black bags.
muted blue bags contain 4 dotted indigo bags.
striped blue bags contain 4 vibrant beige bags, 3 plaid lime bags.
dull gold bags contain 4 drab violet bags, 3 pale aqua bags, 3 mirrored cyan bags.
plaid tan bags contain 5 shiny gold bags.
mirrored brown bags contain 3 pale lime bags, 2 dull coral bags.
mirrored white bags contain 5 muted black bags, 1 dark yellow bag, 4 drab blue bags, 4 clear bronze bags.
pale yellow bags contain 4 clear tomato bags, 1 drab salmon bag, 1 plaid crimson bag.
faded silver bags contain 5 dotted indigo bags, 3 posh chartreuse bags.
mirrored orange bags contain 4 drab tomato bags.
dotted lime bags contain 3 faded tomato bags, 4 vibrant beige bags, 5 posh chartreuse bags.
muted coral bags contain 1 muted plum bag.
bright tomato bags contain 1 posh red bag, 4 light red bags, 1 dotted fuchsia bag, 4 dull turquoise bags.
plaid orange bags contain 4 shiny salmon bags, 4 muted tomato bags, 4 dull gold bags, 3 clear green bags.
plaid teal bags contain 1 shiny black bag, 4 wavy purple bags, 3 dark plum bags, 4 pale silver bags.
muted tan bags contain 5 faded salmon bags, 4 dotted magenta bags, 3 clear gold bags, 3 dotted tan bags.
faded olive bags contain 1 clear lavender bag.
muted olive bags contain 4 drab coral bags, 5 light yellow bags.
posh salmon bags contain 3 dim turquoise bags, 1 vibrant purple bag, 2 bright maroon bags, 2 drab lime bags.
dim crimson bags contain 5 dull white bags, 1 dim yellow bag, 5 dark green bags.
light brown bags contain 1 drab tan bag.
light bronze bags contain 2 vibrant silver bags, 1 muted plum bag, 3 drab blue bags, 5 dull yellow bags.
faded lime bags contain 3 bright teal bags, 2 light aqua bags.
clear gold bags contain 1 dim cyan bag, 3 striped brown bags.
clear coral bags contain 4 mirrored bronze bags, 5 posh magenta bags, 5 striped purple bags.
striped cyan bags contain 1 wavy violet bag, 4 drab yellow bags.
bright coral bags contain 4 dotted lime bags, 3 striped chartreuse bags.
faded bronze bags contain 1 vibrant beige bag, 4 dotted green bags, 4 dotted gold bags, 1 shiny turquoise bag.
dark red bags contain 3 pale salmon bags, 5 bright green bags.
posh cyan bags contain 3 plaid fuchsia bags.
clear teal bags contain 5 plaid aqua bags, 1 posh tomato bag, 2 shiny olive bags, 4 shiny turquoise bags.
dotted turquoise bags contain 5 dim blue bags, 5 bright teal bags, 2 dull coral bags.
wavy silver bags contain 5 posh aqua bags.
shiny cyan bags contain 5 clear crimson bags, 4 vibrant purple bags, 3 mirrored turquoise bags, 5 plaid aqua bags.
mirrored beige bags contain 2 dim green bags, 1 dull teal bag.
plaid turquoise bags contain 1 dark yellow bag.
dim white bags contain 5 posh indigo bags, 4 bright cyan bags, 5 dim orange bags, 2 dim teal bags.
faded tan bags contain 4 dim salmon bags, 2 plaid blue bags.
faded yellow bags contain 1 posh gray bag, 4 dim beige bags.
dull tomato bags contain 2 pale indigo bags, 2 striped bronze bags, 1 wavy maroon bag, 5 posh tomato bags.
posh lavender bags contain 4 faded blue bags, 4 striped teal bags, 5 plaid chartreuse bags.
mirrored magenta bags contain 2 dim magenta bags.
drab violet bags contain 3 shiny black bags, 1 mirrored silver bag.
pale coral bags contain 5 dim gold bags.
clear red bags contain 4 muted maroon bags.
dark yellow bags contain 5 striped black bags, 2 clear plum bags.
dull coral bags contain 5 bright teal bags, 2 shiny black bags, 3 drab tomato bags, 4 dotted coral bags.
dotted bronze bags contain 3 bright black bags, 3 dull orange bags, 3 mirrored indigo bags.
dull green bags contain 4 clear teal bags, 5 muted silver bags, 2 pale blue bags, 2 light plum bags.
wavy gold bags contain 5 pale red bags, 3 dim salmon bags, 2 striped orange bags, 4 bright beige bags.
plaid aqua bags contain 4 pale black bags, 2 clear tomato bags, 1 faded beige bag.
wavy tomato bags contain 5 posh turquoise bags.
wavy white bags contain 2 dim maroon bags.
dull beige bags contain 3 wavy brown bags.
light olive bags contain 5 dim white bags, 4 dark fuchsia bags, 4 dull magenta bags, 5 light lavender bags.
mirrored lime bags contain 5 vibrant coral bags.
light black bags contain 2 dark salmon bags.
bright gold bags contain 3 dark orange bags, 5 shiny black bags, 2 bright silver bags, 3 pale black bags.
dull lime bags contain 2 posh bronze bags, 2 mirrored blue bags.
posh chartreuse bags contain 3 light lime bags, 3 bright lavender bags, 3 posh fuchsia bags.
clear orange bags contain 1 dull maroon bag, 1 faded yellow bag.
striped red bags contain 2 dotted cyan bags, 3 dull silver bags, 2 light blue bags.
pale turquoise bags contain 4 wavy silver bags, 3 dotted teal bags, 4 light green bags.
wavy crimson bags contain 1 light cyan bag, 2 posh beige bags.
light turquoise bags contain 1 dull orange bag.
dotted coral bags contain 1 drab tomato bag, 5 dim yellow bags, 5 bright lavender bags.
dotted tan bags contain 4 light coral bags, 4 dim cyan bags, 3 vibrant beige bags.
drab blue bags contain 1 dim turquoise bag.
pale white bags contain 3 clear olive bags, 2 clear coral bags, 5 dark olive bags, 2 wavy white bags.
muted orange bags contain 2 dim gold bags.
faded black bags contain 2 wavy aqua bags, 5 vibrant bronze bags, 5 mirrored blue bags.
posh lime bags contain 2 dim salmon bags, 2 pale orange bags, 4 wavy maroon bags, 1 dim coral bag.
wavy indigo bags contain 2 muted lime bags.
faded orange bags contain 1 light green bag, 5 plaid turquoise bags, 4 posh turquoise bags.
light blue bags contain 1 plaid fuchsia bag, 4 mirrored salmon bags, 1 muted chartreuse bag.
light violet bags contain 3 dotted black bags, 3 posh black bags.
posh bronze bags contain 3 striped purple bags, 5 posh purple bags, 2 plaid magenta bags, 3 dull aqua bags.
shiny fuchsia bags contain 5 dim olive bags, 2 plaid silver bags, 1 dark cyan bag, 1 pale red bag.
vibrant gray bags contain 2 drab blue bags.
faded salmon bags contain 1 drab aqua bag, 1 mirrored blue bag.
dark white bags contain 4 dim orange bags, 4 plaid magenta bags, 2 clear tomato bags.
muted indigo bags contain 4 dotted violet bags.
dull white bags contain 2 shiny cyan bags, 3 shiny orange bags.
faded plum bags contain 3 dim cyan bags, 2 dark yellow bags.
muted silver bags contain 2 drab red bags, 3 dark gray bags, 4 striped teal bags.
wavy lavender bags contain 1 drab turquoise bag.
striped beige bags contain 2 dim turquoise bags, 1 muted plum bag, 4 posh violet bags.
dark gray bags contain 3 posh fuchsia bags, 2 striped brown bags.
plaid yellow bags contain 3 vibrant red bags, 5 dark gold bags.
dark violet bags contain 2 mirrored orange bags, 2 muted crimson bags, 1 pale white bag, 1 pale chartreuse bag.
shiny maroon bags contain 4 dim tan bags.
dotted fuchsia bags contain 4 bright lime bags, 3 dotted lime bags, 2 bright maroon bags, 5 drab yellow bags.
light yellow bags contain 1 dotted coral bag, 1 bright lavender bag, 3 pale violet bags.
shiny blue bags contain 1 shiny crimson bag.
dotted black bags contain 4 muted aqua bags, 2 light lime bags, 3 posh turquoise bags, 1 light silver bag.
pale purple bags contain 2 striped violet bags, 5 clear lavender bags.
pale red bags contain 4 bright tan bags, 4 pale black bags, 4 mirrored cyan bags, 3 dotted coral bags.
dim gray bags contain 3 dull cyan bags, 3 dotted purple bags, 2 shiny brown bags, 2 plaid tan bags.
posh tan bags contain 2 light coral bags, 2 bright black bags, 2 dim yellow bags.
vibrant black bags contain 4 pale crimson bags, 2 mirrored brown bags, 4 plaid violet bags, 3 muted yellow bags.
dark salmon bags contain 2 mirrored brown bags, 5 clear salmon bags, 5 drab yellow bags.
dim green bags contain 5 pale indigo bags, 5 pale coral bags, 5 plaid lavender bags.
plaid fuchsia bags contain 2 muted maroon bags, 3 muted crimson bags, 3 dim black bags.
faded maroon bags contain 3 mirrored purple bags, 5 faded tan bags.
dark maroon bags contain 5 dull lavender bags, 4 clear plum bags, 3 shiny silver bags.
pale magenta bags contain 1 light indigo bag.
dim salmon bags contain 2 vibrant red bags, 1 light lime bag.
dotted lavender bags contain 4 drab tan bags, 1 mirrored olive bag, 5 plaid gold bags.
faded aqua bags contain 5 dim purple bags.
plaid brown bags contain 2 shiny green bags, 3 faded tomato bags, 4 wavy orange bags.
striped purple bags contain 4 posh gray bags, 1 light lime bag.
muted yellow bags contain 2 pale indigo bags, 3 vibrant blue bags, 2 muted coral bags.
dark gold bags contain 4 striped teal bags, 4 bright maroon bags.
mirrored indigo bags contain 5 dim white bags, 4 wavy white bags, 4 bright purple bags.
mirrored tomato bags contain 1 drab turquoise bag, 1 drab cyan bag, 1 dotted teal bag.
striped white bags contain 1 shiny silver bag, 1 faded gold bag.
pale plum bags contain 2 shiny brown bags, 1 posh fuchsia bag.
bright gray bags contain 4 posh chartreuse bags, 4 dull turquoise bags.
shiny olive bags contain 3 plaid yellow bags, 4 dotted fuchsia bags, 2 bright beige bags.
faded crimson bags contain 4 faded blue bags, 5 faded gray bags, 1 dotted lime bag, 1 wavy magenta bag.
striped coral bags contain 1 dull fuchsia bag, 4 striped fuchsia bags, 1 dull gold bag, 5 posh lime bags.
posh orange bags contain 4 dim yellow bags, 2 posh tan bags.
striped tan bags contain 5 vibrant coral bags, 5 posh violet bags, 4 plaid aqua bags, 4 dark crimson bags.
shiny yellow bags contain 3 dull silver bags, 3 dim purple bags, 3 vibrant violet bags.
shiny black bags contain 3 mirrored cyan bags, 1 clear gray bag, 2 light cyan bags.
posh silver bags contain 1 posh blue bag.
mirrored cyan bags contain 5 pale lime bags, 1 drab aqua bag, 4 muted lime bags.
dark plum bags contain 3 muted green bags.
clear white bags contain 5 wavy crimson bags, 3 plaid salmon bags, 4 plaid silver bags, 3 faded beige bags.
plaid plum bags contain 2 dim salmon bags, 1 faded black bag, 2 plaid purple bags, 5 dull lavender bags.
dim turquoise bags contain 2 pale indigo bags, 4 striped black bags.
vibrant green bags contain 5 clear purple bags, 4 pale brown bags, 2 drab olive bags, 3 dotted brown bags.
dark lime bags contain 4 dull blue bags, 4 wavy chartreuse bags, 1 bright olive bag.
shiny white bags contain 2 muted magenta bags, 4 clear gray bags, 1 mirrored bronze bag, 3 mirrored green bags.
dark orange bags contain 5 clear gray bags, 1 posh maroon bag, 1 vibrant blue bag.
light crimson bags contain 2 drab tomato bags, 5 bright tan bags, 5 striped gray bags.
clear yellow bags contain 2 muted salmon bags, 1 mirrored magenta bag.
plaid salmon bags contain 3 drab tan bags, 4 dark yellow bags, 5 dim yellow bags.
faded chartreuse bags contain 1 dull black bag, 5 pale lime bags, 2 wavy olive bags, 4 shiny green bags.
plaid bronze bags contain 2 vibrant maroon bags.
striped crimson bags contain 1 shiny beige bag.
clear magenta bags contain 3 muted olive bags, 4 bright olive bags, 5 pale purple bags, 3 dark aqua bags.
muted lime bags contain no other bags.
dull yellow bags contain 3 dark black bags, 1 wavy orange bag, 5 posh fuchsia bags.
shiny teal bags contain 5 posh bronze bags, 1 striped tomato bag, 2 dim gold bags, 2 posh chartreuse bags.
plaid violet bags contain 5 mirrored bronze bags, 5 shiny crimson bags, 5 vibrant blue bags.
posh coral bags contain 5 bright silver bags, 2 bright lime bags.
dim magenta bags contain 5 drab white bags, 1 faded blue bag, 1 drab red bag, 5 light brown bags.
muted turquoise bags contain 4 shiny beige bags.
posh maroon bags contain 2 light lime bags.
posh crimson bags contain 5 wavy lavender bags, 3 pale orange bags, 3 plaid magenta bags.
striped black bags contain no other bags.
drab teal bags contain 5 light olive bags, 3 clear teal bags, 2 posh magenta bags.
plaid white bags contain 1 shiny tan bag, 3 dotted lavender bags, 5 wavy olive bags, 4 clear black bags.
pale olive bags contain 4 vibrant beige bags.
shiny tomato bags contain 5 pale lavender bags, 3 muted fuchsia bags, 5 drab white bags.
dim coral bags contain 3 dotted fuchsia bags.
faded blue bags contain 4 dim maroon bags, 3 vibrant blue bags, 4 clear gray bags.
plaid maroon bags contain 3 dotted indigo bags, 1 mirrored olive bag.
mirrored teal bags contain 3 dim olive bags, 5 posh white bags, 4 faded plum bags.
mirrored olive bags contain 5 light indigo bags, 5 muted lime bags, 4 wavy indigo bags.
drab aqua bags contain 4 drab tan bags, 2 striped gray bags, 1 pale lime bag.
posh plum bags contain 5 dim magenta bags, 5 clear gray bags.
dull olive bags contain 1 clear black bag, 3 dim brown bags.
bright chartreuse bags contain 5 vibrant violet bags, 4 posh green bags, 5 pale coral bags.
dull bronze bags contain 3 dark green bags.
plaid silver bags contain 4 striped lavender bags, 3 mirrored orange bags, 5 muted coral bags.
mirrored fuchsia bags contain 1 vibrant crimson bag.
drab beige bags contain 4 light indigo bags, 1 shiny green bag.
plaid chartreuse bags contain 2 dark bronze bags, 5 drab chartreuse bags.
drab magenta bags contain 3 plaid chartreuse bags.
pale black bags contain no other bags.
dark fuchsia bags contain 1 dim yellow bag, 5 dim salmon bags.
clear gray bags contain 3 bright tan bags.
dark purple bags contain 4 plaid purple bags, 1 dark gold bag.
bright tan bags contain no other bags.
clear plum bags contain 1 posh blue bag, 4 bright teal bags.
striped brown bags contain 5 clear tomato bags, 1 dotted indigo bag, 2 clear coral bags.
drab silver bags contain 3 clear lavender bags, 3 shiny gold bags, 5 dotted coral bags, 5 wavy indigo bags.
dotted purple bags contain 2 mirrored bronze bags, 4 light red bags, 4 dim teal bags, 3 muted indigo bags.
dotted red bags contain 2 shiny brown bags, 2 dull tan bags, 3 wavy coral bags, 2 pale lime bags.
posh magenta bags contain 3 clear gray bags.
dim olive bags contain 4 muted cyan bags, 2 mirrored brown bags, 3 dim orange bags.
dotted tomato bags contain 2 bright fuchsia bags, 5 dull silver bags, 2 dim lime bags.
striped magenta bags contain 3 mirrored red bags, 1 muted magenta bag, 3 wavy white bags.
posh red bags contain 3 bright orange bags, 4 clear olive bags, 5 faded violet bags, 3 plaid coral bags.
muted crimson bags contain 5 light indigo bags.
drab fuchsia bags contain 3 shiny coral bags.
light lime bags contain 4 bright lavender bags, 2 light crimson bags, 5 vibrant blue bags.
dotted yellow bags contain 4 pale fuchsia bags.
bright lavender bags contain no other bags.
dull aqua bags contain 4 posh gray bags, 2 light indigo bags, 5 light crimson bags.
shiny aqua bags contain 2 pale orange bags, 3 drab gray bags.
drab red bags contain 5 striped tomato bags.
bright salmon bags contain 3 light indigo bags.
faded turquoise bags contain 5 clear beige bags.
shiny gold bags contain 1 mirrored bronze bag, 4 dull aqua bags, 2 dotted indigo bags, 1 light indigo bag.
clear fuchsia bags contain 5 dotted indigo bags.
dark bronze bags contain 4 shiny black bags.
dotted olive bags contain 4 bright cyan bags.
vibrant purple bags contain 3 striped gray bags.
dull purple bags contain 5 wavy orange bags, 5 faded black bags, 2 plaid violet bags, 2 vibrant lavender bags.
shiny lime bags contain 1 light purple bag.
pale cyan bags contain 3 vibrant red bags, 5 dark white bags, 4 mirrored red bags, 3 vibrant brown bags.
dark cyan bags contain 5 clear olive bags, 4 plaid purple bags, 5 striped teal bags, 3 bright magenta bags.
dim lime bags contain 3 muted tomato bags.
drab olive bags contain 1 dotted blue bag, 2 dull lavender bags.
faded gray bags contain 5 mirrored tan bags, 1 muted orange bag, 3 posh purple bags.
muted gray bags contain 5 pale white bags.
mirrored yellow bags contain 5 bright black bags, 1 plaid turquoise bag.
wavy lime bags contain 5 plaid bronze bags, 4 mirrored green bags, 5 pale lavender bags, 3 wavy tan bags.
wavy orange bags contain 3 dotted lime bags, 1 dull crimson bag, 2 mirrored turquoise bags.
dotted cyan bags contain 4 dotted lime bags, 2 striped teal bags.
light green bags contain 3 muted indigo bags, 3 pale fuchsia bags.
drab cyan bags contain 3 posh bronze bags, 5 drab white bags, 3 drab tomato bags, 1 light indigo bag.
faded brown bags contain 3 bright tan bags, 4 striped gray bags, 5 drab cyan bags, 3 mirrored tan bags.
light purple bags contain 3 pale aqua bags, 1 dim olive bag, 2 dim tan bags.
vibrant lavender bags contain 2 faded lavender bags.
vibrant brown bags contain 4 striped black bags, 1 faded yellow bag.
dull crimson bags contain 2 mirrored white bags, 2 clear tomato bags.
drab green bags contain 2 drab beige bags, 1 vibrant crimson bag, 2 vibrant purple bags, 1 faded black bag.
shiny bronze bags contain 3 dark fuchsia bags, 3 dark bronze bags, 2 striped brown bags, 4 shiny brown bags.
plaid blue bags contain 5 faded green bags.
light white bags contain 3 wavy brown bags, 3 dark violet bags, 2 muted coral bags, 5 plaid chartreuse bags.
bright violet bags contain 1 faded violet bag, 2 muted maroon bags, 3 posh gray bags, 2 dark salmon bags.
striped turquoise bags contain 5 bright salmon bags, 1 bright lavender bag, 1 wavy maroon bag, 4 light turquoise bags.
clear cyan bags contain 5 posh magenta bags, 4 striped plum bags, 5 light turquoise bags.
bright silver bags contain 4 dotted indigo bags, 1 drab tomato bag, 1 muted salmon bag.
mirrored plum bags contain 5 bright white bags, 1 vibrant brown bag.
mirrored aqua bags contain 5 drab bronze bags, 3 mirrored salmon bags, 3 posh lavender bags, 3 bright crimson bags.
muted lavender bags contain 4 posh bronze bags, 3 striped lime bags, 5 striped chartreuse bags, 5 plaid plum bags.
dim orange bags contain 3 muted magenta bags, 2 pale magenta bags.
faded teal bags contain 5 wavy coral bags, 3 posh blue bags.
dotted magenta bags contain 5 faded purple bags, 5 posh fuchsia bags, 1 drab white bag.
drab brown bags contain 4 light red bags, 4 muted chartreuse bags.
striped indigo bags contain 3 light maroon bags, 2 pale gray bags, 2 faded magenta bags, 1 vibrant teal bag.
dull gray bags contain 3 clear olive bags.
clear blue bags contain 2 clear tomato bags, 4 faded purple bags, 1 wavy lavender bag.
posh green bags contain 5 clear aqua bags, 4 bright orange bags, 2 bright cyan bags, 4 dim fuchsia bags.
muted fuchsia bags contain 5 dull lavender bags, 2 drab violet bags, 4 dotted magenta bags, 2 wavy yellow bags.
posh turquoise bags contain 2 dotted lavender bags.
bright blue bags contain 1 pale lavender bag, 5 dark yellow bags, 5 bright beige bags.
bright bronze bags contain 2 bright gold bags, 4 shiny turquoise bags.
muted chartreuse bags contain 1 vibrant tomato bag, 1 bright lavender bag, 1 vibrant blue bag, 1 dim black bag.
dim bronze bags contain 2 light lavender bags, 2 striped plum bags, 3 dotted gold bags.
pale crimson bags contain 5 dotted lavender bags, 2 clear crimson bags, 4 bright lime bags.
clear bronze bags contain 2 drab tomato bags, 3 vibrant red bags.
pale lime bags contain 4 pale indigo bags, 3 striped black bags.
light red bags contain 4 bright salmon bags, 1 bright gold bag.
pale orange bags contain 5 drab blue bags.
shiny crimson bags contain 3 light crimson bags.
dotted beige bags contain 5 bright turquoise bags, 3 dotted turquoise bags, 4 muted green bags, 4 light black bags.
light gray bags contain 4 faded green bags, 5 wavy gold bags, 4 dim olive bags.
light coral bags contain 2 muted plum bags.
light magenta bags contain 1 dim maroon bag, 5 clear chartreuse bags, 1 vibrant lavender bag, 2 plaid beige bags.
striped violet bags contain 1 vibrant beige bag.
bright aqua bags contain 1 dark crimson bag, 4 dark bronze bags.
dotted maroon bags contain 5 light silver bags, 5 dark maroon bags.
drab plum bags contain 1 dotted yellow bag, 1 bright green bag, 4 vibrant brown bags.
posh gray bags contain 2 light crimson bags.
dotted blue bags contain 2 posh tan bags.
vibrant olive bags contain 3 faded yellow bags.
posh white bags contain 1 faded tomato bag, 2 dim violet bags.
drab lavender bags contain 3 light brown bags.
dark blue bags contain 5 vibrant lavender bags, 4 posh plum bags, 5 pale violet bags, 1 pale beige bag.
muted beige bags contain 1 striped lime bag, 2 clear purple bags, 1 vibrant brown bag, 2 mirrored bronze bags.
dim maroon bags contain 5 dim beige bags, 1 dull coral bag.
wavy teal bags contain 1 drab yellow bag, 2 muted magenta bags, 4 wavy gold bags, 2 vibrant cyan bags.
shiny salmon bags contain 2 light red bags, 3 bright fuchsia bags.
light salmon bags contain 3 vibrant purple bags, 3 drab blue bags, 3 faded black bags, 2 bright white bags.
shiny magenta bags contain 5 light fuchsia bags, 3 drab indigo bags, 3 mirrored yellow bags, 4 dim purple bags.
plaid black bags contain 3 light bronze bags, 4 mirrored tan bags, 4 muted lime bags, 5 mirrored white bags.
wavy red bags contain 4 clear lavender bags, 4 dull chartreuse bags.
posh beige bags contain 4 wavy maroon bags, 4 clear plum bags.
wavy bronze bags contain 1 wavy purple bag.
dotted gray bags contain 3 striped black bags, 1 wavy maroon bag, 5 pale indigo bags.
bright white bags contain 3 pale indigo bags, 2 drab white bags.
mirrored black bags contain 2 striped plum bags, 5 wavy brown bags, 1 wavy crimson bag.
light gold bags contain 3 posh plum bags, 1 vibrant crimson bag.
bright fuchsia bags contain 3 light cyan bags, 1 drab turquoise bag, 3 dim orange bags, 1 dull chartreuse bag.
striped gold bags contain 3 muted violet bags, 2 clear teal bags, 2 posh brown bags, 3 dim tan bags.
striped orange bags contain 1 pale fuchsia bag.
drab gold bags contain 4 shiny teal bags, 5 muted aqua bags, 3 wavy lavender bags.
light chartreuse bags contain 2 bright gold bags, 5 striped turquoise bags, 5 light gray bags, 3 wavy aqua bags.
vibrant chartreuse bags contain 2 dotted yellow bags, 5 bright fuchsia bags, 1 striped chartreuse bag, 1 dim salmon bag.
pale indigo bags contain no other bags.
drab lime bags contain 2 mirrored turquoise bags.
vibrant plum bags contain 3 dotted turquoise bags.
pale teal bags contain 5 striped lime bags, 3 faded salmon bags, 4 bright indigo bags.
dark tan bags contain 2 drab lavender bags.
faded lavender bags contain 1 vibrant blue bag.
drab orange bags contain 1 muted turquoise bag, 3 pale indigo bags.
dim fuchsia bags contain 1 drab silver bag.
vibrant lime bags contain 1 posh purple bag, 3 light coral bags, 3 light lime bags, 4 light indigo bags.
clear salmon bags contain 2 light indigo bags, 2 striped plum bags.
dark black bags contain 2 striped fuchsia bags, 4 wavy white bags, 2 wavy maroon bags.
muted white bags contain 2 pale indigo bags, 5 light plum bags.
pale gray bags contain 4 light yellow bags, 2 striped olive bags, 4 clear black bags.
dull cyan bags contain 2 vibrant red bags, 3 drab tan bags.
striped silver bags contain 3 mirrored green bags, 2 wavy purple bags, 3 posh aqua bags.
wavy magenta bags contain 4 dim purple bags, 2 dark aqua bags.
drab black bags contain 2 light plum bags.
drab maroon bags contain 2 vibrant lime bags, 4 dull purple bags, 2 mirrored salmon bags, 3 vibrant aqua bags.
shiny orange bags contain 5 wavy coral bags, 1 pale violet bag.
plaid coral bags contain 2 mirrored cyan bags.
plaid cyan bags contain 4 pale indigo bags.
dotted crimson bags contain 2 dim teal bags.
mirrored tan bags contain 1 pale red bag, 1 light cyan bag, 1 clear gray bag, 3 striped gray bags.
light maroon bags contain 2 vibrant bronze bags.
bright brown bags contain 2 wavy yellow bags.
muted tomato bags contain 5 clear gold bags, 5 plaid coral bags.
dotted white bags contain 4 dotted purple bags, 1 posh chartreuse bag, 5 dark gold bags, 1 vibrant gold bag.
muted red bags contain 4 clear crimson bags, 4 posh magenta bags, 3 plaid cyan bags, 5 pale crimson bags.
wavy yellow bags contain 3 muted magenta bags.
muted purple bags contain 1 dull chartreuse bag.
striped olive bags contain 5 faded tomato bags.
light aqua bags contain 1 vibrant tomato bag, 4 posh lavender bags.
vibrant blue bags contain 2 muted lime bags.
pale lavender bags contain 4 shiny coral bags, 5 muted crimson bags.
mirrored turquoise bags contain 5 posh blue bags.
pale gold bags contain 3 plaid chartreuse bags, 2 pale red bags, 5 clear aqua bags.
wavy salmon bags contain 4 dotted yellow bags.
shiny beige bags contain 1 bright magenta bag, 1 muted fuchsia bag.
striped bronze bags contain 5 bright turquoise bags, 5 dull black bags.
dark magenta bags contain 5 drab lime bags.
dark coral bags contain 3 plaid bronze bags, 3 posh green bags, 4 muted violet bags, 3 plaid purple bags.
mirrored green bags contain 4 posh purple bags, 2 dotted blue bags, 1 dull turquoise bag, 2 plaid purple bags.
striped tomato bags contain 5 drab white bags.
muted teal bags contain 5 shiny lime bags.
vibrant bronze bags contain 3 shiny gold bags, 5 striped fuchsia bags, 5 mirrored orange bags, 2 bright green bags.
clear olive bags contain 3 posh violet bags, 1 bright beige bag.
clear maroon bags contain 1 vibrant lime bag, 2 muted coral bags.
faded coral bags contain 4 dim beige bags, 4 bright magenta bags, 3 vibrant magenta bags, 1 bright silver bag.
pale bronze bags contain 1 dark teal bag, 4 dotted aqua bags.
striped aqua bags contain 3 faded aqua bags.
vibrant cyan bags contain 2 mirrored blue bags, 4 striped black bags, 4 clear black bags.
wavy coral bags contain 4 drab salmon bags, 3 light orange bags, 3 posh aqua bags.
mirrored salmon bags contain 4 pale lime bags.
plaid magenta bags contain 1 dim yellow bag, 1 light indigo bag.
dim brown bags contain 3 vibrant purple bags, 2 striped gray bags, 4 mirrored salmon bags, 2 muted maroon bags.
dull magenta bags contain 1 mirrored green bag, 4 dull coral bags.
dark silver bags contain 5 dotted gray bags.
pale tomato bags contain 1 vibrant blue bag, 4 shiny green bags.
plaid tomato bags contain 4 mirrored chartreuse bags, 1 plaid white bag, 4 wavy magenta bags.
faded magenta bags contain 4 dull yellow bags, 3 wavy silver bags.
mirrored crimson bags contain 3 muted tan bags, 5 posh beige bags.
muted green bags contain 4 dim black bags.
wavy chartreuse bags contain 1 plaid tan bag, 5 bright tan bags, 2 posh beige bags.
wavy plum bags contain 2 clear purple bags, 5 dotted violet bags.
plaid indigo bags contain 1 dull brown bag, 3 clear chartreuse bags, 5 posh gold bags, 1 pale teal bag.
posh teal bags contain 3 light magenta bags, 3 muted white bags, 3 dim blue bags.
striped salmon bags contain 4 shiny coral bags.
pale green bags contain 4 dark gold bags, 4 striped teal bags.
vibrant yellow bags contain 4 faded salmon bags, 1 drab beige bag, 1 muted black bag, 5 clear lavender bags.
dim cyan bags contain 2 mirrored turquoise bags.
wavy turquoise bags contain 4 dark turquoise bags, 3 bright tan bags, 4 muted tomato bags.
bright cyan bags contain 5 wavy indigo bags.
plaid red bags contain 1 mirrored coral bag, 2 dull plum bags, 4 vibrant coral bags, 4 vibrant lavender bags.
dark chartreuse bags contain 5 mirrored salmon bags, 5 posh salmon bags, 2 faded turquoise bags.
plaid gray bags contain 1 dim gold bag, 4 faded olive bags.
vibrant tomato bags contain 5 wavy maroon bags, 1 pale red bag.
faded purple bags contain 1 faded tomato bag, 1 striped black bag, 5 vibrant purple bags.
dotted salmon bags contain 3 bright gold bags, 5 dull gray bags, 3 dim blue bags.
drab salmon bags contain 3 mirrored green bags, 1 mirrored tan bag.
pale blue bags contain 4 dotted fuchsia bags.
faded cyan bags contain 2 striped orange bags, 1 vibrant gold bag, 2 bright orange bags, 1 muted gray bag.
dull red bags contain 2 drab teal bags, 2 light bronze bags.
wavy beige bags contain 1 plaid tan bag, 5 dotted indigo bags, 2 dotted gold bags.
dim red bags contain 5 pale magenta bags.
dark green bags contain 5 muted cyan bags, 3 faded brown bags.
muted cyan bags contain 3 drab tomato bags, 4 drab white bags.
mirrored maroon bags contain 5 wavy tomato bags, 2 vibrant white bags.
faded indigo bags contain 5 dim olive bags, 5 drab tan bags, 3 light orange bags.
light lavender bags contain 1 faded salmon bag, 5 pale lime bags, 4 dark maroon bags.
dim aqua bags contain 4 faded gold bags, 1 striped fuchsia bag.
shiny violet bags contain 1 pale yellow bag, 4 mirrored aqua bags.
wavy blue bags contain 1 dim fuchsia bag, 3 clear gold bags, 1 faded aqua bag, 1 light red bag.
striped teal bags contain 3 mirrored silver bags.
striped green bags contain 1 muted teal bag.
vibrant teal bags contain 3 muted indigo bags.
shiny turquoise bags contain 3 dull chartreuse bags.
bright lime bags contain 5 bright magenta bags, 1 dull orange bag.
shiny red bags contain 4 drab tan bags, 4 posh turquoise bags.
dull violet bags contain 4 shiny silver bags, 3 striped crimson bags, 1 mirrored plum bag.
dim black bags contain 1 posh magenta bag, 3 mirrored turquoise bags, 2 faded tomato bags, 4 dim turquoise bags.
muted maroon bags contain 2 mirrored tan bags, 3 clear coral bags.
posh yellow bags contain 1 bright tan bag, 5 mirrored bronze bags.
clear purple bags contain 5 shiny black bags.
dim silver bags contain 4 clear brown bags.
bright black bags contain 4 posh fuchsia bags.
shiny plum bags contain 1 mirrored cyan bag.
striped lavender bags contain 3 pale lavender bags, 4 muted cyan bags.
drab tan bags contain no other bags.
bright olive bags contain 3 muted coral bags.
dim plum bags contain 3 drab tan bags, 5 pale indigo bags.
light teal bags contain 2 dotted blue bags, 5 muted salmon bags, 2 bright purple bags.
clear lavender bags contain 2 muted lime bags, 5 plaid magenta bags, 3 pale lime bags, 1 drab aqua bag.
muted black bags contain 3 light crimson bags, 4 mirrored blue bags.
clear aqua bags contain 5 plaid gold bags.
dark teal bags contain 1 bright purple bag, 1 dotted coral bag, 5 plaid aqua bags, 5 posh maroon bags.
mirrored gray bags contain 3 dim turquoise bags, 4 bright black bags, 1 drab lavender bag.
vibrant fuchsia bags contain 1 vibrant magenta bag.
bright yellow bags contain 1 mirrored cyan bag, 1 clear olive bag.
vibrant red bags contain 1 dotted indigo bag, 2 faded beige bags, 1 drab tomato bag.
striped maroon bags contain 3 plaid aqua bags, 2 dim maroon bags, 4 plaid chartreuse bags.
pale tan bags contain 5 posh gray bags, 3 wavy violet bags."""
main_raw_input = main_raw_input.splitlines()
Creating the data structure
I feel that I can never stress this enough: A key part of coming up with solutions to Advent of Code challenges is to come up with good structures for the input data.
Here’s my function that takes the initial, somewhat-massaged input data, currently living in main_raw_input, and turns it into a data structure that I could do some problem-solving with:
import re
def create_data_structure(initial_data):
result = {}
for item in initial_data:
bag_and_contents_regex = r"^(\w+ \w+) bags contain (.*)"
bag_and_contents = re.search(bag_and_contents_regex, item)
bag_type = bag_and_contents[1]
contents_string = bag_and_contents[2][:-1] # [:-1] removes trailing period
contents_regex = r"([0-9] )*(\w+ \w+) bag"
contents_tuples = re.findall(contents_regex, contents_string)
bag_contents = []
for contents_tuple in contents_tuples:
if contents_tuple[1] != "no other":
bag_contents.append({
"count": int(contents_tuple[0]),
"type": contents_tuple[1]
})
result[bag_type] = bag_contents
return result
The create_data_structure() function creates a table that makes it easy to look up a given bag and see what bags it contains.
It takes each line in the input, which follows this general form:
[adjective and color] bags contain [one or more of
([number][adjective andcolor]bag(s)).
It first makes use of this regular expression…
^(\w+ \w+) bags contain (.*)
…to separate the line into two parts:
The containing bag, which is captured by the (\w+ \w+) group, and
The contained bag(s), which are captured by the (.*) group.
The contained bag(s) are further parsed using this regular expression…
([0-9] )*(\w+ \w+) bag
…to create a list of tuples of the form:
(number, adjective_and_color)
Here’s how I used create_data_structure() to create the data structure:
bags = create_data_structure(main_raw_input)
Here’s a sample of the what the structure looked like for my data:
With the data structure built, it was now possible to write a function to determine how many shiny gold bags a given bag would contain:
def shiny_gold_bag_count(bag_collection, bag_name):
count = 0
bag = bag_collection[bag_name]
if len(bag) == 0:
return count
else:
for sub_bag in bag:
if sub_bag["type"] == "shiny gold":
count += 1
count += shiny_gold_bag_count(bag_collection, sub_bag["type"])
return count
It’s the return of our friend:
This function checks the contents of the given bag. If there are bags in the given bag, it checks the contents of those bags and counts the shiny gold ones. If there are bags in those bags, it checks the contents of those bags and counts the shiny gold ones. And so on…
Now that I had the shiny_gold_bag_count() function, I could write another function — bags_containing_at_least_one_shiny_gold_bag() — that would apply the shiny_gold_bag_count() function to all the bags in the collection, giving me the answer to the part one:
def bags_containing_at_least_one_shiny_gold_bag(bag_collection):
count = 0
for bag_name in bag_collection.keys():
if shiny_gold_bag_count(bag_collection, bag_name) > 0:
print(f"{bag_name} bags contain at least one shiny gold bag!")
count += 1
return count
In my case, the count was 326.
The Day 7 challenge, part two
The challenge
Here’s the text of 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?
My solution was the following function:
def bag_count(bag_collection, bag_name):
count = 0
top_level_bag = bag_collection[bag_name]
print(f"Currently counting bags inside {bag_name}.")
if len(top_level_bag) == 0:
return count
else:
for current_bag in top_level_bag:
print(f"There are {current_bag['count']} of {current_bag['type']} inside {bag_name}.")
# Add the number of bags of the current type
# to the count.
current_bag_type_count = current_bag['count']
count += current_bag_type_count
# Count the bags inside each bag of the current type,
# multiply it by the number of the current type,
# then add it to the count.
bags_inside_current_bag_type_count = bag_count(bag_collection, current_bag["type"])
count += bags_inside_current_bag_type_count * current_bag_type_count
return count
Once again, my solution was a recursive one. This function checks the contents of the given bag. If there are bags in the given bag, it counts them and then checks their contents. If there are bags in those bags, it counts them and checks their contents. And so on…
Getting the solution was a matter of calling the function:
bag_count(bags, "shiny gold")
And for my data, the answer was 5635.
Solutions for previous days in Advent of Code 2020
Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 6 challenge.
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?
Importing the data
Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into a Jupyter Notebook running a Python kernel.
This involves pasting it into a triple-quoted string and assigning it to the variable raw_input, and then splitting it using two newline characters in a row as a delimiter, producing a list named split_input:
raw_input = """wdcmlzfnugqtvjbsahi
easrkmocxbpjgi
xrpnegqlcsyodhjfutzakmiwvb
mgilapxjtrndbheyqzckfouwsv
scynhfozmlvbqkarwj
qhvjkmbyxcfonlazdw
vjhzfnapwclkqiomyb
bpourq
ujpmoqs
obqup
v
v
v
v
v
hwjlda
thkdjo
mlhdjw
edyfjvh
djh
xvjadplfcwmkeriug
adgtscyjipewvulr
hmkipduz
mdzkupi
vtyizwcdm
zdvtcyiwm
mfzcywvtid
iydclntzvmw
ps
pm
pm
p
pm
nglatdiw
twialgd
igsadtwl
iadgtwl
igawltd
jqoxkavs
askoxvqj
aqjvxskho
javqkxso
kaxjoqsv
ltkjfoxes
aifogkepx
ufcekybmzx
tigxeahnkf
xzfqbsnhmrviju
rmfvsbihpujq
hstfumvgrobijq
bga
ye
sg
gs
sg
gs
sg
knipbjmtrqoawe
rtaebqkmopjiwn
ewbuqcaijonmrpk
trnmpeqkobjiwa
puifme
ufb
fvp
rntzlyxwokfcg
nufjzpyawbqsdgi
ogcmpsdqaxvnzwetklh
qmdxnfrjobatzwgcyse
rdxtqseawzobygcmfjn
dbot
dwetlp
odtr
utbqx
bxuqt
xtbqu
quxbit
rvthuiqbljzaofgwy
ldftrsjvwoiayzuekcg
dtxmalyuifznvprkcwgoj
twc
w
pwg
rmzaoylipcwkvuqesbhn
kpuvhqlwyrabmszecnoi
cwaylknbrhvzmiupseqo
qlwiyczkevsnarhbpumo
cgr
grch
cgsr
rgce
eso
ose
soe
swimuzq
zqwsmliu
iqzurwsmh
iswqzum
wzhumsqi
amolqcs
sqoayj
sjazqxyo
aqhxsot
ozsajqkx
qbkyhzfspewgrtlv
pyeqtcbskf
jxbsonqtaykpef
tqskfmyboeup
bdjtfqypokse
yrtwqacluozbg
vwtfgzmcqobraj
opctryzqawbg
v
v
v
nv
dclgejbqrwtkvsxfa
ovgkhjyiqwbmefc
vpkx
jmydw
fxa
xa
gwtocmzslfqk
olkgwzcftsmq
ogmsfzlwqckt
uwxdl
wdux
oxuwdt
dxwu
ab
smej
t
iwhlqdermv
menrvqd
jemdqvr
n
n
a
n
jqcvetapkbsyu
twndyfrixzhvmsogu
xsz
zxs
zxs
szx
sxz
fsatbzpvqjknlrm
pbnljkratfzvsmq
qtrasmjnlkfvbpz
bsjavlmpqktrnzf
qajlbkzvmtsnfrp
utlchvariswzqjmx
almujswrcthzvfqix
p
j
p
n
cgsxwk
uwkcxj
xpwethnkcyb
gywc
wcgy
ctyugw
gwcy
wgyc
afmtuw
muatfw
ujwmnirvkdygtqcabh
takwqdjgzcuivrhnom
cawvrnxfjmghdtkiuq
srgt
ma
urnymxabthi
rtxnailuqvoyph
duytknrwiehaxz
rhaumscngtyix
gawbhtkqruyjel
rlcqbuhawkmyfgjte
jhbyqgkraetwlou
gxbtrnadlejwhyquks
ujfkleagybrtwhq
dctkngohsxaljfrbvmey
mlbvxaksifyneodgjctrh
lmkfobtyxngsjvrdahec
srkyveohxfmcjdlbtnag
lbguestydkjxfopnvmhcar
pjrhgzdwcmxq
cgwhmqpjdrxz
meipjv
mivpje
jevmip
peimjv
vmpeji
zkcavufyr
fyzuarckv
fvnacqgksry
yvcrfak
crfvyka
pqynikfxd
dynxqlifpk
laozucfdek
kpeauocdlz
uoldfsekzac
dmekaclyhnuzo
hwubponvt
vwytnphobu
vpnbgtwuoh
wpouhvbtn
wcxlspod
fmedwbtjops
pwnoscid
ufenjp
ngfxpe
njbpfc
vqnthfazdp
pmfjng
qrphaykit
qkysrta
jbwdtqrxzav
wjqfz
jqfaz
meuxikpsdw
kjimpsdwxu
dmxpwikujs
fjbsnmcgxz
bpfimjnzduh
urtkjpo
cthod
voclmdguaw
oczdlntgmeir
zipf
fipz
nbwcexytjzripskmo
kwpzrmtxiosejcb
tsrcoebzpiwjmxk
jafcwtsukrodynhvqge
pubrlchazvetosyigqjdk
qminshlycutrdwx
vigzpqbmunacrjftokl
hweisfpycjdzouvmbnkq
nqjxscbvmuwhzfakdo
qtndfjcglrkoyux
jqtrlgfkducxnomy
tqnrjxckgfaupdoly
pbe
b
n
n
n
n
n
nsc
ns
nse
qzkxif
vkfqizx
kfzqix
zixkfq
ifzxkq
nvshwafe
vbewacnh
nvwmeah
ziafwxcnmebko
cdfrxmk
fkmpxc
y
y
y
y
y
yauxbwtcvgoq
ywcvotagxbqiu
gqwyvbacouxtn
uobqrcgwtvayx
qcgwoytbxuav
r
nr
a
r
xjrkwdnbyuscfgqtphiov
brshqnjcoukxitvywfdpg
vrxlptbcyfdwhgkouqijns
fqcvwudyiotjblzpxshgnmkrae
ouhrqwtgnjeyxiamfzpdscbkl
lnch
nhclmg
ldhzcny
uzfeomrwi
ydgkhjbx
qcylp
hagpbecorwyvfdz
rstplobhmfnxvykdewc
hfruowdvyjgbpzce
rgdiznuxa
dragzniue
jzysdgpuvkowqin
lugrndiz
nbdcfugzi
eqponlctfbwgk
kyjniulbegpdchtwoaq
onczetbplkwqg
thevzsrc
zcewrsv
vczueosky
wmzlcsve
sxeqojwkarhyutcdnzp
rjnuwzxpmeysdoctlaq
pzqxeratsdnkuovcwjy
qexjbo
cqunbaprhwyjfe
ilvegkbszdt
efbmqj
wm
wm
hm
wm
m
texosjaiycpqn
mntxspgikeldwycjarq
nysqtaceipjux
phiqznsyxjcvoabet
neqytxcuipsajvf
z
nozy
ydfcsvgbikjphamr
wskfdahgpvmrcjby
kpsirchfmjavbdgy
pslxjrugtzydaokemvbcfqh
t
pyt
fu
fu
d
yj
fnl
qxkevrhpna
kmvyorduqe
sfnmyevqwka
fvmyieawqks
kvfhmctdqjaslywe
ywfkvqeanms
kufwyqmaesvh
ulvtwepimynb
ehmpnylubtvwi
wplevtunmyib
lpbwnvtuyeim
unvpbgtjiaylmcwes
zfxkceynsu
xdfzysnuie
efzgxunsy
nzydesxfu
jneurlkfzxbq
xekznblfurqj
rbzljfkqnxeu
zueknrbxjfylq
xzferlbjqnku
tr
f
egtr
jmu
s
aeq
qae
eqa
aeq
bsgjrilayoezwndvtq
giadlcryjwobhznqesvft
guxfyzespj
zusejpfgxy
zxygjuefps
xvmlgpzjdrubqa
jfmbdvzeyrlup
ruzchykmbpwdvloj
vhmuebldrjzpo
bhvcmrypulzjiwds
cfsjzamyhtoxq
xoysjqfzmhtac
qocxatmfshjzy
vdhsifmynta
nsmfhdtya
tsnfhamdy
dafyqtsnmh
rfybkqmh
qoumrd
l
y
l
y
w
vlmerz
mlvrze
zvrmle
zelrvm
mzlrve
rnb
gdcb
pbtergc
tecfjgr
ogzsajwvdiplrtxbhfcnky
btjzlswhikyofgcpvrnda
tbwinagrhfyscvlejkdop
dakhrbipqglmovjyncswtf
bhyljrdpsktgfiancwov
qolmnyvhtwe
uwkecxshldmoy
zwblsockyumh
miywfgjhaopr
u
u
q
zdxynqmev
bdexmzyiqcn
bwtqagf
tnmwfaqbj
p
p
p
p
p
yjgicnxerbsu
xpzfqirsjh
exswmarikbj
mjxgrsi
tvzkbxugmcnshproiw
czxtirownbmpksuvgh
cnofirbgmhzuspvtxwk
gmctsrohkxwzupvbni
vsgbzcmktxihonwupr
dyaoim
aiom
ozimual
oxaim
biyotma
saliju
evzhxcobk
lj
txhebw
etwhbx
uhwxtbe
eyaixfrdhoqksc
eakiqsrocxyhd
vkr
kvr
kvr
surjoh
ubh
ubmahe
uh
vhkcawrno
vowahrnkc
oknarvwhc
cnkhvwoar
wvhkanrco
ntpfemsvialxgrwqzc
kcwegrtispxnyd
phstgwixebnucr
xpwjtenscoigr
sfanq
xgtzfrn
ulfinpkv
kdwnyjuzctiqpgf
ngtcrjipqfyh
ypfvcqntirgjh
urmtsh
svihtu
utmph
juthydwafcqx
uthve
sk
ks
sk
zxbvcrgyqfjtoeiudwpkhsm
igkswrpohqudcfjxzmvytb
cpatkzfuoyqgvrsmibhxjdw
kvgumiabnoh
bvaiomgnukhc
mkhnvusbagio
hamiobunkgv
umsgovkahbin
yrceuq
rmdbpa
nkvxjslwg
lkt
fl
vil
whn
hn
hn
gvebcszypdlkqm
zcyhdlpqgsvke
cdzbylqkpsuveg
pzsyxlgdaiofcqwvek
gmcpvyqzeskld
ryzfspdtbwxiomhkjnlu
tqihvployrmksbunzfwc
dualjxigyrzb
durysxjlgzaib
srgxulazbjyid
lrgaubjydzxi
azritbxdpljyg
cfahxspjelitdnobuvqywk
vwmkoxulnypfiatgjbhrcsq
f
f
f
f
f
grbmahpise
mbireyxhalgs
bcrkvuwqt
trubckq
rbuqtkc
trkbcuq
rubtqkc
zxpbejmvhrutwlkq
gtvrzphoqcbnmju
pjazbvqurgmysht
fhsptiumrvjqbz
kpszjieflb
blsijkefzp
zksjiefpbgl
ilbzrksajpfe
sglzbepfjik
nxwohsipd
zitjrlvfgsoym
bqsiopuc
aoisd
wj
j
fzpglynjeu
jk
ikj
abzftcqvgsrnexpmho
pxvlybndrtqimzhosacgef
nocqfzerjaubxthgmwspv
psauzryot
vmdhbwe
lfc
gsri
sqya
lkjudnqterhyscgx
eckqhlxybrngudstj
wotecvlyrpgqmijxkhsd
htpc
caph
hpustjc
nyhcedmgp
ezaljkfpiyvroud
hbiwxfstmldkecnvpgqo
kiqvzyjrthmblu
ahszlduemxcij
wirunkh
hwqdknyirul
kxwuhirn
hkirwnu
ierwunkh
vcgno
snmicvo
ncomjisv
coynuv
lconfdvpz
tgqkhowsyfbzpcur
zcqsugtwhrpfy
fgydqpcjswrlzeuth
thgpcfyzqeursw
rwpci
cipwr
ptrlaqebo
pebtlaqor
qboxepatr
epbartoq
fypd
dpyf
ypfd
fdpy
c
c
c
d
c
gxysqiamkpc
mpiacyqxkgs
mvqbskuzefy
zcsqebma
ztbnlhe
snx
xsn
nkxs
snx
joyblxztkswmvnec
gdcrhykmfseqapibzu
oqzmprikt
fhlgxucda
ygrjkfazu
kjiagrzyfu
btg
o
v
oc
bnqyz
ebdfls
vjhocqkamygbplu
dbwsyefuxzntijrc
kmlb
kqsbl
vhjsdxrfpokyznibwgtmu
syvkmzfjgpdwixrnbutoh
uzbjgvhdkpynmtfoxsrlwi
jpkxwvyrgftzioubhsmnd
ykjmzvsqnhxwgbrutoipdf
hwby
yvbmhl
echgiyabjpf
krbouyh
hrynotb
tobipzwfxy
pfxwytizob
hsfwzpbotiyax
znrgilpcfse
seinczlpgrf
nircgepszfl
rcegzsiflpn
lzgrcpensfi
tupvbxcgfnmh
fpqntvibgxhmc
npbtvxghfm
tvxfhmbnipg
rnvxmhfjgpbt
inysghdka
wbc
noktsjqvmzxheplrcfgiuwda
dlogmasfzwhupjrkcntixqev
zhwfbs
bzcwh
igqkpctmafr
jietalnfksqp
ewlanjvgdbpm
lpjangwvem
vpngjwmeal
glvwnpejam
enlgwjmvpa
niocufzwrk
kirmuzfocvw
juqervaxni
cudjqavnix
iuvjndcaxq
xvniqajugd
vxunjiaq
lmayozkep
koazylep
aeykzlop
ejgotzhrxbsnqimu
lrspkgobcaywmjfvhd
uazxfrony
uoaxynzrf
yunaorxfz
lowmgiuxpnakzsq
qwaomukglnx
ubgkoyqanwlvmx
lowaqgyxunkhm
alfoj
floj
yglkurfahidmoxtvz
muykfdrzivlothga
devylsarcupgoihkmftz
rmtgkalydnhvozubfi
ahrzqodkgxyuitvmfl
gmdoshlaixnc
xhmicdgosanl
hiqgvbulakdmoxcpn
hoiamdsngcxtl
egnprq
ash
oabx
abxfo
vomitazdbflqhkue
lvemipubdafohztkq
dkabtiylqgzuovehmf
euanfbq
skufxtami
nefauc
fadpbjxvzeghqkriy
xpaqfzjvybdhrkieg
jeqghzxrdyvakpfbwi
ygvakzbdpqrxjfeiht
dhvmgjoqzknbwyl
hvnlobmydwzqkjg
vbzljhdqgnmwoyk
s
k
sk
d
svzubcigpeqdthfmxnj
djogszbcnvefqthiuxmp
vgkpjwymduqfxcztoasne
swgapuymcvqnjodtkfzxe
stgv
yvbts
iokqv
h
h
h
ujxw
uz
uz
uz
cdh
lhg
mkh
quroafxhipsev
d
d
dg
lbrsefwhxagdmpqjiocuvyn
uobfgnhvsqwzlkjyraicdpm
uwnvthio
yudxpkhrngb
selctamwozqvf
ueiypcnoa
nidaehvt
akencir
ozcru
uoflar
pwoxuyvm
nrgaujbldiwxvq
sdvuirgaynbj
synqkzdlpebticorvwxmaug
ekyatuvbpohmxnfdgczirwql
ztvwupairdeqmckgbnylxo
alngerwtckpvmioxbduzyq
dqygzrkuowejsm
zyikwtjsver
yzjrsvawceik
lqduw
iudw
wdrue
zxnrflac
lx
lvx
otlwkx
wxyl
q
q
q
q
q
aigmyqxscvhde
csegmkqdnvyahix
gvqixcdheysam
dsmyaexgivqhc
shiqmxgdeycva
nbmovulhpai
yfcobuiaetpdvmln
mnopuvlbia
wviopnmluabk
uvamohipklnb
cibznrjtsgoafdlkx
cethszlarinx
xcsztairehnlp
szhnatlxicr
mpselnxatyzric
qxdzauyvbc
qxzvabdcuy
zyxabucqsdv
uzxvatmprofyjcliwgbdsqnek
kynesjvmoifucbpqwxlzrdtga
mepouwaj
cutjoxvpa
apojcvftd
opwdaj
njhzgqrikyapslo
efqisyl
elfqsiy
sfiqley
if
wvzghe
xn
dnxu
afuolgsxdckypbenqjhmr
euqojgbfzphxmnrysda
xsbwrdmnfqyphaegjuo
xsfuhpgnbjmwqoaeryd
xjyizvdsbkfmhenwop
mueiojtyqnag
bjlvkzugwqspcihmxr
mlugrxwjqsvibczhkp
vikuscpzwqhmgjxrbl
pxzbksqmjlcgihurvw
payfmlnhgtzsrxke
yeknlfshmrgztx
p
p
p
p
gnmcwdtquesz
ztdscnkg
zdancosjgt
cdntzsg
zcjgbpstrnd
ugxawjehznr
gujxqzrwhnea
rewagunjzhx
krvmqtuiwsezbjcdhployaxngf
xkwsubhjlfvparcgomyenidzqt
jrglbkzcwtuayno
iwydqmzt
tdwfeyz
jnvchaxzotqd
jdaohpexnt
yifrdlua
asridu
rchuily
brliyc
icyl
nclfjxiytvs
hiycrl
fj
fj
jf
jf
hncwvidj
ncijh
qjhrin
zsxiheynj
jvihaqnc
zkraj
zkjrl
akjzr
zsvjrk
culpozwn
copkslvruwt
fhwlecupo
cuibdzoagynvrkw
dobjkzuxvrcyinag
ipsduzkvybnoacrmeqg
gjwfeblzasoirpvhcqtxu
dcfqurpiaxslgjhbyzwmeno
agi
sa
vuhaksj
zatyex
xponks
ojnkpsx
cqeiyuforpx
bxfnzrs
xhfnvdr
rfx
tqowdj
dw
diwfu
dfewgi
wd
dyvjwabnuzgx
bjdyglxvzonw
dxbwnyvagjz
zyiwdcgrbjexvn
xjngvztwbdy
ob
ob
bo
ob
cp
cp
cg
cnwlshdkyboxmpvtz
ndswvmyzjeuprbgchl
ayzkbswhlnfptcvdqm
cmfyketonuixwdgpav
xeyngtvuwfcdik
xdufiwcnekvtgy
zuvyixgbsdhwnjkelcf
xwdfvucyinekgr
vwznkidlhxuaosfr
rhakozvwgfisdunl
korahvzwdsyilnuf
fhniwvurokxszald
rlhewm
whpr
wraqfh
szpvechrdnybfjmog
vgptfyjmbdcxzshe
zhsfqepvtygnbjmdc
yzhjalgcusdpfbmveik
xapwbucizkl
qgs
yoehs
jrsge
vjgdtm
vxyuftcbpl
uycftxlbpv
vtxflpbycu
pbcxfvtlyu
xylavcftupb
yhbadxqs
hqdxsay
zphxtaqsd
asdoeqxhfnj
tlmrid
osmrjwlvge
hfprkgzljcs
slghpczfjrk
flcjzshpgrk
hzfcjsgklpr
rgphlfjkzcs
jizfvmyocxq
kogmzyjiqv
ujnqwpaszvhymro
gxomvzjcqy
ie
ie
piec
ei
tvaxzm
txamv
puqcatmbe
bcuqto
ubsiqhzgc
vkqogu
oqfhigvudm
voqubg
zlfapsjxtm
umalzjpfosxt
jplsftaxzm
tafzxlpqsbjm
zicyojr
ilzcyr
hzcrtleyvipf
zicypr
yicezur
ehigkrowmvjylnxb
tihkwoxbjelnmrvy
nkjbmxwhoelrviy
vnojlkwxrmhbeiy
lvkhxnowmjeyrib
bpzgcrtoisywvned
acdwbrytesguv
b
qb
ba
bh
b
hntmvbilk
tnmbzvl
vbfnmt
yvnomuxbtw
ib
ib
lib
jefqbsd
iyhzrvcngl
zaeqfuhynlbxipwvgotkd
kagozfcnbirmpuesywdv
wfulhibnvtapkyrq
ibleqfykavprunmxwth
raulpqfwbhvintyk
vnwrklhufytbapiq
bknqpvrytfuhlwai
wtgqajfmk
mwbfcjukqga
fmghkjwaq
gfawqmjk
fjwmkgaq
lxk
t
w
w
mf
mnzbcw
rad
ejpxykvhu
zslo
fatkelbspwjyhoqrdui
qsngucrzamvx
ldwhapn
wnma
awn
wnau
naw
fnrgykvulp
vyrlupngk
kynprgualvq
oz
oz
oz
zo
dehqmlkfyxpvujagbtcwio
huapickwemyblxodftjvgq
pagblyvnjotwekuhcfxiqm
qjythibopgxaeckmwvluf
huclkitbnrad
uhdoictnrklba
tlcbauhdinrk
pamdyrxtj
pktnmarybxjd
tr
drt
rkt
tor
rt
gjrclwxyuk
isqmdbf
eoivmdfpt
qvg
i
ui
j
l
u
lu
osd
zmdknlf
nzlfmdk
dmznfkl
dzlnkfm
ozdievpxm
mzoxdiepv
idpzexovm
ovdemzxpi
cbyrndpwk
kozyrncdp
ujcksndxphyf
dnbpkyc
e
e
e
w
tpndq
igpajc
gihvnzfacujpoelxqkr
mqfjnrodzkuvxaipel
okwanixqlpjufevr
rxipfjtasnekyulqvob
jmgeixvhaoknq
qloihgekvjxman
ajoghikvmpxnqe
ingovjkaehqmx
szualfd
zsulfaw
osajgkmyfvri
hwmisgbaqf
bvzm
izwrn
zsfd
mz
kixhabnoqpzsg
gpnxaikqobzsh
argcboiqznkxsph
oaqgicsndhkbzxp
jzxhpstoinqbkga
fkisv
fvisdrk
vkmisf
ksifqv
ifspvk
ovwqbshjirpg
iohbgfjqcrvt
efsqtnoywmkzrv
gwsotczmkdyqlrve
zmverktswfynqo
rwtuihvjqofszxaykn
riqntxydpcakjbgo
mzkndrhabvj
gywofampnlxbhsi
hbtenma
rcamubhn
bmndhkja
afsnkue
pfcvirzydqbetlk
zftwoivcr
rtvzwix
kzjwtrgi
hitwzor
harkxeinjtgpy
tprbwighzeksymcv
qecrsugzdho
uwdxocqyftnbzhl
dcrzqhuso
sdchqozu
cu
u
u
u
whlfczpqa
yfzhpqc
zpfobxkhqc
cfzhqp
fcozqhp
erbnkjqouhg
qsthnrjiwxvzkaf
yncqejdukrh
klqubphrnj
ikvyfmlpacez
mzeiplkacvfy
lyfzipvcmeqak
qo
h
neuzqjk
ixqhknj
pvbrygdacs
xf
ef
f
f
t
t
j
z
ybx
a
ewbmvucapsxkig
ksiprxbvagwfme
agdmiwexvsbpk
egisawxkpmbv
dykmbtv
dtjkmyv
mvkdtyc
ydkmtv
zw
o
i
oi
r
hjybnqczotxgeiaup
cpygejxuzhonitqab
jnauyiohtcepqbzgx
uaqtnyicgezoxjpbh
nptbcijxzuoeayqgh
owynpg
wpyn
pnwy
ywpn
fqoishlxzarmkc
dstzjmxrvfckuoi
xsmozrfcik
zmgsrcwiofxpku
igrkebsfoxcmdz
moas
xdcfmoa
xltpwzrf
erbhflxwzntp
tnsrbxlawpzf
rtzwuoxipfl
yesonitqag
etigoaqmynshc
tpneigasoqy
pnmvfgwyierqukct
tcnuigmqpeyrwvk
qza
zaqr
zqa
qza
qza
dyphutng
ghntydup
thpudywng
tpudyhgn
gofac
homgpwae
govmnaw
azsgo
apgmyuo
bsvqmnidyogzuewtk
qitsokmnewdbuy
iqskwxyonmuetdb
kbmsundoywiqte
uoqj
jvs
yjazt
j
r
o
nv
oy
r
u
ru
avofjnwdehrpyklqugzimtx
gfjlwkrahzqvneodmutpyxi
mgpjlfuxoyvzwqtdhaeknir
ryfqedjgpnikawmtxhvuloz
gidrokyntxavfwpmqelhzujc
k
mzp
jfpow
jfop
pfjo
qokte
eno
woef
qnart
utaqr
ajqivchfpem
upvqhcjmafe
pvewjfhmcqa
vmjpecaqhf
cahpfemjvq
ayw
kp
rixwjogsfhuyvebnp
vexwuhjyogrfisnbp
psyfwhrxeogjubnvi
yjvswhnrogixbufpe
eylbtgqvronjfzphw
brhqvoptnjeygwflz
rwhlpzbgjvoneyqtf
hcvlnbegyrfwtpozjq
ynwefqphlvrotbjzg
xyu
xy
bj
j
j
j
kocgiwr
ibksgowc
ijkcwog
wiegjcaok
rlt
ltr
lrt
rlt
lrt
xjoc
jcoxz
cxjo
r
r
amrtqgfw
udr
sderl
vonauts
atxsyvco
psroawlevbjdgk
smvzhqoya
ubwotjecsqhadvkf
ufqkjtesadhvcbow
pbqsuatrzk
rsquzpobk
pqsrbzkdu
zqcusrkpvb
spbkqrzu
vqwcinpb
aiejfduvpht
zowvpinrxqml
zufk
kwe
k
mk
wko
lydtzkhwajf
xrphuebsogm
nsucmhgqpx
mwhlnfotz
shvfwmanl
xfywodzc
fyoxchw
howycfx
owyhfxc
xwocyf
hri
rv
lzr
r
nrfc
mkd
yvjkoguaxip
nwkz
bcktdsmqf
sznkw
flhbygto
ftbylhoa
otbyflh
yhbtfol
rnphowmiy
hpwrmoyis
iunworypmh
diyrwhnmpo
qlhfdcg
plju
rl
nalk
lep
xwcropjbzkdegnufsqiht
rcidlowgxnsktqpbheyzfju
ctfxzgvprnhbqeodkwjisu
wgzu
fkbuxrwg
gwjyuhzn
nhjyzuwg
rwbm
wmkrs
itzekynp
dkepiunyt
vmwlbgkcipnseqr
xlkbgo
kgz
kag
i
x
htq
sot
f
kuqperwixsgvbctyjfdn
qjcdstpxvyuwifnbre
atqumpwrefdxvoijcznys
rfxdcuispnewjtkyqv
imdwuntbahxvj
daniwhemzxtjb
nhmajglidtxvwb
tbjinhxwymad
csaqnhdtfrmjobwkix
esjkcgpf
gmfszpk
pfgksj
i
i
i
i
alnj
zucmhenrtoq
bkn
nifp
nvi
mjkagdfsilctvpwhuq
wufhtjlgpaivcqdsmk
qutsghdvkmcwfaijlp
vutlpwschfkamqjdgi
isjwtmqkvfgalupcdh
ynsgxmfoelkd
yxmvgkd
vgmykxd
gmyhkdx
ygxmkdz
vldyroebks
osverdjlyb
eszyrudvblo
rvdqomlcbtygse
oredlbvsy
o
o
o
o
jvmo
jbkpwnc
dtwrpiqbsf
vlayehgxmozu
khc
crkylh
ewticaxphkd
fhncmk
khcf
ofvtnbpayduik
ufbiatxvpdoyn
oibfupdrtvyna
favdotpyixuqnb
ywatimcefbgvpsoundz
ismcgzfqbxdlv
zlwdsivqcbgmf
szcbqidfgvlm
fgjx
xjf
fxpjm
xjf
etuipyaxvmjszkf
aeyjvuwzspkim
pajvmizekyus
nmbyxzehsagcdfjvt
hzbaxdfyjevntgc
dvthajbznegxfcy
ftwqrgzohp
hexzqdjsrfwmu
eubmrcntqyxpsjozvilgadhkfw
zjfrdtwiuyoaepcnmkslqvgxbh
keiurfhgmzovydqapcxjswntbl
umkocxlwagfbzepjyirtvdsnhq
kngzxjrshovmdbtclwfiqepyua
lyomqhdu
mylowqh
chlwr
rhwcl
crlhw
wcplrfh
tamkofzcpq
tomgsjqca
bj
vfwbi
gb
gbz
njaecfkliuwm
cnvkfwualmij
iaunwmfelckj
hjifcqxumnkalw
iht
orlie
afsxupiz
nocfkzrdstjqwu
ehisrtpqnwgaymbuc
qxgt
gtoxcj
txgr
hoxsgkdiqtfz
gtfisxozhvdk
gofksdtxihz
izghftsdokx
i
x
a
i
i
knqftuisvegdjw
ymogrc
yacpbrog
gxlp
sa
k
k
w
b
speodbqvngkjrl
nfslobmegdpkjvqr
rpgbneasdkljqvo
dnvklcgjiorqpubse
y
y
y
y
y
pahzx
axpz
axzp
ya
a
ay
ta
haposzk
lromwgtifpz
xobjpszq
pujonz
ndopyqvz
wqfl
kwuqelft
lfbvwq
cqgefyksvhwpalxdbrimoznu
spvyfeucqnigwxbkzrmadl
sxlwrdbyvgzpqmnuacfejti
ou
uo
uo
ou
uo
oridzvksnfuep
vsrpfexizdoq
nxo
qgx
xybutqfszdhl
ybsdlqfxutz
zlxuydqbtsf
tl
tbla
rtel
jtgxlohyc
w
vrgofi
kcjt
xkqnrf
pxqnr
xrqn
qrxnp
qxrn
pabnotufrs
bornptsda
sptobanru
mjzonarsplybgt
uranspoqbtx
gncfptk
qyodies
tiln
lt
lt
lt
ecbxuofajgshqk
crehbqksaoifjux
klibxfuhqejocaws
csbxhojuatefkq
gjaqcexhkofbus
egjflivrcywdtu
gyiedbfovxt
qsviadhygtef
gihexypfdvnt
niotdwkarb
jbimonfkl
j
z
yfob
bymsrul
byqu
dsycgzhtioxrpwvlen
edskiwvnhozrcypglt
ygcjblprwkiehz
esfjghqbliczwpuk
ieghcjlpzkwmb
mcephzsxawni
imazphsnexw
mxezwnhysipa
wsheabqmnipxzd
pcmwhysneazxi
yovtlfcuiwxmskzjqeghr
gbcvlityzjxqmfoswkue
mqlgfwkvysjuzntieoxc
hivam
amfuvi
aemv
mxahvg
lze
le
lze
lepd
jwpm
wjmc
gcmjw
mjdaw
jwm
s
sxuq
su
ns
uqs
csqmipzdnhxkvfgt
hxdfqvptigsmcn
snhpfmtgqivcxd
scihxqwpmdntfvg
nrsmoa
rsnma
sramn
nasmr
msnar
yihjeplactzrdfb
ztfekaljidry
qwhty
gweh
zksdnuipmhal
oxtwrhcbjq
qhcvb
ybemxa
jseoixkvc
ugdxepl
tofhpsgaul
lqushgofp
lfphogsu
goplhsuf
lhsugpof
gdwzk
xqw
wmiagjvocxrzkhdtfu
xhwscvljdqryibpgofma
rgacswftbpxydum
rsmtxdypgofuacwb
rwqkufstdjxmnalgbpyc
thzabcdwprgyxmsfu
caywrpsduftgxbvm
dujpzvsb
jusdvpabr
odvjbsup
budpvjs
kpujbsvd
gfpncwmjrdlx
rwmcfnbdplgj
djw
jdw
wjd
diwvjn
jwdb
h
k
z
k
v
al
lpa
la
chinjymkwe
vnwgcemkp
kvcemyxnj
enkcm
krlceuqnfom
glewafm
ngqawfvul
fia
rup
j
rmp
ju
dgvtfbxow
wvtjgbdxf
gxtbwvd
tbndgxzqvw
kuycgeanqwh
unkhyceqgaw
aykcweqguhn
ceqhwkunyag
vcighoudqlamkrt
dnyhemguilvqtao
hxzoubfvgiqajtlwm
ovqepnmgladtihu
oatnlremuvsigqh
nd
wdn
xnea
ribpvsfynoctmqh
n
rpflnskacoq
laqojrp
liprwqao
aojlprq
oarqipl
jvk
zwmvj
jv
vj
vydxlwk
vxywd
xdyzurw
lqghripoewbjdvy
qbpcdjlwhovrey
pledvrqbwhsojanf
hjqdbptlmwzeogvr
rqjwohdipuvble
h
h
ot
t
t
fyxkdhnwalez
weakhydnlxzf
xhqawsrol
guxblwar
lvkjrydiwxmptea
wfaxnrgl
famd
xmd
md
fmd
damj
istm
smbj
mwbs
msw
ms
raszvfpwdmeich
awfmvlizcperdh
pjviuhacmzfwdryqe
t
t
t
t
t
b
b
uemjsklzft
teukljfmzs
ztfjulsemk
jkfesztmlu
jlumszeftk
toczuxmkslrhpvijeg
mopultekcxzv
xukmoedpltczva
kpolveuzxmtc
pktdovemcxzul
agvfm
jvogqfiau
vdaogf
c
gqd
sgfpy
sgfbpl
jretxvqmfghp
tureqgfvjm
ijtyqezrgvnfml
mergqtjfv
ubzsrptcgxwdoe
tebrzfpwuxgds
wbdrxtfpgsuez
gvnuhzpdebwaxtrs
gdqmje
gqtcpdmfe
rxqyiehnogmsbdv
fqwzlinbormheg
mjorlniezb
ia
ai
ia
ai
xghswfuabdlqicnyekmt
bgetcxwalnkdiysfuh
sigwankrfuhtcxedlby
nlwxfucbhgtdseikya
khawdecfngultbyixs
cwzgvbuqlsyetoiajnpm
asjpbudkhoinqgtzryfwevxc
zbpfxictqy
udpyqtxizcgef
zptxicfhqy
hpqcfbzixyt
zxhqpyftic
oirypkjhxfcwdqeagu
hwoqyupdrjigbmvxsa
kxdhpangqieuroyjw
fegnzr
rzfgne
erfnzg
znfreg
pvuafthmr
dvpmwcyg"""
split_input = raw_input.split("\n\n")
Each item in the split_input list represents the collected answers for a group. If a group has more than one person in it, a newline character separates each person’s answers.
In the sample of split_input shown below:
The first line shows the answers for the first group, which is made up of two people.
The fifth line shows the answers for the fifth group, which is made up of five people. All of them answered yes to only one question: Question v.
With the input data massaged into something that could easily be processed in Python, it was time to get to work.
Strategy
The goal was to get the total of all the “yes” answers for all the groups, keeping in mind that if any person in the group answers “yes” to a given question, the group is considered to have answered “yes” to that question.
Consider a group of three people. If:
the first person in the group answered “yes” to questions a, b, and c,
the second person in the group answered “yes” to questions d, e, and f,
and the third person in the group answered “yes” to questions g, h, and i…
…the the group is considered to have answered yes to questions a though i.
To put it mathematically, a group’s answers was the union of the answers of everyone in the group.
With that in mind, I wrote this function:
def count_union_group_answers(groups):
count = 0
for group in groups:
if len(group) == 1:
# If there’s only one person in the group,
# the group’s “yes” answers are that person’s “yes” answers.
count += len(group[0])
else:
# If there’s more than one person in the group,
# the group’s “yes” answers are the union
# of everyone’s yes answers.
union_of_answers = set(group[0]).union(*group[1:])
count += len(union_of_answers)
return count
This function takes advantage of the fact that while Python’s union() is a set method, it can take one or more non-set arguments, as long as it can convert the arguments into a set.
For example, this code:
set(['a', 'b', 'c']).union("def", "ghi")
results in this set:
{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}
I rearranged the set so that its items would appear in alphabetical order so that it would be easier to read. This is fine, because with sets, there is no order.
Now that I had count_union_group_answers(), I could apply it to groups…
count_union_group_answers(groups)
…and get the answer for part one: 6504.
The Day 6 challenge, part two
The challenge
Here’s the text of 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?
Strategy
This time, the goal was to get the total of all the “yes” answers for all the groups, keeping in mind that the group is only considered to have answered “yes” to a given question if every person in the group answered “yes” to that question.
Consider a group of three people. If:
the first person in the group answered “yes” to questions a, b, and c,
the second person in the group answered “yes” to questions a, e, and f,
and the third person in the group answered “yes” to questions a, h, and i…
…the the group is considered to have answered yes to question a, and nothing else.
To put it mathematically, a group’s answers was the intersection of the answers of everyone in the group.
All I had to do was tweak the count_union_group_answers() function from part one to find the intersection of group members’ answers…
def count_intersection_group_answers(groups):
count = 0
for group in groups:
if len(group) == 1:
# If there’s only one person in the group,
# all the answers count.
count += len(group[0])
else:
# If there’s more than one person in the group,
# only answers common to all people count.
intersection_of_answers = set(group[0]).intersection(*group[1:])
count += len(intersection_of_answers)
return count
…and then apply count_intersection_group_answers() to groups…
One of the silver linings of my job evaporating due to the pandemic is that I suddenly had a lot of free time to try some new things. The best of those new things by far was my five weeks in The Undercroft’s inaugural UC Baseline cybersecurity course.
Over the past year, a number of notable out-of-state tech companies have chosen to open offices in or relocate to Tampa. Last December, Tampa beat out other up-and-coming tech hubs like Denver and Atlanta as the new home of Boston-based Drift, a marketing technology platform. Information technology training franchiser New Horizons moved its headquarters from Pennsylvania to Tampa in January. And that same month, D.C.-based technology company TheIncLab expanded to Ybor City. TheIncLab opened an “Artificial Intelligence Experience Lab” in The Undercroft, a cybersecurity incubator that launched last summer with the hopes of turning the historic Ybor into a tech industry hotspot.
“At The Undercroft, we’re focusing on the supply side of cybersecurity,” says CEO Adam Sheffield. “How do we support more talent in this community and more people who have passion for the field?”
Initially conceived as a co-working type space where startups and members could connect, The Undercroft launched a training program, UC Baseline, in response to layoffs during the coronavirus shutdown. The UC Baseline program is designed to help educate people moving into the cybersecurity workforce or transitioning from traditional IT roles. Ten participants have signed up for the six-week program that offers courses in networking, software, and hardware, according to Sheffield Incubators and accelerators are behind much of Tampa’s recent tech growth, as nonprofits like the Tampa Bay Wave and Embarc Collective offer resources and networking opportunities for local startups, including two recent programs that focus on boosting the representation of women and diversity in the tech industry.
To describe The Undercroft as Tampa Bay’s security guild and cybersecurity coworking space is fair, but that description doesn’t capture the spirit of the place.
A better way to paint the picture would be to call it the 21st-century cybersecurity counterpart of coffeehouses in 17th- and 18th-century England. Like those coffeehouses of old, The Undercroft is a place in a beautiful old building that functions as the home for the (often boisterous) exchange of ideas, the advancement of specialized fields of knowledge, a little deal-making, and if you pay attention, a great place to learn.
(Thankfully, The Undercroft departs from those old coffeehouses in one important way: Women are welcome in The Undercroft.)
How I ended up in UC Baseline
Back in mid-July, I’d heard about scholarships for The Undercoft’s then-upcoming cybersecurity class. I posted an article about it, which ended with this quip:
(I’ll admit it: Although I’m not likely to qualify, I applied.)
I applied, and to my surprise, I qualified, which meant that I was in this classroom a couple of weeks later:
What I did in UC Baseline
And thus began five intense weeks, which comprised the following…
Hardware 101 — Gain a thorough understanding about the devices on which all our software runs and through which all our information flows:
Networking 101 — Learn how our systems are connected and the ways in which they communicate through these connections:
Linux 101 — Covers the foundations of security in Linux environments, the OS on which the internet runs:
Windows 101 — Here’s a big challenge — learn the foundations of security for Windows environments:
Information Security 101 — Covers everything from core IT concepts, to cybersecurity principles, methods, and practices:
Python 101 — If you’re doing security, you should have some coding skills to automate your work and build tooling, and Python’s an excellent language for that task:
This is not for someone who’s casually curious about cybersecurity. It’s a lot of work. As I wrote midway through the course:
If you take The Undercroft’s five-week cybersecurity course, UC Baseline,you will have to absorb a lot of material.
After one particular day, I felt like the cat in this video:
The course was taught by a team of instructors who work in the security industry when they’re not teaching. They’re also a personable bunch, and all of them went above and beyond in their efforts to ensure that we students were getting the most out of our classes.
Did it pay off to devote 5 weeks, 5 days a week, 8 hours a day, to attend UC Baseline? I think it did.
I’m really a programmer and developer evangelist by training and experience. There’s a tendency in both these lines of work to think of security as an afterthought. Attending UC Baseline, learning from actual security professionals, getting my hands on the actual hardware and software used by the pros, and even just being in The Undercroft helped me refine my security mindset.
That in turn helped me bring my A-game when it was time to apply for a job at Auth0 and then go through their rigorous interview process (which I wrote about here).
I’m not alone — 8 out of 10 of the inaugural UC Baseline class got work around a month or so after completing the program.
And of course, special thanks to Team Undercroft, for making such a special place — the Tampa tech scene just wouldn’t be same without you: Joy Randels, Adam Sheffield, and Chris Machowski!
Another UC Baseline in 2021!
If UC Baseline sounds interesting to you, and if you think you’re up to the challenge, there’s another one taking place in early 2021. Visit the UC Baseline page to find out more!
Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 5 challenge.
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?
Importing the data
Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into Python. This involves pasting it into a triple-quoted string and assigning it to the variable raw_input, and then splitting it using the newline character as a delimiter, producing a list named split_input:
They dropped a hint in the title of the challenge: Binary Boarding.
They dropped a hint by saying the airlines seats people using binary space partitioning instead of zones.
They dropped a hint when they said that the row numbers range from 0 to 127, and that a seven-character sequence determined your row. Only two characters could be used in that sequence, F and B.
(Additional hint for those of you who didn’t study binary numbers: The numbers 0 through 127 can be represented using seven bits.)
They dropped a hint when they said that the seat numbers (which they called column numbers) range from 0 to 7, and that a three-character sequence determined your seat. Only two characters could be used in that sequence, L and R.
(Additional hint for those of you who didn’t study binary numbers: The numbers 0 through 7 can be represented using three bits.)
The “FB” and “LR” sequences are just binary numbers in disguise.
Solving this challenge involves:
Converting the “FB” and “LR” strings into binary strings.
Converting those binary strings into decimal numbers.
Doing the math on those numbers to get the seat IDs.
Converting the “FB” and “LR” strings into binary strings and converting those binary strings into decimal numbers
For each “FB” string, I wanted to convert the Fs to 0s and Bs to 1s. In order to do this, I used Python’s string.maketrans() method to build a character translation table and its string.translate() method to make the translation using that table.
The first line in the function uses string.maketrans() to define a translation table. string.maketrans() takes two arguments:
The characters to be translated.
The corresponding resulting characters.
In this case, I only want F to be translated into 0 and B to be translated into 1. All other characters translated using this table will remain unchanged.
The second line does the actual translating, using the translation table as its guide.
With the function defined, I could then use it to create a list of all the rows, expressed as binary strings:
binary_rows = [convert_FB_to_01(line[:7]) for line in split_input]
This line of code creates a new list, binary_rows, by taking the first seven characters of each line of input data — the “FB” string — and converting it to binary.
The next step was to convert binary_rows into a list of its numeric equivalents:
decimal_rows = [int(binary_row, 2) for binary_row in binary_rows]
This line of code, creates a new list, decimal_rows, by converting each binary string into its decimal numeric equivalent. It does this by using the int() function to convert strings to integers, and the extra argument specifies that value represented in the string is in base 2, a.k.a. binary.
Here’s a sample of the result:
[97, 94, 58, 93, 50,
18, 47, 72, 72, 90, ...
It was time to do the same thing with the “LR” strings. This was pretty much the same operation as with the “FB” strings.
binary_columns = [convert_LR_to_01(line[-3:]) for line in split_input]
This line of code creates a new list, binary_columns, by taking the last three characters of each line of input data — the “LR” string — and converting it to binary.
Finally, convert these numbers into decimal:
decimal_columns = [int(binary_column, 2) for binary_column in binary_columns]
I now had two lists that I could use to do the math:
decimal_rows: The “FB” sequences, converted into decimal numbers.
decimal_columns: The “LR” sequences, converted into decimal numbers.
Doing the math to get the seat IDs
As stated in the problem definition, the ID for any given seat is (its row number * 8) + (its seat number). I needed to build a list of seat IDs using decimal_rows and decimal_columns.
Here’s the code I used to do it:
decimal_rows_and_columns = zip(decimal_rows, decimal_columns)
seat_ids = [item[0] * 8 + item[1] for item in decimal_rows_and_columns]
The first line uses zip() to take two lists to make a single list filled with tuples. Each tuple has an item from the first list and a corresponding item from the second list. Here’s an example of zip() in action:
The second line uses the newly-created decimal_rows_and_columns as a basis for creating a new list of seat IDs.
Once the seat_ids list was created, it was a matter of using the max() function to get the highest ID value, which was the solution for part one. In my case, the value was 883.
The Day 5 challenge, part two
The challenge
Here’s the text of 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?
Strategy
It’s a full flight, so my seat should be the only one missing from the list. I could find this seat by doing the following:
Sorting the seats in ascending order.
Iterating through the seats, while keeping an eye out for a “gap”. That gap is my seat.
Solution
Here’s the code I used to solve part two:
sorted_seat_ids = sorted(seat_ids)
last_seat_ids_index = len(sorted_seat_ids) - 1
current_index = 0
my_seat_id = None
while current_index < last_seat_ids_index - 1:
if sorted_seat_ids[current_index + 1] - sorted_seat_ids[current_index] == 2:
my_seat_id = sorted_seat_ids[current_index] + 1
break
current_index += 1
if my_seat_id:
print(f"My seat is {my_seat_id}.")
else:
print("Better check that algorithm!")
It creates a list of sorted seat IDs, which it then loops through. While looping through it, it checks to see if the ID of the seat immediately after the current one is 2 higher than the current ID. If it is, we’ve found the gap, and the ID of my seat is the ID of the current seat plus one.
In my case, the seat ID was 532. I entered that value and solved part two.
Please be warned: If you want to try solving the challenge on your own and without any help, stop reading now! The remainder of this post will be all about my solution to both parts of the Day 4 challenge.
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:
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?
Importing the data
Every Advent of Code participant gets their own set of data. I copied my data and went through my usual process of bringing it into Python. This involves pasting it into a triple-quoted string and assigning it to the variable raw_input.
At this point, each item in the list had its individual components delimited by a mix of spaces and newlines. I used this line of code to convert and newlines to spaces:
split_input_2 = [string.replace("\n", " ") for string in split_input]
With the input data massaged into a decent data structure, it was time to test the passports to see if they were valid. Valid passports have have all the required keys.
I wrote this function to test the validity of a given passport:
def is_valid_passport(passport):
has_birth_year = "byr" in passport
has_issue_year = "iyr" in passport
has_expiration_year = "eyr" in passport
has_height = "hgt" in passport
has_hair_color = "hcl" in passport
has_eye_color = "ecl" in passport
has_passport_id = "pid" in passport
has_country_id = "cid" in passport
return (
has_birth_year and
has_issue_year and
has_expiration_year and
has_height and
has_hair_color and
has_eye_color and
has_passport_id
)
With is_valid_passport() written, I could apply it to every passport by way of a list comprehension:
valid_passports = [passport for passport in passports if is_valid_passport(passport)]
print(len(valid_passports))
My result: 228. I entered it into the solution text field, and Advent of Code told me that I was correct! It was time for part two.
The Day 4 challenge, part two
The challenge
Here’s the text of 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: ambblubrngrygrnhzloth.
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:
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?
Strategy
In part one, it was about testing for the presence of required keys. This time, it was about testing for valid values.
To that end, I wrote this function…
def has_valid_values(passport):
has_valid_birth_year = 1920 <= int(passport["byr"]) <= 2002
has_valid_issue_year = 2010 <= int(passport["iyr"]) <= 2020
has_valid_expiration_year = 2020 <= int(passport["eyr"]) <= 2030
has_valid_height = False
height_units = passport["hgt"][-2:]
if height_units == "cm":
height = int(passport["hgt"][:-2])
has_valid_height = 150 <= height <= 193
elif height_units == "in":
height = int(passport["hgt"][:-2])
has_valid_height = 59 <= height <= 76
def is_valid_hex_string(string):
test_value = string.lower()
is_valid = True
for character in string:
if character not in "0123456789abcdef":
is_valid = False
break
return is_valid
has_valid_hair_color = False
if len(passport["hcl"]) == 7:
digits = passport["hcl"][1:]
has_valid_hair_color = is_valid_hex_string(digits)
has_valid_eye_color = passport["ecl"] in ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"]
def is_valid_passport_id(value):
is_valid = False
if len(value) == 9:
is_valid = True
for character in value:
if character not in "0123456789":
is_valid = False
break
return is_valid
has_valid_passport_id = is_valid_passport_id(passport["pid"])
return (
has_valid_birth_year and
has_valid_issue_year and
has_valid_expiration_year and
has_valid_height and
has_valid_hair_color and
has_valid_eye_color and
has_valid_passport_id
)
…which I then used in a list comprehension, which served as a filter on the validated passports from part one:
truly_valid_passports = [passport for passport in valid_passports if has_valid_values(passport)]
print(len(truly_valid_passports))
My result was 175, which was correct. Day 4 was done!