Skip to content

Instantly share code, notes, and snippets.

@rektide
Created May 2, 2025 23:02
Show Gist options
  • Save rektide/28695ab27e87d8740fd0352dbc160e89 to your computer and use it in GitHub Desktop.
Save rektide/28695ab27e87d8740fd0352dbc160e89 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
function* gen(
m = Number.parseInt(process.argv[2]) || 15,
n = Number.parseInt(process.argv[3]) || 26,
data = 0
) {
// finish iteration
if (n-- === 0) {
if (m === 0)
yield data
return
}
// advance to next bit
data <<= 1
// try left and right paths
yield* gen(m, n, data)
if (m > 0) {
yield* gen(m - 1, n, data + 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment