Arc Forumnew | comments | leaders | submitlogin
2 points by jsgrahamus 3178 days ago | link | parent

These kinds of articles fascinate me for showing what is possible.

APL/K/J seem to epitomize this kind of code golf. Tried the J example on my phone and it worked. Don't have a clue as to how it works or what it is saying. From the comments on HN:

  queenst =: (, #: I.@,@(</)&i.)~ (] #"1~ [ */@:~:&(|@-/) {)&.|: ! A.&i. ]
This is the calculation, and you can output all 92 solutions for the 8 queens problems like this:

  queenst 8

  0 4 7 5 2 6 1 3
  0 5 7 2 6 3 1 4
  0 6 3 5 7 1 4 2
  ....
each column is a row number, and the integer is which column the queen is in, or vice versa on rows and columns. ,or print how many solutions $queens 92 8 $ gives the 'shape' of the array, that is 92 rows (solutions) x 8 columns (8-queens problem).

I wonder what the arc equivalent would be?



1 point by akkartik 3177 days ago | link

Yeah, somebody should write one and also add it to http://rosettacode.org/wiki/N-queens_problem

-----