Removing needless code:
cribpairs =: 3 : '+/ 0 0 2 6 12 {~ #/.~ y'
Henry Rich
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Henry Rich
> Sent: Friday, September 26, 2008 8:12 AM
> To: 'Programming forum'
> Subject: RE: [Jprogramming] Longest run from a list
>
> Working on your problem rather than your question:
>
> cribruns =: 3 : '{: 0 -.~ 3 4 5 ([ * +/@:(*/\))"0 _ <:
> #/.~ y ,~ i. 13'
> cribpairs =: 3 : '+/ 0 0 2 6 12 {~ <: #/.~ y ,~ i. 13'
> cribruns 1 1 3 3 2
> 12
> cribpairs 1 1 1 3 2
> 6
>
> Fifteens and his nobs left to you.
>
> Henry Rich
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Moore
> > Sent: Friday, September 26, 2008 7:04 AM
> > To: J Programming
> > Subject: [Jprogramming] Longest run from a list
> >
> > I've got a sorted list of numbers, and I want to find the
> longest run
> > of consecutive integers:
> >
> > 2 4 5 6 12 --> 3
> > 1 2 3 4 5 6 --> 6
> >
> > Other constraints ensure that there will only ever be 1
> such run (for
> > example 2 3 4 6 7 8, with 2 runs of 3, is not possible). However,
> > duplicates are: 1 12 13 13 14 - the longest run here is
> length 3. For
> > extra credit, I need to know about the duplicates (so that I can
> > calculate how many combinations make a run of 3).
> >
> > To save people guessing, this is scoring the runs in a
> Cribbage hand.
> >
> > I can see some ways of doing this, using shifts, increments and
> > comparisons, but things get more complex than I can fathom before I
> > reach a solution :-)
> >
> > Paul.
> >
> ----------------------------------------------------------------------
> > 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