Skip to content

Instantly share code, notes, and snippets.

@chasefloyd
Created November 1, 2017 18:28
Show Gist options
  • Save chasefloyd/e16b0c7b9849fcaaf730f6df5aafc870 to your computer and use it in GitHub Desktop.
Save chasefloyd/e16b0c7b9849fcaaf730f6df5aafc870 to your computer and use it in GitHub Desktop.
Python solution to determining a function
def isFunction(A, B, f):
x = []
for i in range(len(f)):
x.append(f[i][0])
#print(x)
if len(x) != len(A):
return False
else:
for s in A:
#print(s)
if not s in x:
return False
else:
return True
A = [1, 2, 3]
B = [4, 5]
f = [[1, 4], [2, 5], [3, 4]]
print(isFunction(A, B, f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment