Created
April 2, 2019 18:20
-
-
Save MaxMonteil/659e2fb99f86f68db8d292ce87d77dbc to your computer and use it in GitHub Desktop.
Given an array arr, find element pairs whose sum equal the second argument arg and return the sum of their indices.
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
def pairwise(arr, arg): | |
size = range(len(arr)) | |
s = 0 | |
for i in size: | |
for j in size: | |
if arr[i] + arr[j] == arg: | |
arr[i] = 0 | |
arr[j] = 0 | |
s = s + i + j | |
return s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment