Last active
December 12, 2015 14:04
-
-
Save whatalnk/2d08a2609f786dd551b4 to your computer and use it in GitHub Desktop.
TopCoder SRM 675 Div2
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
# [TopCoder Statistics - Problem Statement](https://community.topcoder.com/stat?c=problem_statement&pm=14090&rd=16625) | |
# [null](https://community.topcoder.com/stat?c=problem_solution&cr=22676962&rd=16625&pm=14090) | |
class LengthUnitCalculator(): | |
def calc(self, amount, fromUnit, toUnit): | |
amount = float(amount) | |
units = {"mi": 1, "yd": 1760, "ft": 1760 * 3, "in": 1760 * 3 * 12} | |
return amount * units[toUnit] / units[fromUnit] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment