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

5
2025/01/JS/deno.json Normal file
View File

@@ -0,0 +1,5 @@
{
"tasks": {
"dev": "deno run --watch main.ts"
}
}

10
2025/01/JS/example.txt Normal file
View File

@@ -0,0 +1,10 @@
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82

4732
2025/01/JS/input.txt Normal file

File diff suppressed because it is too large Load Diff

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()