|
-
January 17th, 2011, 10:07 AM
#1
Detecting Unique combinations of sequential numbers
Hello all,
Long time lurker, first time poster here. My thanks in advance to everyone!
I am trying to fool around something on my own (no I'm not a college student looking for someone to do my work for me etc).
Ive come across a problem I'd really like to solve, and for some reason cannot seem to come up with any kind of workable solution. Pointers gently nudging me (or shoving me even) in the right direction are very much appreciated!
Now down to the problem at hand:
I am trying to write a cribbage game. Its a game I enjoy, and one which is testing my skills very well. The problem Im having is scoring unique combinations of sequential numbers within a 5 element array. So the question is:
Given a random selection of five numbers from a known range (1 - 14) occurring a known number of times in the 'pool' (4 times each) how can one determine the number of unique 3 or more numeric sequences, assigning 1 'point' per number?
For example:
Given a single dimensional array holding the numbers
1, 1, 2, 2, 3
you have four separate series of sequential numbers where at least one of the numbers is replaced every time.
if you identify the array elements alphabetically from a to e the distinct combinations would be
a,c,e
a,d,e
b,c,e
b,d,e
giving 1 point to each element in the sequence, you should come out with 12.
Conversely, if you had a 5 element array of
1237910
the only distinct combination would be abc, for 3.
Any suggestions/nudges/ slaps over the head in the right direction?
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
|