Skip to content

Instantly share code, notes, and snippets.

@kungtotte
Created November 17, 2018 11:42
Show Gist options
  • Save kungtotte/4356666f8e54890378494faf4178bc9e to your computer and use it in GitHub Desktop.
Save kungtotte/4356666f8e54890378494faf4178bc9e to your computer and use it in GitHub Desktop.
let
rate = 40.0
weekly_discount = 50.0
weekend_discount = 20.0
test_data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
proc total_cost(days: int): float =
result = days.float * rate
if days >= 7:
result -= weekly_discount
elif days >= 3:
result -= weekend_discount
for n in test_data:
echo "Cost for ", n, " days is: ", total_cost(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment