20 lines
425 B
TypeScript
20 lines
425 B
TypeScript
import { open } from 'node:fs/promises';
|
|
|
|
|
|
const file = await open('./2025/inputs/1');
|
|
let angle = 50
|
|
let count = 0
|
|
for await (const line of file.readLines()) {
|
|
const prefix = line[0]
|
|
const sign = (prefix == "L") ? -1 : 1
|
|
const value = Number(line.slice(1)) * sign
|
|
angle += value
|
|
if (angle < 0) {
|
|
angle += 100
|
|
}
|
|
angle %= 100
|
|
if (angle == 0) {
|
|
count++
|
|
}
|
|
}
|
|
console.log(count) |