Ralph G Selfridge wrote:

> Let me add that the APL finds ALL solutions, no rotations or
> symmetries, and written to print out on a typewriter. Somewhere
> in the code I think I have page width (quad PW), so that as many
> solutions as possible print across the page. Further you get a
> picture of the board, not just coordinate pairs.
> I'll make no attempt to get this to the forum.
> Ralph S

This inspired me to write a verb that creates diagrams from 
solution-permutations.

   NB. queens coded by Roger Hui; see N-queens essay on the J wiki.
   queens=: (, #: I.@,@(</)&i.)~ (] #"1~ [ */@:~:&(|@-/) {)&.|: ! A.&i. ]
   $ queens 8
92 8
   0 91 { queens 8
0 4 7 5 2 6 1 3
7 3 0 2 5 1 6 4
   boards=:' .Q'{~(~:/~8$0 1) >."2 2 (#&0 , 2 , 7&- # 0:)"0 queens 8
   $ boards
92 8 8
   0 91 { boards
Q. . . .
. . Q . 
 . . . Q
. . .Q. 
 .Q. . .
. . . Q 
 Q . . .
. .Q. . 
  
 . . . Q
. .Q. . 
Q. . . .
. Q . . 
 . . Q .
.Q. . . 
 . . .Q.
. . Q . 
 
This verb does not provide the most interesting features of Ralph's one-liner, 
but I happen to not be interested in integrating display and solution into a 
single line, nor in maximizing how many diagrams can be printed on a page.

The important thing for me, as an exercise, was doing this without either 
boxing or amending.
--
Tracy B. Harms

                    A good programming language is a conceptual universe
                    for thinking about programming.
                                                                                
Alan Perlis


      
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to