fork download
  1. from itertools import*
  2. f = lambda s,n,c=combinations:all(x^y for x,y in c(map(sum,c(s,n)),2))
  3.  
  4. for x,n in (
  5. ([1, 4, 8], 1),
  6. ([1, 10, 42], 1),
  7. ([1, 2, 3, 4], 3),
  8. ([1, 2, 3, 4, 5], 5),
  9. ([1, 2, 3, 5, 8], 3),
  10. ([1, 2, 3, 4, 5], 2),
  11. ([-2, -1, 0, 1, 2], 3),
  12. ([1, 2, 3, 5, 8, 13], 3),
  13. ([1, 2, 4, 8, 16, 32], 3),
  14. ([1, 2, 4, 8, 16, 32], 4),
  15. ([1, 2, 4, 8, 16, 32], 5),
  16. ([1, 2, 4, 8, 16, 32], 6),
  17. ([3, 4, 7, 9, 12, 16, 18], 6),
  18. ([3, 4, 7, 9, 12, 16, 18], 3)
  19. ):
  20. print(f(x, n))
Success #stdin #stdout 0.02s 9936KB
stdin
Standard input is empty
stdout
True
True
True
True
True
False
False
False
True
True
True
True
True
False