mirror of
https://github.com/danbulant/adventOfCode
synced 2026-05-21 13:18:40 +00:00
17 lines
No EOL
595 B
TypeScript
17 lines
No EOL
595 B
TypeScript
|
|
const input = Deno.readTextFileSync("input");
|
|
|
|
const priority = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
|
|
let sum = 0;
|
|
for(const line of input.split("\n")) {
|
|
const firstHalf = line.slice(0, line.length / 2);
|
|
const secondHalf = line.slice(line.length / 2);
|
|
console.log(firstHalf, secondHalf, firstHalf.length, secondHalf.length);
|
|
|
|
const sharedLetter = firstHalf.split("").find((letter) => secondHalf.includes(letter));
|
|
sum += priority.indexOf(sharedLetter!) + 1;
|
|
console.log(sharedLetter, priority.indexOf(sharedLetter!) + 1);
|
|
}
|
|
|
|
console.log(sum) |