3 1(1) is the shape of the result block, which contains the result of(p # n)&>t [you can see this for yourself by setting tooltip detail to 'Tutorial' and hovering over the components of 3 1(1)]

The (1) indicates that fill was added to the result, bring the shape up to 1.

The crosshatching in the result indicates where the fill was added to the result.

p and n don't show results yet because they are being applied to multiple cells as part of (p # n) and there is no guarantee that the results of the individual cells can be assembled into an array. If you click on the result of #, that will select an individual cell, and you can then see what p and n contributed to that result.

If you want to see what p is doing, select a single result-cell of p and then right-click the name p, to get a dissection of that name.

Henry Rich








On 12/4/2016 1:18 PM, Moon S wrote:
OK, simple case

    t  NB. three boxed strings

┌──┬──┬──┐

│22│33│44│

└──┴──┴──┘

   p  NB. test for all two's

*./@('2' = ])

   n  NB. append zero and cvt to number

".@('0' ,~ ])

   (p&>t)#(n&>t)  NB. ok

220

   (p # n)&>t  NB. zero-padded

220

0

0

dissect doesn't show anything for p and n in the second case; and what's "3
1(1)" for '#'?

http://mas.orgfree.com/adventofcode2016/diss1.png



On Sun, Dec 4, 2016 at 6:14 PM, Henry Rich <henryhr...@gmail.com> wrote:

I have no time to help, other than to suggest you use dissect to see
what's happening.

Henry Rich


On 12/4/2016 11:02 AM, Moon S wrote:

I have this code:

t =: cutLF CR-.~fread '04.dat'
a =: a.{~97+i.26                        NB. 'abc...z'
c =: 5{.a\:[:+/"1 a=/[:/:~_10}.'-'-.~]  NB. calculate checksum string
v =: c -: _1}._6&{.                     NB. checksums match = good string
n =: [:".3{._10{.]                      NB. extract number (id)
s =: 4 :'((26|x+])&.(_97+a.i.]))"0 y'   NB. shift cypher, n s 'str'
p =. +./@('north' E. n s ])             NB. if decrypted string contains
'north'
echo +/(n*v)&> t                        NB. sum of ids of good strings
echo +/(n*p)&> t                        NB. sum of ids of strings with
'north'
exit 0                                        NB. ^^^ we assume such
string
is only one

It works, but I planned to use '#' instead of +/...*... for the second
task.

Verb n takes a number from a string.
Verb p decrypts a string using the number and tells if it contains
'north'.
So far so good.
Noun t is the input data as boxed strings.
n&> t  gives numbers (like 111 222 333 444)
p&> t  gives a boolean vector (like 0 0 1 0)
The idea was to have something like "(p # n)&> t" but that didn't work.
(p&> t)#(n&> t) is ok
(p # n)&> t is not
Something wrong with ranks, I guess. Any idea how to use (p # n)?

Thank you.
Georgiy Pruss
----------------------------------------------------------------------
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