题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
a, b = input().strip().split('-')
poker_map = {
'2': 15, '3': 3, '4': 4, '5': 5,
'6': 6, '7': 7, '8': 8, '9': 9, '10': 10,
'J': 11, 'Q': 12, 'K': 13, 'A': 14,
'joker': 15, 'JOKER': 16
}
# type
# 1 -- 1,2,3,5
# 4 -- 4
def get_type(s):
if len(s) in [1, 3, 5]:
return 1
if len(s) == 2:
return 1 if 'joker' not in s else 4
return 4
def compare(a, b):
sa, sb = a.split(' '), b.split(' ')
if not isinstance(sa, list):
sa = [sa]
if not isinstance(sb, list):
sb = [sb]
ta, tb = get_type(sa), get_type(sb)
if ta == 4:
if tb != 4: return a
if 'joker' in a: return a
if 'joker' in b: return b
return a if poker_map[sa[0]] > poker_map[sb[0]] else b
if ta == 1:
if tb == 4: return b
if len(sa) != len(sb): return "ERROR"
return a if poker_map[sa[0]] > poker_map[sb[0]] else b
print(compare(a, b))

