Skip to content

Instantly share code, notes, and snippets.

Forked from jorgebastida/gist:1023399
Created June 14, 2011 10:13
What would you like to do?
Tuenti ejercicio 1
import re
from operator import add, mul, sub
import sys
ops = {'=': add, '@': sub, '#': mul }
r = '\^(.)\s*(\-?\d+)\s*(\-?\d+)\$'
def e(g):
g = g.groups()
return str(ops[g[0]](*map(int, g[1:])))
def parse(exp):
while '^' in exp:
exp = re.sub(r, e, exp)
return exp
if __name__ == '__main__':
for x in ' '.join(sys.argv[1:]).split('\n'):
print parse(x)
Copy link

te lo acabo de forkear con trucos de perro viejo XD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment