From 2cb5c1ea8abf0d12cf53a3e09bf225e78b65c069 Mon Sep 17 00:00:00 2001 From: Alix von Schirp Date: Sun, 7 Dec 2025 17:32:58 +0100 Subject: [PATCH] solution(partial): 2025/6/1 Signed-off-by: Alix von Schirp --- src/2025/6/1/index.ts | 40 ++++++++++++++++++++++++++++++++++++++++ src/2025/6/2/index.ts | 0 2 files changed, 40 insertions(+) create mode 100644 src/2025/6/1/index.ts create mode 100644 src/2025/6/2/index.ts diff --git a/src/2025/6/1/index.ts b/src/2025/6/1/index.ts new file mode 100644 index 0000000..277a628 --- /dev/null +++ b/src/2025/6/1/index.ts @@ -0,0 +1,40 @@ +export default async function runner(inputPath: string) { + const input = (await Bun.file(inputPath).text()).trimEnd(); + + let sum = 0; + + const splittedOutput = input.split("\n").map(value => { + return value.trim().split(/([\d\s]+)\s/gm); + }) + + const transposedInput: string[][] = []; + + for(let i = 0; i < splittedOutput[0]!.length; i++){ + const transInput: string[] = []; + splittedOutput.forEach(line => { + transInput.push(line[i]!) + }) + transposedInput.push(transInput) + } + + + transposedInput.forEach(value => { + let work = 0; + for(let i = 0; i < value.length - 1; i++){ + if(work === 0 && value[value.length-1] === "*") work = 1; + const val = parseInt(value[i]!) + switch (value[value.length-1]){ + case "+": + work += val; + break; + case "*": + work *= val; + break; + } + } + sum += work; + }) + + console.log(sum) + +} diff --git a/src/2025/6/2/index.ts b/src/2025/6/2/index.ts new file mode 100644 index 0000000..e69de29