Guest User

Untitled

a guest
Jan 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function f(
  2. a, // bitmask representing all queens are placed
  3. b, // result storage
  4. c, // positions record
  5. d, // row
  6. e, // left diagnal
  7. g, // right diagnal
  8. h, // placeholder for places where queens can be placed in
  9. i // placeholder for the position where the queen is placed in
  10. ) {
  11. for (a ^ d ? h = a & ~(d | e | g) : b.push(c); i = -h & h; h ^= i) // loop through over the subtrees
  12. f(a, b || (b = []), d ? c + [,i] : i, d | i, (e | i) << 1, (g | i) >> 1); // go to the next depth
  13. return b;
  14. }
Add Comment
Please, Sign In to add comment