Last active
December 17, 2017 11:14
-
-
Save empeje/6468fbbb49aca9c1ee8ffe3e6d489e81 to your computer and use it in GitHub Desktop.
[SNIPPET-21] HackerRank - Divisible Sum Pairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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