fork download
  1. # your code goes here
  2. import itertools
  3.  
  4. list = [5, 1, 2, 3, 4, 1,]
  5. uniquelist = set(list)
  6. targetsum = 1
  7.  
  8. for n in itertools.combinations(uniquelist, 2):
  9. if n[0] ^ n[1] == targetsum:
  10. print str(n[0]) + " + " + str(n[1])
Success #stdin #stdout 0s 9024KB
stdin
1
2
stdout
2 + 3
4 + 5