Added the four first days of 2015

Yes i'm gonna do them all !

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2021-12-07 17:03:46 +01:00
parent c0369d340a
commit 1060cb8a09
11 changed files with 1179 additions and 0 deletions

1
2015/day-1/input.txt Normal file

File diff suppressed because one or more lines are too long

8
2015/day-1/part-1.ts Normal file
View File

@@ -0,0 +1,8 @@
import fs from 'fs'
const input = fs.readFileSync(__dirname + '/input.txt').toString()
.split('')
console.log(
"Result:", input.reduce((p, c) => p + (c === '(' ? 1 : -1), 0)
)

19
2015/day-1/part-2.ts Normal file
View File

@@ -0,0 +1,19 @@
import fs from 'fs'
const input = fs.readFileSync(__dirname + '/input.txt').toString()
.split('')
let v = 0
for (let i = 0; i < input.length; i++) {
const item = input[i];
if (item === '(') {
v++
continue
}
if (--v < 0) {
console.log(
"Result:", i + 1
)
break
}
}