Here it is:

   1j1 # 1j3 #”1 (,~ ,. [)/ 'RELIOPS'
S P O I L E R
P P O I L E R
O O O I L E R
I I I I L E R
L L L L L E R
E E E E E E R
R R R R R R R


   p=: ] ,"1 0 i.@[ -. ] + (i:1) */~ #\.@]
   q=: ;@:(<@p"1)^:[&'' f.
   #q 8
92
   scr <'q'
32

It uses a breadth-first search.
p takes a vector argument and appends every possible next position to it.
q calls p on each vector in its right argument, and collects all the results 
into
a matrix / table. Since the number of queens in each vector grows by 1 at
each iteration, p must be called N times, starting with an empty vector.

Good luck,
Louis

> On 21 Aug 2016, at 00:49, Louis de Forcrand <[email protected]> wrote:
> 
> Alrighty then.
> 
> Let’s start this off with a couple of rules:
> - We can either count characters or tokens; I suggest tokens.
>  Either one should be counted on fixed (f.) functions.
> - Programs can be restricted to either tacit or explicit, or not.
>  In the latter case counting tokens would be ambiguous, so I
>  don’t think the two should be used together.
> 
> Of course this could change from task to task, and should be clarified
> at the beginning of new challenges.
> I won’t be coming up with all of the challenges; you should make some
> up too.
> 
> 
> Without further ado, here is a simple first challenge:
> Write a verb which takes a scalar N, and returns all solutions to the
> N-Queens problem in the form of a rank-2 array of rank-1 permutation
> vectors. Given a vector V, the queens’ coordinates are:
> 
>       (,.~ i.@#) V
> 
> This can be done because we know that no two queens can be
> placed on the same row.
> 
> I suggest counting tokens of tacit solutions using this verb:
> 
>       scr=: #@;:@(5!:5)       NB. score verb: scr ‘foo’ ; ‘bar’ ; ‘baz’
> 
> If you have a better suggestion for scoring or rules, feel free to chime in.
> In addition, if you feel your version is particularly elegant, or efficient,
> or posses any other attribute you deem worthy, please share it with us,
> even if it is does not have an especially low score.
> 
> I will be posting my contender soon.
> 
> Cheers,
> Louis
> 
> 
>> On 20 Aug 2016, at 21:47, Joe Bogner <[email protected]> wrote:
>> 
>> Hi! Welcome. I think this is the right place.
>> 
>> Source: http://www.jsoftware.com/forums.htm
>> 
>> On Aug 20, 2016 3:35 PM, "Louis de Forcrand" <[email protected]> wrote:
>> 
>>> Hi everyone,
>>> 
>>> Would this be the appropriate place for some Jolfing (J code golfing),
>>> or is there a better place for this?
>>> 
>>> Thanks,
>>> Louis
>>> 
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to