Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

(jeffa) 2Re: Trying to solve N-Queens

by jeffa (Bishop)
on Sep 09, 2002 at 19:37 UTC ( [id://196410]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://196410]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found