Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. import itertools
  2.  
  3. arr = [1, 2, 3, 4, 5]
  4. k = int(input('int k: '))
  5.  
  6. matched = []
  7.  
  8. all_combinations = itertools.combinations(arr, 2)
  9. for combination in all_combinations:
  10.   if not sum(combination) % k:
  11.     matched.append(combination)
  12.  
  13. print(matched)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement