Skip to content

george-williamson/advent-of-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

❄️ Advent of Code Solutions ❄️

A repository to store my solutions to the annual advent of code puzzles. All of my solutions are written in Python.

📝 Learnings

🐍 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 Patterns

Algorithm learnings go here.

Misc

Misc learnings go here.