Skip to content

Instantly share code, notes, and snippets.

@Scinawa
Created March 24, 2016 04:19
Show Gist options
  • Save Scinawa/760c7461c9d3c9100bfc to your computer and use it in GitHub Desktop.
Save Scinawa/760c7461c9d3c9100bfc to your computer and use it in GitHub Desktop.
function from N to X
>>> x = len("ABCDEF") # x= 6,
>>> n=3
>>> for i in product("ABCDEF", repeat=n):
... print(i)
('A', 'A', 'A')
...
('F', 'F', 'F')
>>> len( [i for i in product("ABCDEF", repeat=n)] ) == x**n
True
def sample_function(n=0, s=set() ):
f = {i:random.choose(s) for i in range(0,n)}
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