11
1
Background
Brag is a card game similar in concept to, but simpler than, poker. A hand in brag consists of three cards and is ranked as follows from highest to lowest:
Three of a kind - all three cards the same rank. Named as "three Kings" etc.
Running flush aka straight flush. All three cards of same suit and of consecutive ranks. The hand is named by the three cards in ascending order followed by the words "on the bounce" to distinguish from a simple run/straight, eg "ten-jack-queen on the bounce". Note an ace is either high or low but not both - "king-ace-two" is not a run.
Run aka straight. As above but without the requirement to match suits. Named simply as eg "ten-jack-queen".
Flush - all three cards the same suit, named after the highest rank eg "Ace flush".
Pair - two cards the same rank together with a third of another version rank. Named as "pair of threes" etc.
Any other combination, named after the highest rank eg "ace high".
Challenge
Given three playing cards, output the name of the brag hand they output.
The cards will be input either as three 2-character strings or concatenated as a single 6-character string (whichever your implementation prefers), where the first of each pair is the rank (2...9, T, J, Q, K, A) and the second signifies the suit (H, C, D, S).
Standard golfing rules apply - write a program or function which accepts this input and outputs the name of the hand as detailed above.
You can assume the input will be valid (ranks and suits in the above range, no repeated card) and in whatever case you prefer, but will not be in any particular order.
Output must be either in all capitals, all lower case, or a sensible capitalisation eg title case or sentence case. Numeric ranks should be spelled out eg "tens" not 10s.
Sample inputs & outputs:
2H3C2D => "pair of twos"
TD8C9C => "eight-nine-ten"
4SKS9S => "king flush"
4D4H4S => "three fours"
5H3H2C => "five high"
2D3DAD => "ace-two-three on the bounce"
6D6C6H => "three sixes"
This is my first attempt at a challenge on this site, please do suggest improvements but be gentle :)
3Related. Related. – Martin Ender – 2017-03-12T13:48:01.380
4
Welcome to PPCG! I've only skimmed the challenge so far, but it looks decent for a first challenge. That said, writing good challenges is hard and for the future I'd recommend posting ideas in the sandbox first where you can get feedback and improve details of the specification before risking downvotes, close votes and answers that might be invalidated by later changes to the challenge.
– Martin Ender – 2017-03-12T13:49:53.387@MartinEnder thanks! I'll certainly have been a look at the sandbox next time. – IanF1 – 2017-03-12T13:50:49.137
Can we get input as arrays of tuples? Also, can we shorten output like 'king flush' to 'fk'? – Matthew Roh – 2017-03-12T14:08:40.013
@MatthewRoh input as tuples, yes. Shortened output, no - the challenge isn't called "give a cryptic abbreviation of the brag hand" :) – IanF1 – 2017-03-12T14:20:44.243
@IanF1 Many languages seem to suffer the lack of compressing strings into shorter code- unless Jelly, of course – Matthew Roh – 2017-03-12T14:28:11.273
@MatthewRoh I'm not anticipating 6-byte answers :) – IanF1 – 2017-03-12T14:29:04.447
BTW, this doesn't look much different from other related challenges Martin posted. But I don't know if I should flag as a dupe. – Matthew Roh – 2017-03-12T15:31:46.253
@MatthewRoh Thanks for the feedback. I see it as a different balance between the two tasks involved - the calculation (what hand is this) and the efficient returning of strings, as the hands in this case are simpler than in poker. – IanF1 – 2017-03-12T15:35:14.853
@MatthewRoh btw if the community consensus is that it is a dupe, I'll understand. – IanF1 – 2017-03-12T15:39:01.080
@IanF1 The community consensus is, if it is easily solvable by editing an answer from another challenge, it's a dupe. But seeing those two 'Related' posts are not dupe hammered each other, I'm confused if I should dupe flag or not. – Matthew Roh – 2017-03-12T15:41:39.503
1please add
"6D6C6S"
as a test case since six is an odd plural – Not that Charles – 2017-03-16T21:39:17.490@NotthatCharles Great shout - adding this now! – IanF1 – 2017-03-16T22:08:35.620