A repository to store my solutions to the annual advent of code puzzles. All of my solutions are written in Python.
2-element list indexing using a boolean:
This is extremely useful when you binary choices for indexing. It can remove the need to write an if else statement depending on what the value of the index is.
list = ['a', 'b']
list[False]
> 'a'
list[True]
> 'b'
list = ['XXX', 'ZZZ']
current = 'R'
list[current=='R'] # this statement is true
# has chosen the right element
> ZZZ
iterools.pairwise
Allows you to get the successive overlapping pairs in any iterable.
from itertools import pairwise
list(pairwise(list(range(5))))
> [(0, 1), (1, 2), (2, 3), (3, 4)]
https://docs.python.org/3/library/itertools.html#itertools.pairwise
Algorithm learnings go here.
Misc learnings go here.