题目:
?
思路:分情况讨论,只要不要漏掉,就没什么问题。第一种情况某一个是对王,输出;第二种情况长度不相等且都不是炸弹,输出error;第三种长度相等,因为是排好序的,直接比较最后一张牌的大小,输出大的那个,这里我用了一个列表;第四种情况某一个为4个的炸弹,输出那个就好了
代码:
a,b = map(str,input().split('-'))
card1 = a.split(' ')
card2 = b.split(' ')
if card1 == ['joker', 'JOKER']:
print(a)
elif card2 == ['joker', 'JOKER']:
print(b)
elif (len(card1) != len(card2)) and (card1 != ['joker', 'JOKER']) and (card2 != ['joker', 'JOKER']) and (card1.count(card1[0]) != 4) and (card2.count(card2[0]) != 4):
print("ERROR")
elif (len(card1) == len(card2)) :
m = ['3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2']
c = m.index(card1[-1])
d = m.index(card2[-1])
if c>d:
print(a)
else:
print(b)
elif (card1.count(card1[0]) == 4) and (card2.count(card2[0]) != 4):
print(a)
elif (card1.count(card1[0]) != 4) and (card2.count(card2[0]) == 4):
print(b)
?
?
|