PHP Array Sorting/Calculating

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.

\$cardleft= &quot;2d,2c,2s,2h,3s,4s,4h,5s,7s,8s,10s,11s,12s&quot;;

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:

2d,2c,2h

2s,3s,4s,5s,

10s,11s,12s

The remaining cards should be:

4h,7s,8s

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)

Some cases:

example case 1:

1c,2c,3c,3d,3h

returns lowest value = 1c,2c

example case 2:

1c,1d,1h,2h,3h

returns lowest value = 1c,1d,

example case 3:

1h,2h,3h,4d,4h,4s,5h,6h

returns lowest value = 4d,4s

example case 4:

1h,2h,3h,4d,4h,4s,5h,6h,7h

returns lowest value =0

example case 5:

1c,1d,1s,1h,2h,3h

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.

Taidot: PHP

( 1 review ) New Territory, Hong Kong

Projektin tunnus: #451175

Myönnetty käyttäjälle:

mentallysafe

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

50 \$ USD 0 päivässä
(2 arvostelua)
1.8

2 freelanceria on tarjonnut keskimäärin 40 \$ tähän työhön

laserlight

hello, I can give you the solution. I have 3+ years of experience in web development. thanks!

30 \$ USD 1 päivässä
(0 arvostelua)
0.0