(+/\"1 ]0,.15+#:i.2^14) is a noun, an array of integers with shape 16384 15

   $(+/\"1 ]0,.15+#:i.2^14)
16384 15
   datatype(+/\"1 ]0,.15+#:i.2^14)
integer

Now that we know this solves PE18 14 are the number of rows in the triangle, and (+/\"1 ]0,.15+#:i.2^14) cleverly are indexes of all paths through the triangle from top to bottom.


If t is a verb the sentence is a syntax error because the rightmost and even tines of a fork must be verbs (or trains, but cannot be nouns).

Let's assume t is a noun, there are no trains to consider and the verbs act on t leftward.
Now that we know this is PE18,
t=:>75;95 64;17 47 82;18 35 87 10;20 04 82 47 65;19 01 23 75 03 34;88 02 77 73 07 63 67;99 65 04 28 06 16 70 92;41 41 26 56 83 40 80 70 33;41 48 72 33 47 32 37 16 94 29;53 71 44 65 25 43 91 52 97 51 14;70 11 33 28 77 73 17 78 39 68 17 57;91 71 52 38 17 14 91 43 58 50 27 29 48;63 66 04 68 89 53 67 30 73 16 69 87 40 31;04 62 98 27 23 09 70 98 73 93 38 53 60 04 23

A =: ravel t (,t) is a 1 dimensional vector of atoms.
B =: (+/\"1 ]0,.15+#:i.2^14) from A (dyadic {) has the shape of the left argument (x) consisting of items of A (y). B has shape 16384 15. +/"1 means to insert + between the columns of B. (add the rows) (giving a vector of weighted path lengths)
C =: +/"1 B
Finally, >./ C inserts (/) larger of (>.) between the items of this vector, yielding the maximum which is the PE 18 solution. I suppose you'll want (+/\"1 ]0,.15+#:i.2^14) explained.


Suppose we wanted a solution through the first 5 rows, the indexing array would be as follows where the factor of 5 accounts for the fills created by opening the linked (dyadic ;) rows of the triangle. You can investigate this piece by piece interactively by successively evaluating
2^4   NB. 2 to the power of 4
i.2^4  NB. integers
#:i.2^4   NB. base 2 representation of each of these
5+#:i.2^4
0,5+#:i.2^4
(+/\"1)0,5+#:i.2^4  NB. sum scan along rows


   (+/\"1 ]0,.5+#:i.2^4)
0 5 10 15 20
0 5 10 15 21
0 5 10 16 21
0 5 10 16 22
0 5 11 16 21
0 5 11 16 22
0 5 11 17 22
0 5 11 17 23
0 6 11 16 21
0 6 11 16 22
0 6 11 17 22
0 6 11 17 23
0 6 12 17 22
0 6 12 17 23
0 6 12 18 23
0 6 12 18 24

Date: Tue, 6 Jan 2015 17:14:49 +0300
From: "oventarb oventarb"<[email protected]>
To:[email protected]
Subject: [Jprogramming] Help me understand line of code:
Message-ID:<[email protected]>
Content-Type: text/plain; charset="utf-8"; format="flowed"

Help me understand line of code:

>./ +/"1 (+/\"1 ]0,.15+#:i.2^14){,t

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

Reply via email to