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
