fork download
  1. import itertools as it
  2. valid = (comb for comb in it.combinations(range(1, 11), 4) if all(abs(x - y) != 1 for x, y in zip(comb, comb[1:])))
  3. for t in enumerate(valid, 1):
  4. print("{0:2}. {1}".format(*t))
Success #stdin #stdout 0.02s 27704KB
stdin
Standard input is empty
stdout
 1. (1, 3, 5, 7)
 2. (1, 3, 5, 8)
 3. (1, 3, 5, 9)
 4. (1, 3, 5, 10)
 5. (1, 3, 6, 8)
 6. (1, 3, 6, 9)
 7. (1, 3, 6, 10)
 8. (1, 3, 7, 9)
 9. (1, 3, 7, 10)
10. (1, 3, 8, 10)
11. (1, 4, 6, 8)
12. (1, 4, 6, 9)
13. (1, 4, 6, 10)
14. (1, 4, 7, 9)
15. (1, 4, 7, 10)
16. (1, 4, 8, 10)
17. (1, 5, 7, 9)
18. (1, 5, 7, 10)
19. (1, 5, 8, 10)
20. (1, 6, 8, 10)
21. (2, 4, 6, 8)
22. (2, 4, 6, 9)
23. (2, 4, 6, 10)
24. (2, 4, 7, 9)
25. (2, 4, 7, 10)
26. (2, 4, 8, 10)
27. (2, 5, 7, 9)
28. (2, 5, 7, 10)
29. (2, 5, 8, 10)
30. (2, 6, 8, 10)
31. (3, 5, 7, 9)
32. (3, 5, 7, 10)
33. (3, 5, 8, 10)
34. (3, 6, 8, 10)
35. (4, 6, 8, 10)