题解 | #扑克牌大小#

扑克牌大小

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

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


while 1:
    try:
        cmp1, cmp2 = input().split('-')
        cmp1 = cmp1.split()
        cmp2 = cmp2.split()

        if set(cmp1) == {'JOKER', 'joker'}  or set(cmp2) == {'JOKER', 'joker'}:
            print('joker', 'JOKER')
        
        elif (len(cmp1) == 4 and len(set(cmp1)) == 1) or (len(cmp2) == 4 and len(set(cmp2)) == 1):
            if (len(cmp1) == len(cmp2)) and len(set(cmp1)) == 1 and len(set(cmp2)) == 1:
                if point_dic[cmp1[0]] > point_dic[cmp2[0]]: print(' '.join(cmp1))
                else: print(' '.join(cmp2))
            elif len(cmp1) == 4 and len(cmp2) != 4: print(' '.join(cmp1))
            elif len(cmp2) == 4 and len(cmp1) != 4: print(' '.join(cmp2))

        elif len(cmp1) == len(cmp2) and len(set(cmp1)) == len(set(cmp2)):
            if point_dic[cmp1[0]] > point_dic[cmp2[0]]: print(' '.join(cmp1))
            else: print(' '.join(cmp2))
        
        elif len(cmp1) == len(cmp2) and len(set(cmp1)) != len(set(cmp2)):
            if point_dic[cmp1[0]] > point_dic[cmp2[0]]: print(' '.join(cmp1))
            else: print(' '.join(cmp2))

        else:
            print('ERROR')

    except:
        break

全部评论

相关推荐

dongsheng66:如果想进大厂的话,在校经历没必要占这么大篇幅,可以把专业技能单独放一个专栏写,可以加个项目经历
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务