aoc 1+2
This commit is contained in:
20
www/statics/aoc/2019/01_solution-1.ts
Normal file
20
www/statics/aoc/2019/01_solution-1.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user