From 0b24a5828ef556b45d122e921b98624e9c7d9d5b Mon Sep 17 00:00:00 2001 From: Alix von Schirp Date: Tue, 11 Nov 2025 06:53:21 +0100 Subject: [PATCH] 2015/8 --- src/2015/8/1/index.ts | 16 ++++++++++++++++ src/2015/8/2/index.ts | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/2015/8/1/index.ts create mode 100644 src/2015/8/2/index.ts diff --git a/src/2015/8/1/index.ts b/src/2015/8/1/index.ts new file mode 100644 index 0000000..38d94e6 --- /dev/null +++ b/src/2015/8/1/index.ts @@ -0,0 +1,16 @@ +export default async function runner(inputPath:string){ + const input = await Bun.file(inputPath).text(); + + let diff = 0; + + input.split("\n").forEach(line => { + if(line.trim() === '') return; + const cLength = line.trim().length; + // DO NOT DO THIS!!!!!! THIS IS UNSAFE!!!!!! + const eLength = eval(`${line.trim()}.length`); + const ecDiff = cLength-eLength; + diff += ecDiff; + }) + + console.log(diff) +} diff --git a/src/2015/8/2/index.ts b/src/2015/8/2/index.ts new file mode 100644 index 0000000..1708daf --- /dev/null +++ b/src/2015/8/2/index.ts @@ -0,0 +1,19 @@ +export default async function runner(inputPath:string){ + const input = await Bun.file(inputPath).text(); + + let diff = 0; + + input.split("\n").forEach(line => { + if(line.trim() === '') return; + const eLength = line.trim().length; + + const cLine = `"${line.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`; + const cLength = cLine.length; + + + const ecDiff = cLength-eLength; + diff += ecDiff; + }) + + console.log(diff) +}