|
-
January 18th, 2011, 08:17 AM
#2
Re: Detecting Unique combinations of sequential numbers
I'm sure there's a nice mathematical way of doing this, but since no-one has replied with one yet, here's a brute-force type of way to deal with it.
Do a loop through the pool of numbers, for each of those loop do another loop through the rest of the numbers to find one that is next in sequence (e.g. if number is '4' look for '5'). If it finds one then it loops again looking for the next highest number until it runs out of numbers.
Some csharp/pseudo type code:
int[] pool = array(1,1,2,2,3); //array containing numbers pool
for each number in pool as numA
{
for each number in pool as numB
{
if numB = numA + 1 then ... //you've found a match, loop again looking for another match.
}
}
It's not direct code since you seem to want a nudge/suggestion more than just an answer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|