2011-05-22, 01:44 AM
Sorry about the double post, but this irked me.
When you're looking for a straight, there are a limited number of straights that can exist. And a straight must always be through a line (unless you want a weird straight like Q K A 2 3). So I think it would be far better to do this
PSEUDOCODE:
I don't know if this helps you with your problems, but it's a different way to approach it in a much more logical manner than checking next and previous cards in an array.
When you're looking for a straight, there are a limited number of straights that can exist. And a straight must always be through a line (unless you want a weird straight like Q K A 2 3). So I think it would be far better to do this
PSEUDOCODE:
Code:
hand = GetHand()
numCardsInStraight = 0
cardTypes = [2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A]
For eachCardType in cardTypes:
if eachCardType in hand:
numCardsInStraight += 1
else:
numCardsInStraight = 0
if numCardsInStraight == 5:
return True
return FalseI don't know if this helps you with your problems, but it's a different way to approach it in a much more logical manner than checking next and previous cards in an array.
