Nick Niemeir walked me through signing up and solving my first "Advent of Code" puzzle. site
pages/advent-of-code
My code prints the answers unique to my assigned test input. Click above to run any puzzle. Choose View Page Source to see my solution. Here is the first day.
See also Puzzle Inputs and Samples
http://ward.dojo.fed.wiki/assets/pages/advent-of-code/code.1.html HEIGHT 30
I write a one sentence description of each puzzle part as a code comment also shown here.
http://ward.dojo.fed.wiki/assets/pages/advent-of-code/what.html HEIGHT 400
The puzzles coax me into some seldom used features of javascript. I'll post my most unexpected line of code from each of my solutions.
// puzzle 1 part 2 lists[0] .map(a => a * lists[1] .filter(b => b == a) .length)
// puzzle 2 part 2 report => safe(report) || report.some((level,i) => safe(report.toSpliced(i,1)))
// puzzle 3 part 2 const maybe = text.split(/do\(\)/) const yes = maybe.map(may => may.split(/don't\(\)/)[0])
// puzzle 4 part 2 (ok(a,[m,s],right)||ok(a,[s,m],right)) && (ok(a,[m,s],left)||ok(a,[s,m],left)))
// puzzle 5 part 1 const a = update.indexOf(rule[0])+1 const b = update.indexOf(rule[1])+1 return !a || !b || a<b
// puzzle 6 part 1 while(safe(next())) { if(mark(next())=='.') here = next() else dir = (dir+1)%4
// puzzle 7 part 1 rest.length==1 ? [first * rest[0], first + rest[0]] : [...comp(rest).map(more => first * more), ...comp(rest).map(more => first + more)]
// puzzle 8 part 1 const minus = (a,b) => { const [a0, a1, b0, b1] = [a,b].map(nums).flat() return `${a0-b0}|${a1-b1}`}
// puzzle 9 part 1 while ((g=gap())) { disk[g.space] = disk[g.file] disk[g.file] = '.'
// puzzle 10 part 1 search(x+1,y,z+1) search(x-1,y,z+1) search(x,y+1,z+1) search(x,y-1,z+1)
// puzzle 11 part 1 & 2 while(line.length) next.push(...apply(line.shift()))
// puzzle 13 part 1 const nums = line => { const [x,y] = line.matchAll(/\d+/g) return {x:Number(x[0]),y:Number(y[0])}} return {a:nums(a),b:nums(b),prize:nums(prize)}}