PHP Array Sorting/Calculating
Budjetti $30-250 USD
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= "2d,2c,2s,2h,3s,4s,4h,5s,7s,8s,10s,11s,12s";
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.
Myönnetty käyttäjälle:
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
2 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön
hello, I can give you the solution. I have 3+ years of experience in web development. thanks!