Skip to content

Instantly share code, notes, and snippets.

/README Secret

Created October 25, 2017 16:11
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 anonymous/0d5d728066cf75f305f0c54292b6764a to your computer and use it in GitHub Desktop.
Save anonymous/0d5d728066cf75f305f0c54292b6764a to your computer and use it in GitHub Desktop.
task-1
Goal
The goal is to calculate the price of a vehicle depending on the duration and the amount of kilometers.
Explanation
You find in data.json the pricings for vehicles. Use the data.json together with input.json to generate output.json. Your code should be found in main.rb.
Calculations
To get the proper price all full weeks should be calculated with the weekly price. The remaining full days with the daily price, the remaining hours with the hourly price.
When calculating the prices you should consider if it wouldn't be cheaper to take the daily or weekly price instead.
{
"vehicles": [
{
"id": 1,
"hourly_price": 100,
"daily_price": 4500,
"weekly_price": 12000,
"kilometer_price": 60
},
{
"id": 2,
"hourly_price": 250,
"daily_price": 5000,
"weekly_price": 1500,
"kilometer_price": 90
}
]
}
{
"start_at": "2016-10-03T15:00:00+02:00",
"end_at": "2016-10-05T21:15:00+02:00",
"kilometers": 150
}
# implementation here
{
"results": [
{
"vehicle_id": 1,
"total_price": 18625
},
{
"vehicle_id": 2,
"total_price": 15000
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment