Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
8 lines proc solution in Creative category for Calculator-I by CDG.Axel
def calculator(log: str) -> str:
prev, current, save, operation = 0, 0, False, '='
for key in log:
if key.isdigit():
current, save = current * 10 * save + int(key), True
elif key in '+-=':
prev = current = prev + current if operation == '+' else prev - current if operation == '-' else current
operation, save = key, False
return str(current)
Feb. 6, 2023
Comments: