We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0e6708e commit c6c3fceCopy full SHA for c6c3fce
HackerRank-Divisible Sum Pairs/Divisible_Sum_Pairs.py
@@ -0,0 +1,34 @@
1
+#!/bin/python3
2
+
3
+import math
4
+import os
5
+import random
6
+import re
7
+import sys
8
9
+# Complete the divisibleSumPairs function below.
10
+def divisibleSumPairs(n, k, ar):
11
+ count=0
12
+ for i in range(len(ar)):
13
+ for j in range(i+1,len(ar)):
14
+ if((ar[i]+ar[j])%k==0):
15
+ count+=1
16
+ return count
17
18
19
+if __name__ == '__main__':
20
+ fptr = open(os.environ['OUTPUT_PATH'], 'w')
21
22
+ nk = input().split()
23
24
+ n = int(nk[0])
25
26
+ k = int(nk[1])
27
28
+ ar = list(map(int, input().rstrip().split()))
29
30
+ result = divisibleSumPairs(n, k, ar)
31
32
+ fptr.write(str(result) + '\n')
33
34
+ fptr.close()
0 commit comments