题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
import sys #创建字典识别字母大小 zd = { 'J':11, 'Q':12, 'K':13, 'A':14, '2':15, 'joker':16, 'JOKER':17 } #检查牌型大小 def check_pai(n): if len(n) == 2 and n[0] == 16: return n[0]*20 elif len(n) == 4 and n[3] == n[0]: return n[0]*20 else: return n[0] #输入与初始化 n = input().split('-') a = n[0].split() b = n[1].split() for i in range(len(a)): if a[i] not in zd: a[i] = int(a[i]) else: a[i] = zd[a[i]] for i in range(len(b)): if b[i] not in zd: b[i] = int(b[i]) else: b[i] = zd[b[i]] #排序并检查大小 a , b = sorted(a) , sorted(b) a1 , b1 = check_pai(a) , check_pai(b) #print(a1,b1) if len(a) != len(b) and (a1 % 20 != 0 and b1 % 20 != 0): print('ERROR') elif a1 > b1: print(n[0]) else: print(n[1])