Created
April 2, 2019 18:20
Given an array arr, find element pairs whose sum equal the second argument arg and return the sum of their indices.
This file contains hidden or 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