Skip to content

Instantly share code, notes, and snippets.

View gnarf's full-sized avatar

Mx Corey Frang gnarf

View GitHub Profile
@gnarf
gnarf / 2021.20.full.js
Created December 20, 2021 05:54
#AdventOfCode - Day 20 Part 2 (pre-golfing, but still ugly...)
// comment out top line if you are running it first time... don't blast that fetch!
// I=(await(await fetch("https://adventofcode.com/2021/day/20/input")).text());
// I=`..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
// #..#.
// #....
// ##..#
// ..#..
// ..###`;
[key,...rest]=I.split(/\n+/)
@gnarf
gnarf / 2021.21.golfed.js
Last active December 21, 2021 09:34
#AdventOfCode 2021 Day 21
I=(await(await fetch("https://adventofcode.com/2021/day/21/input")).text(w=W=0)).match(/(\d+)/g)
u=(c,...a)=>{for(let i in U=[,,,1,3,6,7,6,3,1])U[i]&&((r,c,p,P,s=0,S=0,t)=>(((s+=p=((p-1+r)%10)+1)>20)&&(t?W+=c:w+=c),s<21&&u(c,P,p,S,s,!t)))(+i,U[i]*c,...a)}
u(1,I[1],I[3])
w>W?w:W