Skip to content

Commit

Permalink
day 4
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Dec 4, 2023
0 parents commit 8e462db
Show file tree
Hide file tree
Showing 24 changed files with 3,309 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 01a/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { readFileSync } from "fs";

const input = readFileSync("input1.txt", "utf-8");

let result = 0;
for (const line of input.split("\n")) {
const [_1, first, _2, second = first] = /^[^\d]*(\d)(.*(\d))?[^\d]*$/g.exec(
line
);
const number = `${first}${second}`;
result += parseInt(number);
}

console.log(result);
4 changes: 4 additions & 0 deletions 01a/input0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
Loading

0 comments on commit 8e462db

Please sign in to comment.