I found my error. ud =: i. , }:@}.@i.@- NB. added }:@ Also, the approach is very inefficient, but works, now.
On Wed, Dec 20, 2017 at 6:29 PM, Brian Schott <[email protected]> wrote: > I am getting the wrong answer for part 1 of day 13. > Can someone give me a hint what I am misunderstanding? > > My main verb is day13, but it depends on the following simple verbs. > > ud =: i.,}.@i.@- > spos =: [{.@:|."0 1 ud@] > (i. 6) spos"0/ ]3 2 0 0 4 0 4 > 0 0 0 0 0 0 0 > 1 1 0 0 1 0 1 > 2 0 0 0 2 0 2 > 1 0 0 0 3 0 3 > 0 1 0 0 2 0 2 > 0 0 0 0 1 0 1 > > > day13 =: verb define > ranges =. y > severity =. 0 > for_secs. i. # ranges do. > state =. secs spos"0 ranges > if. 0 = secs { state do. > if. secs{ ranges do. > severity =. severity+secs*secs{ranges > end. > end. > end. > severity > ) > day13 3 2 0 0 4 0 4 > 24 > day13 $.^:_1 datas > 2052 > > > > For more completeness, my data collection used the following ideas. > > datam =: data rplc ':';' ' > datas =: ({:|: ". ;._2 datam)({.|: ". ;._2 datam)} 1 $. 99 > > TIA, > > -- > (B=) > -- (B=) <-----my sig Brian Schott ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
