Created
November 1, 2017 18:31
-
-
Save chasefloyd/df1fc818f2c0089dbbe048a94f66ae90 to your computer and use it in GitHub Desktop.
Python solution for determining if a function is onto
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 isOnto(A,B,f): | |
x = [] | |
for i in range(len(f)): | |
x.append(f[i][1]) | |
#print(x) | |
i+=1 | |
B = sorted(B) | |
x = list(set(x)) | |
if B == x: | |
return True | |
else: | |
return False | |
A = [1, 2, 3] | |
B = [4, 5] | |
f = [[1, 4], [2, 5], [3, 4]] | |
print(isOnto(A, B, f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment