18 lines
386 B
JavaScript
18 lines
386 B
JavaScript
|
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 run(parse(input), [1n]).outputs.glib.sum();
|
||
|
},
|
||
|
2: (input) => {
|
||
|
return run(parse(input), [5n]).outputs.glib.sum();
|
||
|
},
|
||
|
};
|