Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. queensSolutions
  2. ================
  3. Solve the famous n queens puzzle with bitwise.
  4.  
  5. For example, solving an eight queens puzzle, the input should be 255 (11111111 bin), and the output will return an array which contains all the solutions formed as strings.
  6.  
  7. One of the solutions of the above exapmle is like "1,16,128,32,4,64,2,8". After spliting with the separator ",", it becomes ["1", "16", "128", "32", "4", "64", "2", "8"].
  8.  
  9. Now it looks like this:
  10.  
  11. 1
  12. 16
  13. 128
  14. 32
  15. 4
  16. 64
  17. 2
  18. 8
  19.  
  20. In binary form:
  21.  
  22. 00000001
  23. 00010000
  24. 10000000
  25. 00100000
  26. 00000100
  27. 01000000
  28. 00000010
  29. 00001000
  30.  
  31. where 1 are queens.
Add Comment
Please, Sign In to add comment