题解 | #扑克牌大小#
扑克牌大小
http://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
插播一个反面教材
能做出来但是考虑复杂了
all_pic = '3 4 5 6 7 8 9 10 J Q K A 2 joker JOKER'
input_dict = {}
for n, i in enumerate(all_pic.split()):
if i == 'joker':
input_dict[i] = 100
elif i == 'JOKER':
input_dict[i] = 200
else:
input_dict[i] = n
def get_ll(input_list):
if len(input_list) == 1:
return 0 # 单
elif len(input_list) == 2 and 'joker' not in input_list:
return 1 # 对子
elif len(input_list) == 3:
return 2 # 三不带
elif len(input_list) == 4:
return 3 # 四炸
elif len(input_list) == 5:
return 4 # 顺子
elif len(input_list) == 2 and 'joker' in input_list:
return 5 # 王炸
else:
return False
def get_num(input_list):
num_list = [input_dict[i] for i in input_list]
return sum(num_list)
def get_4num(input_list):
num_list = [input_dict[i] for i in input_list]
return sum(num_list) + 1
while True:
try:
input_res = input().split('-')
left_input = input_res[0].split()
right_input = input_res[1].split()
left_n = 0
right_n = 0
if get_ll(left_input) == 5&nbs***bsp;get_ll(right_input) == 5:
if get_ll(left_input) == 5:
print(' '.join(left_input))
elif get_ll(right_input) == 5:
print(' '.join(right_input))
elif get_ll(left_input) == 3&nbs***bsp;get_ll(right_input) == 3:
if get_ll(left_input) == 3 and get_ll(right_input) != 3:
print(' '.join(left_input))
elif get_ll(right_input) == 3 and get_ll(left_input) != 3:
print(' '.join(right_input))
elif get_ll(right_input) == 3 and get_ll(left_input) == 3:
if get_num(left_input) > get_num(right_input):
print(' '.join(left_input))
elif get_num(left_input) < get_num(right_input):
print(' '.join(right_input))
elif get_ll(left_input) != get_ll(right_input):
print('ERROR')
elif get_num(left_input) > get_num(right_input):
print(' '.join(left_input))
elif get_num(left_input) < get_num(right_input):
print(' '.join(right_input))
else:
print('ERROR')
except EOFError:
break
