My question is very similar to "How do I return a group of sequential numbers that might exist in an array?".
I need to find a way to check if a given array of numbers (card values basically) is a poker straight, or simply return the longest sequence.
As Mr. Thomas suggested, each_cons
works well, but in Texas Holdem, straight is not only 2, 3, 4, 5, 6 or 8, 9, 10, J, Q, but K, A, 2, 3, 4 also.
If we have figures signed as numbers I think it will make everything easier: J will be 11, Q will be 12 and so on.
Any idea how to achieve this?