def find_longest_straights(cards): # 定义牌的优先级顺序 order = {'3': 0, '4': 1, '5': 2, '6': 3, '7': 4, '8': 5, '9': 6, '10': 7, 'J': 8, 'Q': 9, 'K': 10, 'A': 11, '2': 12} # 排序卡片 sorted_cards = sorted(cards, key=lambda x: order[x]) # 去重 unique_cards = seen = set for card in sorted_cards: if card not in seen: seen.add(card) unique_cards.append(card) # 查找所有可能的最长顺子 straights = n = len(unique_cards) i = 0 while i = 5: straight = unique_cards[i:j] straights.append(straight) i = j # 跳过已经处理的顺子 else: i += 1 # 按起始牌的大小排序 straights.sort(key=lambda x: order[x[0]]) # 输出结果 if not straights: print("No") else: for straight in straights: print(' '.join(straight))# 读取输入cards = input.splitfind_longest_straights(cards)摘要:def find_longest_straights(cards): # 定义牌的优先级顺序 order = {'3': 0, '4': 1, '5': 2, '6': 3, '7': 4, '8': 5, '9': 6, '10': 7, 'J': 8, '
来源:野猪游戏