Skip to content

Instantly share code, notes, and snippets.

@greyscaled
Created August 20, 2018 14:26
Show Gist options
  • Save greyscaled/de023707733f9ae8ea5588c760451f64 to your computer and use it in GitHub Desktop.
Save greyscaled/de023707733f9ae8ea5588c760451f64 to your computer and use it in GitHub Desktop.
const collect = (node, pre, pattern, q) => {
if (!node) { return }
let d = pre.length
if (d === pattern.length && node.value) { q.push(pre) }
if (d === pattern.length) { return }
let next
pattern[d] === '.'
? next = '.'
: next = Base26.getBase26Digit(pattern[d])
for (let c = 0; c < R; c++) {
if (next === '.' || next === c) {
collect(node.next[c], pre + (Base26.getUTF16(c)), pattern, q)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment