I'm creating a simple card game but stalled with the final function. Sorting the cards after a game.
I need help to sort out an array of card. Remove flush, same card ranks.
I have to remove from an array the flush with more than 2 cards and 3 or 4 cards with the same ranks(trio or cuadro); if cuadro, check if one of them can use in the flush. The remaining is the final count of the cards.
In the example above I have to remove:
The remaining cards should be:
Some more details
The cards are already set in the array... all it needs is sorting out.
The goal of the game is to have the lowest possible value... zero would be the lowest.
Remove 3 or more flushes from the array.
Remove 3 or 4 same value from the array.
Cannot reuse a card. (if you use the card in a flush, you can't use it to get 3 of a kind with the same card)
example case 1:
returns lowest value = 1c,2c
example case 2:
returns lowest value = 1c,1d,
example case 3:
returns lowest value = 4d,4s
example case 4:
returns lowest value =0
example case 5:
returns lowest value = 0
The tricky part is WHERE to use a card when it is possible to use it either with flush or trio. It should be use where it would output the lowest possible card values to be left, see above cases.
I'm an expert in game algorithmics, if that matters. I'll be able to write your function ( fully working ) in less than a day. Hope I'll hear from you. Cheers, MentallySafe