题解 | #扑克牌大小#

扑克牌大小

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

全部评论

相关推荐

练习生懒羊羊:开飞机把这个公司创飞吧
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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