题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
from re import split import sys def is_bomb(xs): if len(xs)==4: if len(set(xs)) == 1: return True return False def compare(c1,c2): if c1 =='joker JOKER' or c2 == 'joker JOKER': return 'joker JOKER' cp1 = c1.split() cp2 = c2.split() if is_bomb(cp1) and not is_bomb(cp2): return c1 if is_bomb(cp2) and not is_bomb(cp1): return c2 if len(cp1) != len(cp2): return 'ERROR' dic = {x:index for index, x in enumerate(("3 4 5 6 7 8 9 1 J Q K A 2 j J").split())} if dic[c1[0]]> dic[c2[0]]: return c1 else: return c2 card_1, card_2 = input().split('-') print(compare(card_1,card_2))
把特殊条件全部去除后比较第一个单词就行