Skip to content

Instantly share code, notes, and snippets.

@MaxMonteil
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.
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