Sorting/counting Array -- Will Pay

Discussion in 'PHP' started by dfreeman, Jun 12, 2009.

  1. #1
    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

    I'll pay $30 to whoever can make a function for this.

    Thanks
     
    dfreeman, Jun 12, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    I do not play cards, so I do not understand the requirements. If you can provide detailed instructions and definitions to the game nomenclature, I will take a look at it. Sorting and counting array items is easy, but I need to know the requirements of course.
     
    Social.Network, Jun 12, 2009 IP
  3. Nasukai

    Nasukai Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If the cards that are needed to be removed are already set as an array within the script, then I can do this for you. If not, you will need to explain it better for me because I don't play cards either. I've sent you a PM with my portfolio.
     
    Nasukai, Jun 12, 2009 IP
  4. dfreeman

    dfreeman Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry guys, someone is already working on this. If he doesn't make it, I'll post again and choose amongst the posters.

    Thanks a lot.
     
    dfreeman, Jun 12, 2009 IP
  5. eyes_drinker

    eyes_drinker Member

    Messages:
    224
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #5
    looking forward
     
    eyes_drinker, Jun 12, 2009 IP
  6. dfreeman

    dfreeman Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    OK. If anyone else would like to try this, please let me know.

    Some 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.

    Thanks
     
    dfreeman, Jun 13, 2009 IP