From aecfe6b8853a21296fa3278ca2bfdc53c0e24751 Mon Sep 17 00:00:00 2001 From: merrywhether Date: Mon, 9 Dec 2024 11:18:03 -0800 Subject: [PATCH] get day 09 under 100ms --- deno.json | 1 + src/07/main.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index 9f8c718..c2cc0aa 100644 --- a/deno.json +++ b/deno.json @@ -5,6 +5,7 @@ "input": "deno run -NEWR src/crypto.ts --get=$DAY", "solve": "deno run -R src/$DAY/main.ts", "test": "deno test -R src/**/test.ts", + "test:all": "deno test -R src/**/*test.ts", "test:input": "deno test -R src/**/input.test.ts" }, "imports": { diff --git a/src/07/main.ts b/src/07/main.ts index 3460278..fed7a62 100644 --- a/src/07/main.ts +++ b/src/07/main.ts @@ -1,8 +1,8 @@ // { calibrationSum: 4998764814652, concatCalibrationSum: 37598910447546 } -// Elapsed: 207ms +// Elapsed: 94ms function concatNumbers(a: number, b: number) { - return Number(`${a}${b}`); + return a * Math.pow(10, Math.ceil(Math.log10(b + 1))) + b; } function numbersProduceTestValue(