My personal attempts at the 2022 Advent of Code https://adventofcode.com/2022
Each day is in a two-digit day numbered folder
The *.py file is my code
https://pypi.org/project/advent-of-code-data/
A slick way to download the puzzle data and submit answers
numpy!
- 11 Dec, still lagging
- Things I re-learned
- numpy indexing
- Things I learned
-
np.genfromtxt
PurePosixPath!
- 11 Dec, lagging a lot
/jssbn/lfrctthp/lfrctthp/
WHHYYYY!?!?!- Thanks to Rainow CSV VS Code Extension for enabling a rapid exploration of the dataset, although a momentary panic that
LIKE
wasn't supported was alleviated by the existence oflike(col, str)
- Things I re-learned
- If you don't update the value of a loop variable, it's not helpful
- When concatenating strings with
+
you have tostr()
integers collections.defaultdict
is awesome- EXPLORE YOUR DATASET
- Things I learned
pathlib.PurePosixPath
can be used to keep track of directories even if there's no actual file system!
Counter!
- 08 Dec, still lagging
- Things I re-learned
- Can't chain
list.append()
withlist.pop()
because they both returnNone
- Can't chain
- Things I learned
Counter.most_common()
Transposed Lists!
- 07 Dec, still lagging
- Things I re-learned
- inplace list operations
- Things I learned
itertools.groupby()
Sorted Lists! Mapped Tuples!
- 06 Dec, still lagging
- Got
aocd
working on Ubuntu - Things I re-learned
sorted()
for listslist.count()
- Things I learned
(tuple(map(operator.sub,tups[0],tups[1])))
subtracts corresponding elements in a pair of tuples!
Sets!
- 05 Dec, still lagging
- Didn't get around to debugging
aocd
- Things I re-learned
set.intersection()
string.isupper()
- Things I learned
reduce(lambda x,y: set(x)&set(y), list_of_strings)
Dictionaries!
- Doubling up, 04 Dec
- Things I re-learned
advent-of-code-data
is a thing!- Must get your AOC session token
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available
Lists!
- Started late, 04 Dec
- Things I re-learned
from pathlib import Path
p = Path(__file__).with_name(n)
with p.open() as f: txt = f.read().splitlines()
- To add items to a list,
list.append()
for a non-iterable,list.extend()
for items in an iterable
- Things I learned
- You can use
None
in a variable when setting a stop slice index!
- You can use