Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function f(
- a, // bitmask representing all queens are placed
- b, // result storage
- c, // positions record
- d, // row
- e, // left diagnal
- g, // right diagnal
- h, // placeholder for places where queens can be placed in
- i // placeholder for the position where the queen is placed in
- ) {
- for (a ^ d ? h = a & ~(d | e | g) : b.push(c); i = -h & h; h ^= i) // loop through over the subtrees
- f(a, b || (b = []), d ? c + [,i] : i, d | i, (e | i) << 1, (g | i) >> 1); // go to the next depth
- return b;
- }
Add Comment
Please, Sign In to add comment