Half-assed attempt at 2018 Advent of Code.
Will try to update with improvements and summarize what I've learned each day.
- originally wanted to set up to pull data on each run using node-fetch, but learned that's dumb because input doesn't change & we probably shouldn't unnecessarily bomb the server with requests
- don't think runtime can be greatly improved from first draft, as we're doing one pass over array (~6ms)
- first run was quite inefficient (~10s on my laptop w/ i7-4558U) due to using array to store a list of frequencies, and doing linear search on each iteration to look for duplicates
- first rewrite used JavaScript prototype's ability to add arbitrary attributes (~85ms)
- second rewrite used native Set type for additional performance gain (~35ms)
- readable but likely too verbose (~16ms)
- tried rewrite calculateRepeats() using native Map type for tiny performance improvement (~10ms)
- another performance improvement using object literals to avoid checking for first match (~6ms)
- first run crappy/inefficient - O(n^2)? (~48ms)
- added limiters on first discovery & diff >1 (~12ms)
- algo didn't calculate correctly on first two runs: i was off-by-one on shape-drawing loops
- parsing was PITA, should figure out if there are parsing filters/masks I can use in JavaScript
- TODO figure out better string parsing method
- TODO bonus: print out canvas
- first solution an absolute shit show in terms of readability
- new trick: use
new Array(length).fill(value)
to initialize values - TODO figure out if we can remove
moment
and use native Dates
- strings are immutable, duh
- obvious from example we should avoid multiple passes through polymer
- attempted rewriting remove() to not use the nasty string.split().join() thing to remove all occurences of particular character, rewrite sucked because it involved more array operations