2011-05-24, 04:05 AM
Kalovale Wrote:I see. It's essentially the same approach I used for determining quads, trips, full houses and other stuff: the unique number of occurrences of a certain target.
So just to be clear on the idea, you will start the "combo" count, for lack of better words, once an eachCardType in the array of length 13 can be found in the hand, then increment it each time that event takes place again, terminate once it is false (so that 2, 3, 4, 5, 8 don't make a straight) and start a new count again, which will never reach the desired number 5.
Am I reading that right?
I'll have to think of a way to deal with A, 2, 3, 4, 5 in that case though. It gives ultimately the same output but I much prefer it since I don't have to change the hand that was supposed to be randomly generated.
Yeah. For example, if your hand is 2 2 3 4 6, logic goes
2: in hand -> numCards += 1 (to 1)
3: in hand -> numCards += 1 (to 2)
4: in hand -> numCards += 1 (to 3)
5: not in hand -> numCards = 0
6: in hand -> numCards += 1 (to 1)
7: not in hand -> numCards = 0
8: not in hand -> numCards = 0
9: not in hand -> numCards = 0
10: not in hand -> numCards = 0
J: not in hand -> numCards = 0
Q: not in hand -> numCards = 0
K: not in hand -> numCards = 0
A: not in hand -> numCards = 0
Since numCards is never 5, it then returns false.
As for A2345, if that's a valid straight, you just make the array {A, 2, 3, ...} and it should work out okay. Doesn't matter that the array duplicates itself on the ends.

