Created
March 24, 2016 04:23
-
-
Save Scinawa/d3b2d1a3eba8789fc144 to your computer and use it in GitHub Desktop.
Injective functions from N to X
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
>>> s="ABCD" | |
>>> repetition=3 | |
>>> a = [i for i in itertools.permutations(s, repetition)] | |
>>> len(a) == math.factorial(len(s)) / math.factorial(len(s)-repetition) | |
True | |
def sample_function(n=0, s=set() ): | |
f = {} | |
for i in range(0, n): | |
f[i]=random.choice(s) | |
s.remove(f[i]) #injective functions here | |
def _function(x): | |
return f[x] | |
return _function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment