Andrew Nikitin wrote:

>    fn2 =: {. (|[EMAIL PROTECTED] , }.) ]
>    6!:2 't10=.>./ <:([EMAIL PROTECTED] #@(fn2^:(<_))@:>:@A. i.) 10'
> 83.2398
>    t10
> 38
>

Andrew:

I somehow missed your solution in my inbox: I've just see it in the
archives.  Mine is obviously very similar, but was separately conceived.

> Also, they say "first 30 permutatuons" and in test file those permuataions
> are listed in some strange order which I do not have any motivation to
> decode. It's not lexicographic, that is for sure. Probably, some of the
> various "least change".
>

The issue is that you are supposed to implement a particular algorithm,
and the first 30 permutations is an artifact, presumably to check that you
really used the algorithm.  I ignored this.

The problem is that the site administrators regard the algorithm as
language-neutral, when it is not.  In particular, J will lose out if it is
forced to apply functions to small arguments.

Let me give an example of the non-neutrality of algorithms.  Consider the
language I will euphemistically call BF as compared with C.  Suppose you
had to implement an algorithm for calculating the sum of n numbers.  The
Shootout people would regard the obvious algorithms as O(n).  However, in
BF, adding a+b is O(a+b), since it stores a by incrementing 0 a times.  If
you think this is bogus, consider arbitary precision integers in a
sensible language stored as an array of machine integers, where a+b is
O(log ab).

A more sensible contest would allow programmers to use algorithms
appropriate to their language.  Specific algorithms are never
language-neutral.

Best wishes,

John


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

Reply via email to