const { parse, run } = require('./_intcode'); const gravityAssist = (program, noun, verb) => { const pClone = program.slice(); pClone[1] = noun; pClone[2] = verb; return run(pClone).memory[0]; }; module.exports = { '1': (input) => { return gravityAssist(parse(input), 12n, 2n); }, 2: (input) => { const program = parse(input); for (let noun = 0n; noun <= 99n; noun++) { for (let verb = 0n; verb <= 99n; verb++) { if (gravityAssist(program, noun, verb) === 19690720n) { return noun * 100n + verb; } } } throw new Error('no solution'); }, };