Skip to content

Instantly share code, notes, and snippets.

@christianp
Created January 17, 2018 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianp/2bd16a63383a41da9e9a3039aa8fb11b to your computer and use it in GitHub Desktop.
Save christianp/2bd16a63383a41da9e9a3039aa8fb11b to your computer and use it in GitHub Desktop.
from math import factorial, sqrt, floor
id = lambda x: x
commands = {
's': sqrt,
'f': floor,
'!': factorial,
}
def decode(n,expr):
for letter in expr:
n = commands.get(letter,id)(n)
return n
decode(2018,'ssf!ssf!ssf')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment