Skip to content

Latest commit

 

History

History

2020

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Advent of Code 2020

AoC 2020

Daily Impressions

I tried to solve this in JavaScript, but it's been a while and setting up a development environment took longer than I had before work. Hope to set it up tonight (2020-12-01) or this weekend.

Fell back to Python... hacked together a solution with tests. Once submitted, when back and generalized it.

It's been a while since I've done RegEx so I decided to use that module.

Used collections.Counter to count letters, but apparently strings have a str.count method built-in.

TIL: str.count

This wasn't too bad. Was able to take advantage of the math.prod function I learned about while reading other people's solution for Day 1.

Validating data without a serializer is not a lot of fun. It took me a few attempts to get this question correct... my RegEx-es were not accurate enough.

TIL: Make sure to start and end strings with ^ and $

Finally got a JavaScript environment set up using parcel. Have to use Node since I'm reading files from disk and have no idea how to debug except for using console.log, but that's the point. Only way to get better in an ecosystem is to work in that ecosystem until you are comfortable.

The problem wasn't too hard, spent most of my time re-learning how to basic things in JavaScript.

TIL: Array.sort does not sort numbers, have to use .sort((a, b) => { return a - b; }) instead.

Today was pretty easy. Have a bunch of stuff to do today so I went back to Python to get it done. Question would have taken me a 20-30 minutes longer in JavaScript.

Took advantage of the .split("\n\n") trick to read blank lines. Thanks to Wim in the Chicago Python Slack for the tip!

First hard-ish puzzle of the year! Stuck with Python since I have an 8:30 meeting in the morning and only had an hour to finish.

Used a graph search for Part 1 since I figured Part 2 would require it.

Today's puzzle was reminiscent of last year's IntCode Calculator. I just wrote up some if statments and called it a day for part 1. Part 2 required me to add a check to my part 1 function to ensure that it had halted.

Probably a good idea to refactor my computer into a class. A wise man once said that if statements are a code smell and it's more likely than not future problems will build upon this one.

This felt very similar to day 1. Was pretty straightforward.

Part 1 was pretty straight forward. Spent some time thinking of a way to do Part 2 without recursion and couldn't think of anything.

Implemented recursion, got it working, but it was taking forever to run. Utilized memoization via functions.lru_cache() to speed up the function. Cheers to Spencer in the Chicago Python #advent-of-code channel for the idea.

This wasn't too difficult. My part 1 solution was janky and needed to be refactored a bit so I could use the same logic to solve part 2.

I had a mistake in my input which I spent a bit of time debugging part 2. Once I starting printing out the seating map, I saw my mistake.

Day 11 was pretty messy so I tried to be clean for Day 12 by using a class. Structure from one came in handy as I was able to reuse it for part 2.

I found Part 2 extremely difficult. I tried to brute force it by using generators to find when each bus is was moving. I couldn't think of a smart optimization; got a tip from the Chicago Python slack about using the Chinese Remainder Theorem.

I took a few hours and relearned the basics of congruency and modulo arithmetic. Hand-coded my own version of the Chinese Remainder Theorem.

Helpful resources

After a hard day yesterday, this one is fairly straightforward. My implemented started off clean for Part 1, but got messy as the Part 2 class was copied and pasted.

My algorithm isn't the best, but it gets the job done with pypy3, which is good enough for me.

TODO: improve implementation and get all tests to pass.

Picking this back up in November 2021 to start getting ready for Advent of Code 2021. Part 1 was pretty straight forward. I made a mistake and used my solution for Part 1 in Part 2; there was an edge I didn't account for... got it eventually but after a bit of trial and error.

The picture was confusing, but after a bit of Googling -- found a reddit thread where somebody explained what was going on with the pic. Once I wrote up a print_state function, things became easier to reason about. Part 2 was a quick copy and paste + add a new var to go from 3d to 4d.