def gen3(lst, d): return [d + lst[i] + lst[j] for i in range(len(lst)) for j in range(i, len(lst))] def gen2(lst, d): return [d + item for item in lst] def generate(match): scoreDbl = list(range(2, 41, 2)) + [50] scoreAll = list(range(1, 21)) + list(range(3, 61, 3)) + [25] + scoreDbl mix = scoreDbl[:] for last in scoreDbl: mix += gen3(scoreAll, last) mix += gen2(scoreAll, last) return list(filter(match, mix)) print(len(generate(lambda x: x < 100)))