this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Solve Part 1

modamo-gh e700cf83 ebdcaa75

+35
+35
day01.ts
··· 1 + const partOne = () => { 2 + const input = "puzzleInput"; 3 + const parsedInput = input.split(/\n/); 4 + const instructions = parsedInput.map((instruction) => ({ 5 + direction: instruction[0], 6 + amount: Number(instruction.slice(1)) % 100 7 + })); 8 + 9 + let dialPosition = 50; 10 + let dialAtZero = 0; 11 + 12 + for (const instruction of instructions) { 13 + if (instruction.direction === "L") { 14 + dialPosition -= instruction.amount; 15 + 16 + if (dialPosition < 0) { 17 + dialPosition = 99 + dialPosition + 1; 18 + } 19 + } else { 20 + dialPosition += instruction.amount; 21 + 22 + if (dialPosition > 99) { 23 + dialPosition %= 100; 24 + } 25 + } 26 + 27 + if(dialPosition === 0){ 28 + dialAtZero++; 29 + } 30 + } 31 + 32 + console.log(dialAtZero) 33 + }; 34 + 35 + partOne();