8 queens algorithm

Правка en2, от I_love_Eva_Green, 2019-04-13 07:08:40

Hi. In the college we are looking at two basic examples of backtracking (sudoku and n-queens) and a question arose: How program the algorithm of the 8 queens in a non-recursive way?

more specifically it must be done through a stack or through a queue counting the steps to reach the solution.

My problem is born with the code they give us and with the algorithm itself (here). I understand that du and dd are the main diagonals but I do not understand the line 16... (specifically du [c + 7 -r]) where that seven comes from(should not move one square per diagonal?).

Теги #backtracking, #algorithms

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский I_love_Eva_Green 2019-04-13 07:08:40 459 Tiny
en1 Английский I_love_Eva_Green 2019-04-13 04:50:00 207 Initial revision (published)