Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active December 12, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/2d08a2609f786dd551b4 to your computer and use it in GitHub Desktop.
Save whatalnk/2d08a2609f786dd551b4 to your computer and use it in GitHub Desktop.
TopCoder SRM 675 Div2
# [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