1
0
www.mikescher.com/www/statics/aoc/2019/01_solution-1.ts

21 lines
421 B
TypeScript
Raw Normal View History

2019-12-02 14:27:20 +01:00
namespace AdventOfCode2019_01_1
{
const DAY = 1;
const PROBLEM = 1;
export async function run()
{
let input = await AdventOfCode.getInput(DAY);
if (input == null) return;
const fuel = input
.split(new RegExp('\r?\n'))
.filter(p => p.trim().length > 0)
.map(p => parseInt(p))
.map(p => Math.floor(p/3) - 2)
.reduce((a,b) => a+b);
AdventOfCode.output(DAY, PROBLEM, fuel.toString());
}
}