题解 | 牛牛的考试
牛牛的考试
https://www.nowcoder.com/practice/1a7a7c8d721547a29107cf02330ffe72
def correct(options): # 每个选项的内容 contects = [option.split(".", 1)[1] for option in options] # 每个选项的长度 lengths = [len(contect) for contect in contects] # 获取最大最小长度 max_len = max(lengths) min_len = min(lengths) # 统计每个长度出现的次数 len_counts = {length: lengths.count(length) for length in lengths} # 三长一短 if len_counts[min_len] == 1: return options[lengths.index(min_len)][0] # 三短一长 elif len_counts[max_len] == 1: return options[lengths.index(max_len)][0] else: return "C" n = int(input()) results = [] for i in range(n): options = [input().strip() for _ in range(4)] results.append(correct(options)) print("\n".join(results))