adding 2015 & 2025 advents

This commit is contained in:
2025-12-16 21:34:25 +01:00
parent 536070e45c
commit 12892d6460
17 changed files with 6054 additions and 0 deletions

43
2025/01/JS/main.ts Normal file
View File

@@ -0,0 +1,43 @@
const input = await Deno.readTextFile("input.txt");
const START = 50
const TOTAL = 100
function part1(){
let password = 0
let current = START
for (const rotation of input.split('\n')) {
const direction = rotation[0]
let amount = Number(rotation.slice(1))
if (direction === "L") {
amount *= -1
}
let change = current + amount
while (change < 0) {
change = TOTAL + change
}
current = change % TOTAL
if (current === 0) {
password += 1
}
}
console.log(password)
}
function part2(){
let password = 0
let current = START
for (const rotation of input.split('\n')) {
const direction = rotation[0]
let amount = Number(rotation.slice(1))
if (direction === "L") {
const divisions = Math.floor((amount * -1) / TOTAL * -1)
password += divisions
}
}
console.log(password)
}
//part1()
part2()