+ 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

20th Jan 2018, 6:11 PM
SMhd Asadi
SMhd Asadi - avatar
8 Answers
20th Jan 2018, 11:32 PM
LukArToDo
LukArToDo - avatar
+ 8
My python oneliner : (gives one solution) https://code.sololearn.com/cOrHE7d7D969/#py
22nd Jan 2018, 1:37 AM
CĂ©pagrave
CĂ©pagrave - avatar
+ 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)
20th Jan 2018, 9:17 PM
Thomas
+ 1
thanks @Thomas, your answer is pretty wellđź‘Ś
20th Jan 2018, 9:21 PM
SMhd Asadi
SMhd Asadi - avatar
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!
20th Jan 2018, 9:23 PM
Thomas
6th Jun 2018, 1:35 PM
Hasanka Amarasinghe
Hasanka Amarasinghe - avatar