Skip to content

Instantly share code, notes, and snippets.

@miku
Created December 16, 2010 17:19
Show Gist options
  • Select an option

  • Save miku/743682 to your computer and use it in GitHub Desktop.

Select an option

Save miku/743682 to your computer and use it in GitHub Desktop.
Codility.com sampletest 100% in python.
#!/usr/bin/env python
def equi(A):
upper = sum(A)
lower = 0
for position in range(0, len(A)):
if upper - A[position] == lower:
return position
else:
lower += A[position]
upper -= A[position]
return -1
if __name__ == '__main__':
a = [-7, 1, 5, 2, -4, 3, 0]
print equi(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment