hi @vaporeon_ want to read some disgusting golfy javascript code i just wrote

Advent of Code Day 1, Part 1 spoiler 

@vaporeon_
There is a round safe lock with the numbers 0-99. I have a text file called "inputs.txt" that has a bunch of instructions separated by line terminators. The instructions are like "L38" or "R15" and tell you turn the safe lock left or right by the given number. The safe lock starts at 50, I need to find how many times the safe lock hits the number 0.

let bound = 100, t = 50, hits = 0;
Deno.readTextFileSync("input.txt").split("\r\n").map(s => s.replace("L", "-").replace("R", "")).forEach(n => {
if ((t +=+ n) < 0 ? t = -(-t % bound) : t %= bound); else ++hits;
});
console.log("password:", hits);

re: Advent of Code Day 1, Part 1 spoiler 

@aescling @vaporeon_ that was on purpose

Follow

re: Advent of Code Day 1, Part 1 spoiler 

@wallhackio @vaporeon_ are you coercing n to the number type

re: Advent of Code Day 1, Part 1 spoiler 

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.