Created
September 2, 2019 02:52
-
-
Save alexgolec/bff6174c40d3dd8c8e5f919ced4990cc to your computer and use it in GitHub Desktop.
This file contains 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 convert(conversions, start, end): | |
'Given a conversion structure, performs a constant-time conversion' | |
try: | |
start_root, start_rate = conversions[start] | |
end_root, end_rate = conversions[end] | |
except KeyError: | |
return None | |
if start_root != end_root: | |
return None | |
return end_rate / start_rate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment