Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread Henry Rich
(p#n)&> applies (p#n) to each atom of t. (p&> # n&>) applies # to the results of p&> and n&> on the entirety of t. Both forms are valid J, but they do different things. Henry Rich On 12/4/2016 2:10 PM, Moon S wrote: (p&> # n&>) t NB. is ok too. So... why (p#n)&>t is not? And how to deal wi

Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread Moon S
(p&> # n&>) t NB. is ok too. So... why (p#n)&>t is not? And how to deal with this kind of problems? On Sun, Dec 4, 2016 at 8:18 PM, Moon S wrote: > OK, simple case > >t NB. three boxed strings > > ┌──┬──┬──┐ > > │22│33│44│ > > └──┴──┴──┘ > > p NB. test for all two's > > *./@('2' = ]) >

Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread Henry Rich
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 i

Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread Moon S
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

Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread 'Pascal Jasmin' via Programming
some solutions posted on wiki, n seems like a dangerous way to get the sectorID. Relies on fixed length of field and id 3 digits long. I don't know if that is a cause of error. (p&> t)#(n&> t) is ok (p # n)&> t is not The first one applies # to vectors. The 2nd to each cell. This normally

Re: [Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread Henry Rich
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.26NB. 'abc...z' c =: 5{.a\:[:+/"1 a=/[:/:~_10}.'-'-.~] NB. calculate c

[Jprogramming] [Jsoftware] AoC 2016 day 4

2016-12-04 Thread Moon S
I have this code: t =: cutLF CR-.~fread '04.dat' a =: a.{~97+i.26NB. '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