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

Reply via email to