N-queens minimum and knights and bishops: Difference between revisions
Content added Content deleted
(Oops!) |
(→{{header|Go}}: Improvement for knights.) |
||
Line 128: | Line 128: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
This was originally a translation of the Wren entry but was substantially improved by [[User:Petelomax|Pete Lomax]] using suggestions from the talk page and has been improved further since then, resulting in an overall execution time of about |
This was originally a translation of the Wren entry but was substantially improved by [[User:Petelomax|Pete Lomax]] using suggestions from the talk page and has been improved further since then, resulting in an overall execution time of about 22.4 seconds. |
||
Timing is for an Intel Core i7-8565U machine running Ubuntu 20.04. |
Timing is for an Intel Core i7-8565U machine running Ubuntu 20.04. |
||
Line 252: | Line 252: | ||
} |
} |
||
if countSoFar <= maxCount { |
if countSoFar <= maxCount { |
||
si := |
si := ti |
||
sj := |
sj := tj |
||
if piece |
if piece == "K" { |
||
si = |
si = si - 2 |
||
sj = |
sj = sj - 2 |
||
if si < 0 { |
|||
si = 0 |
|||
} |
|||
if sj < 0 { |
|||
sj = 0 |
|||
} |
|||
} |
} |
||
for i := si; i < n; i++ { |
for i := si; i < n; i++ { |
||
Line 415: | Line 421: | ||
. . . . . . . . . . |
. . . . . . . . . . |
||
Took |
Took 22.383253365s |
||
</pre> |
</pre> |
||