+ 9
[CHALLENGE] 8 Queen puzzle
Wikipedia: The eight queens puzzle is the problem of placing eight chess queens on an 8Ă8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. so, write a program to solve this puzzle(or more, for nxn_chessboard!) (any language) And my try with python: https://code.sololearn.com/c8i3yc9kUN8T/?ref=app
8 Answers
+ 22
Here's (older one code):
https://code.sololearn.com/c07f6Kys8ip2/?ref=app
+ 8
My python oneliner :
(gives one solution)
https://code.sololearn.com/cOrHE7d7D969/#py
+ 4
My own go with Python, using bitwise operations and recursion, inspired by the following article: http://www.cl.cam.ac.uk/~mr10/backtrk.pdf
The code: https://code.sololearn.com/cTAZ853m9x69
(max grid size: 12, max number of solutions requested: 10)
+ 1
thanks @Thomas, your answer is pretty wellđ
0
Thank you :) The code could certainly use some error handling and a few comments here & there to explain what's being done, but glad you enjoyed it!