Skip to content

Instantly share code, notes, and snippets.

@empeje
Last active December 17, 2017 11:14
Show Gist options
  • Save empeje/6468fbbb49aca9c1ee8ffe3e6d489e81 to your computer and use it in GitHub Desktop.
Save empeje/6468fbbb49aca9c1ee8ffe3e6d489e81 to your computer and use it in GitHub Desktop.
[SNIPPET-21] HackerRank - Divisible Sum Pairs
#!/bin/python3
import sys
import itertools
n,k = input().strip().split(' ')
n,k = [int(n),int(k)]
a = [int(a_temp) for a_temp in input().strip().split(' ')]
combinations = list(itertools.combinations(a, 2))
count = 0
for pair in combinations:
sum_pair = int(pair[0] + pair[1])
if sum_pair % k == 0:
count += 1
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment