Name the Brag Hand
Python 2, 788, 715, 559, 556, 554, 546, 568, 522 bytes
*now passes the 'sixes' * thanks to Ben Frankel for saving 46 Bytes!
import re
d,m,n=dict(zip('JQKA',range(10,15))),'pair of %ss','%s-%s-%s'
C=lambda s:int(d.get(s[0],s[0]))
z,x,c=sorted(re.findall('..',raw_input()),key=C)
q,w,e=C(z),C(x),C(c)
A=[0,0,'two','three','four','five','six','seven','eight','nine','ten','jack','queen','king','ace']
I,O,U=A[e],A[w],A[q]
a,k='%s high'%I,e-w+q
if k==13:a=n%(I,U,O)
if k==w:a=n%(U,O,I)
if q==w or e==w or e==q:a=m%O
if k==e==w:a='three %ss'%I
if'x'in a:a=a[:-1]+'es'
if z[-1]==x[-1]==c[-1]:
if'-'in a:a+=' on the bounce'
else:a='%s flush'%I
print a
Try it online!
Thanks for a cool first challenge!
PHP, 413 405 398 409 408 406 398 bytes
Unfortunately, PHP does not support nested array referencing inside strings;
that would have saved another 6 5 bytes.
for(;$a=$argn[$i++];)$i&1?$v[strpos(_3456789TJQKA,$a)]++:$c[$a]++;$k=array_keys($v);sort($k);$n=[two,three,four,five,six,seven,eight,nine,ten,jack,queen,king,ace];echo($m=max($v))<2?($k[!$d=count($c)]+2-($h=$k[2])?$k[1]>1|$h<12?"$n[$h] ".[flush,high][$d++/2]:"ace-two-three":$n[$k[0]]."-".$n[$k[1]]."-$n[$h]").[" on the bounce"][$d^1]:($m<3?"pair of ":"three ").$n[$v=array_flip($v)[$m]].e[$v^4].s;
Run with echo <hand> | php -nR '<code>
or test it online.
breakdown
for(;$a=$argn[$i++];)$i&1? # loop through input
$v[strpos(_3456789TJQKA,$a)]++ # count values on even positions [0,2,4]
:$c[$a]++; # count colors on odd positions [1,3,5]
$k=array_keys($v);sort($k); # $k=ascending values
$n=[two,three,four,five,six,seven,eight,nine,ten,jack,queen,king,ace];
echo($m=max($v))<2 # three different values:
?($k[!$d=count($c)]+2-($h=$k[2]) # test normal straight ($d=color count, $h=high card)
?$k[1]>1|$h<12 # test special straight
?"$n[$h] ".[flush,high][$d++/2] # flush if one color, high card if not
# ($d++ to avoid " on the bounce")
:"ace-two-three" # special straight
:$n[$k[0]]."-".$n[$k[1]]."-$n[$h]" # normal straight
).[" on the bounce"][$d^1] # if straight: straight flush if one color
:($m<3?"pair of ":"three ") # pair or triplet
.$n[$v=array_flip($v)[$m]] # card name
.e[$v^4].s # plural suffix
;
Requires PHP>=5.6 (for e[...]
)
Ruby, 384, 320
Accepts an array of two-char strings.
Translates the pip values into hex values and identifies hands based on how many distinct pip values there are.
->*d{u=d.map{|x|*u=x[1]}==u*3
g=d.map{|x|(x[0].tr'TJQKA','ABCDE').hex}.sort
g=1,2,3if[2,3,14]==g
_,l,h=a=g.map{|x|%w{king queen jack ten nine eight seven six five four three two ace}[-x%13]}
[*g[0]..2+g[0]]==g ?a*?-+(u ?' on the bounce':''):u ?h+' flush':[h+' high','pair of '+l+=l[?x]?'es':?s,'three '+l][-g.uniq.size]}
Annotated:
->*d{
# u is "Is this a flush?"" (see if you have more than one suit)
u=d.map{|x|u=x[1]}==[u]*3
# g is the sorted card values in integer (convert to base 16)
g=d.map{|x|x[0].tr('TJQKA','ABCDE').hex}.sort
# use Ace == 1 if we have a low straight
g=[1,2,3]if[2,3,14]==g
# a is the names of all the cards
a=g.map{|x|%w{ace two three four five six seven eight nine ten jack queen king ace}[x-1]}
# l is for "plural" - just choose the middle card because we
# only care about plurals for 2s or 3s
l=a[1].sub(?x,'xe')+?s
# if [g[0],g[0]+1,g[0]+2] == g, we have a run
# possibly "on the bounce"
([*g[0]..g[0]+2]==g) ? (a * ?-) + (u ? ' on the bounce' : '') :
# if we have a flush, we can't have three-of-a-kind, so try that first
u ? a[2]+' flush' :
# otherwise, dedupe your hand. if there's:
# 3 values, x high; 2 values, pair; 1 value, three
[a[2]+' high','pair of '+l,'three '+l][-g.uniq.size]
}