Skip to content

Instantly share code, notes, and snippets.

@fabian57
Last active August 29, 2015 14:17
Show Gist options
  • Save fabian57/dafea7f56d35fcc33a10 to your computer and use it in GitHub Desktop.
Save fabian57/dafea7f56d35fcc33a10 to your computer and use it in GitHub Desktop.
DATA = {
"A": {"unlimited": 70, "package": 50, "extra_mile": 1},
"B": {"unlimited": 140, "package": 100, "extra_mile": 1.5},
}
DAILY_MILEAGE_LIMIT = 200
mileage = input("Mileage? ")
duration = input("Duration (days)? ")
category = raw_input("Category (A or B)? ").upper()
price_unlimited = duration * data[category]["unlimited"]
price_package = duration * data[category]["package"]
extra_miles = mileage - duration * DAILY_MILEAGE_LIMIT
if extra_miles > 0:
price_package += extra_miles * data[category]["extra_mile"]
print "Best option:",
if price_unlimited < price_package:
print "unlimited ($%s)" % price_unlimited,
else:
print "package ($%s)" % price_package,
print "that is to say $%s saving" % abs(price_unlimited - price_package)
@laowantong
Copy link

Parfait!

Regarde le commentaire du programme d'Étienne pour la version longue ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment