Last active
December 11, 2025 11:10
-
-
Save dkaraush/5271c80333d4fa178950a21975e9e10b to your computer and use it in GitHub Desktop.
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 input = Object.fromEntries(document.querySelector('pre').innerText.trim().split('\n').map(L => [L.substring(0, 3), L.substring(5).split(' ')])) | |
| function traverse( | |
| path = ['you'], | |
| count = {}, | |
| last = path[path.length - 1], | |
| dac = path.indexOf('dac') >= 0, | |
| fft = path.indexOf('fft') >= 0, | |
| key = last + dac + fft | |
| ) { | |
| if (last == 'out') return !!(path[0] === 'you' || dac && fft) | |
| if (key in count) return count[key] | |
| return count[key] = input[last] | |
| .filter(next => path.indexOf(next) < 0) | |
| .reduce((acc, next) => acc + traverse([...path, next], count), 0) | |
| } | |
| console.log({ result1: traverse(), result2: traverse(['svr']) }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment