题解 | #扑克牌大小#

扑克牌大小

https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb

dic = {'3': 1, '4': 2, '5': 3, '6': 4, '7': 5, '8': 6, '9': 7, '10': 8, 'J': 9, 'Q': 10, 'K': 11, 'A': 12, '2': 12,
       'joker': 13, 'JOKER': 14}


def isJk(s):
    s = ' '.join(s)
    if s == 'joker JOKER':
        return True

def isboom(s):
    if len(set(s)) == 1 and len(s) == 4:
        return True

tmp = input().strip().split('-')
l = tmp[0].split()
r = tmp[1].split()

if len(l) == len(r):
    if dic[l[0]] <= dic[r[0]]:
        print(' '.join(r))
    else:
        print(' '.join(l))
elif isJk(l):
    print(' '.join(l))
elif isJk(r):
    print(' '.join(r))
elif isboom(l) and isboom(r):
    if dic[l[0]] < dic[r[0]]:
        print(r)
elif isboom(l):
    print(' '.join(l))
elif isboom(r):
    print(' '.join(r))
else:
    print('ERROR')


全部评论

相关推荐

07-30 13:50
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务