Moved to 2021 Folder

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2021-12-07 10:56:13 +01:00
parent a8a771a245
commit c0369d340a
28 changed files with 2 additions and 2 deletions

26
2021/day-2/part-1.ts Normal file
View File

@ -0,0 +1,26 @@
import fs from 'fs'
const input = fs.readFileSync(__dirname + '/input.txt').toString()
.split('\n')
var x = 0
var y = 0
for (const line of input) {
const splitted = line.split(' ')
const action = splitted[0]
const value = parseInt(splitted[1])
switch (action) {
case 'forward':
x += value
break
case 'up':
y -= value
break
case 'down':
y += value
break
}
}
console.log(`Result: ${x * y}`)