Created
August 31, 2014 18:21
-
-
Save sposterkil/6a3bd56f29979680a8e8 to your computer and use it in GitHub Desktop.
I think this even works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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