We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Divisible Sum Pairs
Divisible Sum Pairs
Sort by
recency
|
2457 Discussions
|
Please Login in order to post a comment
Do not need the n in the function and using itertools to get all unique pairs:
result=0 for num in range(n): for num1 in range(n): if num!=num1 and (ar[num]+ar[num1])%k==0: result=result+1 if result%2==0: return result//2 elif result%2==1: return result//2+1
Simplest solution