Yes:

gc=:(1;(0 10#:10*".;._2]0 :0);'<!>'i.a.)&;:
 2.0 1.1 1.1 1.1 NB. 0: end of garbage
 2.3 1.0 1.0 1.0 NB. 1: not garbage
 2.0 3.0 0.0 2.0 NB. 2: garbage
 2.0 2.0 2.0 2.0 NB. 3: cancelled garbage
)

cg=:(1;(0 10#:10*".;._2]0 :0);'<!>'i.a.)&;:
  1.0 0.0 0.0 0.0 NB. 0: not garbage
  2.1 3.0 0.0 2.1 NB. 1: start of garbage
  2.0 3.3 0.3 2.0 NB. 2: in garbage
  1.0 1.0 1.0 1.0 NB. 3: cancelled garbage
)


score=:3 :0
  stream=. gc y
  +/('{'=stream)#+/\-/'{}'=/stream
)

Part 1 was
   score input

Part 2 was
   #cg input

Thanks,

-- 
Raul


On Sat, Dec 9, 2017 at 4:35 PM, Jimmy Gauvin <[email protected]> wrote:
> Hi all,
>
> has anybody used the Sequential Machine ;: to solve this problem?
> It seems like a natural fit.
>
>
>
> On Sat, Dec 9, 2017 at 1:48 PM, David Lambert <[email protected]> wrote:
>
>> Small victory!  I guessed that part 2 would address the chaff.
>>
>>
> ----------------------------------------------------------------------
> 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