Last active
March 3, 2017 04:04
-
-
Save juanitobanca/0d3fa3bc914c446c8c690dc900a40786 to your computer and use it in GitHub Desktop.
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 triplets( alist ): | |
alist.sort() | |
p = getPartitionInt( alist ) | |
trips = set() | |
if p == -1: | |
return "No Triplets" | |
glz = alist[:p] | |
gez = alist[p:] | |
for l in glz: | |
for e in gez: | |
if -(l+e) < 0: | |
x = binarySearch(glz, -(l+e)) | |
else: | |
x = binarySearch(gez, -(l+e)) | |
if x: | |
t = [l,e,-(l+e)] | |
t.sort() | |
trips.add(tuple(t)) | |
return trips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment