This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data structures | |
const trp = a => b => c => f => f(a)(b)(c); | |
const fst3 = p => p(a => b => c => a); | |
const snd3 = p => p(a => b => c => b); | |
const trd3 = p => p(a => b => c => c); | |
const tup = a => b => f => f(a)(b); | |
const fst = p => p(a => b => a); | |
const snd = p => p(a => b => b); | |
// boolean logic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { memoize, readAdvent, range, sum } from '../tools.ts'; | |
import * as m from 'https://cdn.skypack.dev/mathjs'; | |
const inp = (await readAdvent()).split(',').map(s => parseInt(s)); | |
// original implementation that I know gets the correct answer | |
const calc = memoize(remdays => remdays <= 0 ? 1 : calc(remdays - 7) + calc(remdays - 9)); | |
// following along this youtube video | |
// https://www.youtube.com/watch?v=A5tBvxDM9V4 |