in reply to Re: Trying to solve N-Queens
in thread Trying to solve N-Queens

"I also think than a single loop might improve performance slightly."

Yep, and it is more simple as well:
sub mark_attacks { my ($r,$c,$array) = @_; my ($u,$d) = ($r,$r); # to be removed - just for visualization during debugging $array->[$r]->[$c] = 'Q'; for ($c+1..$size-1) { $array->[$r]->[$_] = 0; $array->[--$u]->[$_] = 0 if $u > 0; $array->[++$d]->[$_] = 0 if $d < $size-1; } }
Thanks for the tips. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)