Question: Question 7 - ( Hard ) ( worth 1 0 points - 2 points for getting the right output on the test data and another

Question 7-(Hard)(worth 10 points -2 points for getting the right output on the test data and another 8 for the hidden data - see the first page for more detail!)
In this question, we are looking at the poker hands. In this case, they are all 5 different card hands.
A poker hand has one of the following values:
Straight-flush: The hand is both straight and flush, see below
Four of a kind: There are 4 of some card rank
Full house: There are 3 of some card rank and two of another
Flush: All suits are the same (but it is not a straight-flush)
Straight: The card ranks are consecutive (e.g. the card ranks form the set {3,4,5,6,7}) OR the 5 cards ranks form the set {1,10,11,12,13}. Finally, the hand is not also a flush (because it would then be a straight-flush).
Three of a kind: There are 3 of a card rank
Two pairs: There are two of one card rank and two of another (but it is not a full house)
Pair: There are two of one card rank (but not any of the above)
High card: None of the above
While the above is the ordering of hands in poker (earlier being better), since we are not comparing hands but simply trying to find their value, it does not matter.
You are simply meant to, for each hand, determine its value. The output is supposed to be h id, handvalue 1, handvalue2, where handvalue 1 and handvalue 2 depends on the type of hand, see below:
Each hand which is a Straight-flush, Flush or Straight, should be such that handvalue 1= 'Straight' if the hand is straight and handvalue 1=' otherwise. Also, if it is a Flush, handvalue2= 'Flush' and handvalue2='' otherwise.
Each hand which is a Four of a kind, Full house, Three of a kind, Two pairs or pair, should be such that handvalue 1 is how many there are of the rank of which there are the most. Also, handvalue2 is how many there are of the rank of which there are the second most (or equivalently, how many ranks there are two or more of). E.g. Four of a kind has handvalue 1=4 and handvalue 2=1 and Full house has handvalue 1=3 and handvalue 2=2.
Each hand which is a High card has handvalue1= 'High' and handvalue2= 'Card'.
While it is unlikely to be a good idea to make just one view for this question (you could if you felt it was the better solution, but I am fairly sure it is not), one of the explicit challenges in this question is that there is no suggested set of views to make.
If you look in the public test data, each hand has its value written on it as a comment. So, e.g.(1,'Hearts',9),(10,'Hearts', 9
Question 7 - ( Hard ) ( worth 1 0 points - 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!