difficult problem

Discussion in 'Programmer's Corner' started by braddy, Mar 12, 2006.

  1. braddy

    Thread Starter Well-Known Member

    Dec 29, 2004
    I have a serious problem to understand to code a task.

    we have a set of 5 cards like:

    nine of hearts
    queen of hearts
    ten of hearts
    jack of hearts
    king of hearts

    we are ask to code the task according to the following characteristic:

    straight flush (5 cards in sequence*, all of the same suit) has a value of 10 points.

    *sequence is 2,3,4,5,6,7,8,9,10,jack,queen,king with ace considered as either before 2 or after king as needed.

    The set above has a value of 10 pts.
    I have suceeded to count the number of suits, but how can I work out the sequence part??

    Can help me please?
  2. CoulombMagician

    Active Member

    Jan 10, 2006
    The cards are identified by character strings. Use string functions from one of the libraries to determine the suit and number of each card. Create a 2x5 array to hold the numeric and suit values of the cards in the hand. Then you can perform numerical tests for things like straights, full house etc. and a numeric or character test to test for flushes.