- Store the list into a dictionary.
- Look at each number in turn and subtract it from 2020.
- Check to see if that number in the list.
- One number must be more than 1010 and the other less than 1010
- Same idea as part 1 but with an extra loop
- Number of checks required can be reduced by sorting the list
-
Used regular expressions to parse the input.
-
Different policy is required for part 2. Reused code by passing in the desired policy as a function
- Forest wraps around (right->left->right) so the toboggan's x positions needs to be mod the forest with.
- Same code as part 1, but passing in different slopes (other than 3,1)
- Nice trick when parsing the input which is to separate the passports with
.split('\n\n')
-
Created a function called
is_in_rangeand then usedpartialfromfunctoolsin order to supply the first argument. -
Used regular expressions for other validations
- Trick here is to spot the seat ids are just binary numbers!
- Found it easier to ignore
the seats with IDs +1 and -1 from yours will be in your list.in the problem statement!
-
The idea is to use the intersection of sets to give you anyone who answered yes to a question
-
Part 2 is the same, but using the union of sets
- As the definitions of which bags contain which other bags are nested, it means that recursion should be used.
-
Very simple VM with just three instructions and two registers (
accumulatorandinstruction pointer) -
Part 2 is harder as one instruction is corrupted. I just brute forced changing the instructions one by one.
- Requires a sliding window of length 25 over the list of numbers