Skip to content

Instantly share code, notes, and snippets.

@sposterkil
Created August 31, 2014 18:21
Show Gist options
  • Save sposterkil/6a3bd56f29979680a8e8 to your computer and use it in GitHub Desktop.
Save sposterkil/6a3bd56f29979680a8e8 to your computer and use it in GitHub Desktop.
I think this even works
def recurse(input_file):
"""Takes a file and recursively evaluates lines to get an answer."""
children, value = split_line(input_file.read())
# All operations we implement are binary, we should either have zero
# children or two. Anything else is an error.
if children == 0:
return float(value)
elif children == 2:
return operate(value,
recurse(input_file.read()),
recurse(input_file.read()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment