题解 | 扑克牌大小

import sys

def get_value(val):
    val_dict = {'JOKER':16, 'joker':15, 'J':11, 'j':11, 'Q':12, 'q':12, 'K':13, 'k':13, 'A':14, 'a':14}
    if val.isdigit():
        return int(val)
    return val_dict[val]

def get_group(lst):
    if len(lst) == 4 or len(lst) == 2 and lst[0] > 13:
        return 'bomb'
    group_dict = {1:'single', 2:'double', 3:'triple', 5:'continous'}
    return group_dict[len(lst)]

def compare_group(lst_a, lst_b, a, b):
    if lst_a[0] > lst_b[0]:
        return a
    return b

  
raw_input = []
for i,line in enumerate(sys.stdin):
    raw_input.append(line.strip())
    if i == 1:
        break

x, y = raw_input[0].split('-')
x_lst, y_lst = [get_value(i) for i in x.split(' ')], [get_value(i) for i in y.split(' ')]
group_x, group_y = get_group(x_lst), get_group(y_lst)
if group_x == group_y:
    print(compare_group(x_lst, y_lst, x, y))
elif group_x == 'bomb':
    print(x)
elif group_y == 'bomb':
    print(y)
else:
    print('ERROR')

全部评论

相关推荐

05-18 22:32
已编辑
中南大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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