This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// =========================================================== | |
// PART 1 | |
// =========================================================== | |
let answer1 = 0; | |
const parsed = input.split(`\n`); | |
const links = {} as Record<string, string[]>; | |
const backLinks = {} as Record<string, string[]>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Flow = | |
| { type: 'go'; dest: string } | |
| { type: 'gt'; var: Key; value: number; dest: string } | |
| { type: 'lt'; var: Key; value: number; dest: string }; | |
const rule: Record<string, Flow[]> = {}; | |
const [rules, parts] = parsed; | |
for (const ruleLine of rules.split('\n')) { | |
const [name, rulePart] = ruleLine.split('{'); | |
rule[name] = rulePart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parsed = input.split(`\n\n`); | |
const start = performance.now(); | |
// =========================================================== | |
// PART 1 | |
// =========================================================== | |
let answer1 = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addHints() { | |
document.querySelectorAll('label.answer p').forEach((p, i) => { | |
if (p.getAttribute('data-processed')) return; | |
let hint = document.createTextNode(` (SHIFT: ${i + 1})`); | |
p.appendChild(hint); | |
p.setAttribute('data-processed', 'true'); | |
}); | |
} | |
setInterval(addHints, 1000); | |
window.addEventListener('keydown', (k) => { |