Avatar billede di8leva Nybegynder
31. marts 2005 - 11:46 Der er 1 løsning

Extracting a Pokerhand from a string

I have a String looking like this "cXcXcXcXcX" where c = the color of the card (s = spades, h = hearts, d = diamonds, c = clubs) and X = the value of the card (where T = 10, J = 11, Q = 12, K = 13, A = 14)
The String is always sorted in ascending order (and is actually a Vector with five objects (Card) from start, so that can also be used)

And from this I need to extract what hand I have.
And I just cannot find a good, fast way of doing this.

Do you have ideas or examples for this?

The result I need from "h2h3h5h7hQ" is 10 (hand-position, right now 10 = flush, 11 = full house, etc, but any integer will do, I can change it later on) combined with a String of the hand-value (showing the important cards), in important-descending order (in this example "Q7532").

Another example, to show what I mean with hand-value is a pair-hand
"h2c2s8s9dA" -> 6 (because pair has the hand-position-value 6 in my system) combined with "22A98".
The reason that 2 comes before A in this hand-value is that you first look at the cards building up the pair, and then you can look at the "kickers".

This is later used for comparison with other hands.
Avatar billede di8leva Nybegynder
01. april 2005 - 11:13 #1
Managed to solve it quite easily.... just needed to think some... :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester