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 28.2 seconds.
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 := 0
si := ti
sj := 0
sj := tj
if piece != "K" {
if piece == "K" {
si = ti
si = si - 2
sj = tj
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 28.174576435s
Took 22.383253365s

</pre>
</pre>