编辑代码

from itertools import product

# 全部数字范围
all_digits = set(range(10))

# 直接在代码中指定第二位和第三位的和的个位数
sums = '26058349'

# 将输入的字符串转换为整数集合
sums = set(map(int, sums))

# 初始化字典存储结果
combinations = {0: [], 1: []}  # 0 表示未匹配的组合,1 表示匹配的组合

# 遍历所有可能的组合
for first in all_digits:
    for second in all_digits:
        for third in all_digits:
            for fourth in all_digits:
                combo = (first, second, third, fourth)
                
                # 检查第二位和第三位的和的个位数是否在输入的和集合中
                if (second + third) % 10 in sums:
                    combinations[1].append("".join(map(str, combo)))
                else:
                    combinations[0].append("".join(map(str, combo)))

# 直接打印结果
for value, combo_list in combinations.items():
    print(f"Value {value}:")
    print(" ".join(combo_list))
    print()