-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f959d8c
Showing
35 changed files
with
1,703 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Congestion Tax Calculator | ||
|
||
## The Scenario | ||
|
||
Your colleague started working on an application for calculating congestion tax fees for vehicles within the Gothenburg area. Unfortunately, said colleague has gone on parental leave and left the half-finished project to you. While there are no syntax errors in the attached code, there seem to be bugs in the calculation, and there is no entry point to the project, only a class library that currently isn't called from anywhere. | ||
Looking around your colleagues desk, you find a list of dates scribbled on a post-it. Maybe they'll come in handy. | ||
|
||
"2013-01-14 21:00:00" | ||
|
||
"2013-01-15 21:00:00" | ||
|
||
"2013-02-07 06:23:27" | ||
|
||
"2013-02-07 15:27:00" | ||
|
||
"2013-02-08 06:27:00" | ||
|
||
"2013-02-08 06:20:27" | ||
|
||
"2013-02-08 14:35:00" | ||
|
||
"2013-02-08 15:29:00" | ||
|
||
"2013-02-08 15:47:00" | ||
|
||
"2013-02-08 16:01:00" | ||
|
||
"2013-02-08 16:48:00" | ||
|
||
"2013-02-08 17:49:00" | ||
|
||
"2013-02-08 18:29:00" | ||
|
||
"2013-02-08 18:35:00" | ||
|
||
"2013-03-26 14:25:00" | ||
|
||
"2013-03-28 14:07:27" | ||
|
||
## Assignment | ||
|
||
**We want you to think through and implement the changes and additions required to implement a solution that solves the problem and that you would approve and could stand for.** | ||
|
||
- The application currently doesn't have an entry point, add a way to call the calculation with different inputs, preferrably over HTTP. | ||
- As stated there may be bugs in the code, try to find and fix them. | ||
- There is no particular structure to the code so there are several improvements that can be made. | ||
|
||
You may limit the scope to the year 2013. | ||
|
||
Please limit your total time spent on this assignment to 4 hours. We are not looking for a complete solution and we are interested to see how you prioritise your work given the time constraint. Feel free to document what you wanted to focus on in the time given and layout any additional work you would like to have done with more time. | ||
|
||
The starting code is provided in Java, C#, Python, Go, TypeScript and Kotlin, pick the language you are most comfortable with. If you want to write your code using a different language, feel free. | ||
|
||
## Congestion tax rules in Gothenburg | ||
|
||
Congestion tax is charged during fixed hours for vehicles driving into and out of Gothenburg. | ||
|
||
The maximum amount per day and vehicle is 60 SEK. | ||
|
||
The tax is not charged on weekends (Saturdays and Sundays), public holidays, days before a public holiday and during the month of July. | ||
|
||
### Hours and amounts for congestion tax in Gothenburg | ||
|
||
| Time | Amount | | ||
| ----------- | :----: | | ||
| 06:00–06:29 | SEK 8 | | ||
| 06:30–06:59 | SEK 13 | | ||
| 07:00–07:59 | SEK 18 | | ||
| 08:00–08:29 | SEK 13 | | ||
| 08:30–14:59 | SEK 8 | | ||
| 15:00–15:29 | SEK 13 | | ||
| 15:30–16:59 | SEK 18 | | ||
| 17:00–17:59 | SEK 13 | | ||
| 18:00–18:29 | SEK 8 | | ||
| 18:30–05:59 | SEK 0 | | ||
|
||
### The single charge rule | ||
|
||
A single charge rule applies in Gothenburg. Under this rule, a vehicle that passes several tolling stations within 60 minutes is only taxed once. The amount that must be paid is the highest one. | ||
|
||
### Tax Exempt vehicles | ||
|
||
- Emergency vehicles | ||
- Busses | ||
- Diplomat vehicles | ||
- Motorcycles | ||
- Military vehicles | ||
- Foreign vehicles | ||
|
||
## Bonus Scenario | ||
|
||
Just as you finished coding, your manager shows up and tells you that the same application should be used in other cities with different tax rules. These tax rules need to be handled as content outside the application because different content editors for different cities will be in charge of keeping the parameters up to date. | ||
|
||
Move the parameters used by the application to an outside data store of your own choice to be read during runtime by the application. | ||
|
||
## Further questions | ||
|
||
As you take on the assignment you will undoubtedly have questions. Please write these questions down in a file named `questions.md` and submit that along with your solution. Although we cannot answer them in order for you to complete the assignment, they will be helpful | ||
in evaluating your solution. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <https://unlicense.org/> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Congestion Tax Calculator | ||
|
||
Welcome the Volvo Cars Congestion Tax Calculator assignment. | ||
|
||
This repository contains a developer [assignment](ASSIGNMENT.md) used as a basis for candidate intervew and evaluation. | ||
|
||
Clone this repository to get started. Due to a number of reasons, not least privacy, you will be asked to zip your solution and mail it in, instead of submitting a pull-request. In order to maintain an unbiased reviewing process, please ensure to **keep your name or other Personal Identifiable Information (PII) from the code**. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package calculator | ||
|
||
type Car struct { | ||
} | ||
|
||
func (c Car) getVehicleType() string { | ||
return "Car" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package calculator | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
type TollFreeVehicles int | ||
|
||
const ( | ||
Motorcycle TollFreeVehicles = iota | ||
Tractor TollFreeVehicles = iota | ||
Emergency TollFreeVehicles = iota | ||
Diplomat TollFreeVehicles = iota | ||
Foreign TollFreeVehicles = iota | ||
Military TollFreeVehicles = iota | ||
) | ||
|
||
func (tfv TollFreeVehicles) String() string { | ||
switch tfv { | ||
case Motorcycle: | ||
return "Motorcycle" | ||
case Tractor: | ||
return "Tractor" | ||
case Emergency: | ||
return "Emergency" | ||
case Foreign: | ||
return "Foreign" | ||
case Military: | ||
return "Military" | ||
default: | ||
return fmt.Sprintf("%d", int(tfv)) | ||
} | ||
} | ||
|
||
func GetTax(vehicle Vehicle, dates []time.Time) int { | ||
intervalStart := dates[0] | ||
totalFee := 0 | ||
for _, date := range dates { | ||
nextFee := getTollFee(date, vehicle) | ||
tempFee := getTollFee(date, vehicle) | ||
|
||
diffInNanos := date.UnixNano() - intervalStart.UnixNano() | ||
minutes := diffInNanos / 1000000 / 1000 / 60 | ||
|
||
if minutes <= 60 { | ||
if totalFee > 0 { | ||
totalFee = totalFee - tempFee | ||
} | ||
if nextFee >= tempFee { | ||
tempFee = nextFee | ||
} | ||
} else { | ||
totalFee = totalFee + nextFee | ||
} | ||
} | ||
|
||
if totalFee > 60 { | ||
totalFee = 60 | ||
} | ||
return totalFee | ||
} | ||
|
||
func isTollFreeVehicle(v Vehicle) bool { | ||
if v == nil { | ||
return false | ||
} | ||
vehicleType := v.getVehicleType() | ||
|
||
return vehicleType == TollFreeVehicles(Motorcycle).String() || vehicleType == TollFreeVehicles(Tractor).String() || vehicleType == TollFreeVehicles(Emergency).String() || vehicleType == TollFreeVehicles(Diplomat).String() || vehicleType == TollFreeVehicles(Foreign).String() || vehicleType == TollFreeVehicles(Military).String() | ||
} | ||
|
||
func getTollFee(t time.Time, v Vehicle) int { | ||
if isTollFreeDate(t) || isTollFreeVehicle(v) { | ||
return 0 | ||
} | ||
|
||
hour, minute := t.Hour(), t.Minute() | ||
|
||
if hour == 6 && minute >= 0 && minute <= 29 { | ||
return 8 | ||
} | ||
if hour == 6 && minute >= 30 && minute <= 59 { | ||
return 13 | ||
} | ||
if hour == 7 && minute >= 0 && minute <= 59 { | ||
return 18 | ||
} | ||
if hour == 8 && minute >= 0 && minute <= 29 { | ||
return 13 | ||
} | ||
if hour >= 8 && hour <= 14 && minute >= 30 && minute <= 59 { | ||
return 8 | ||
} | ||
if hour == 15 && minute >= 0 && minute <= 29 { | ||
return 13 | ||
} | ||
if hour == 15 && minute >= 0 || hour == 16 && minute <= 59 { | ||
return 18 | ||
} | ||
if hour == 17 && minute >= 0 && minute <= 59 { | ||
return 13 | ||
} | ||
if hour == 18 && minute >= 0 && minute <= 29 { | ||
return 8 | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
func isTollFreeDate(date time.Time) bool { | ||
year := date.Year() | ||
month := date.Month() | ||
day := date.Day() | ||
|
||
if date.Weekday() == time.Saturday || date.Weekday() == time.Sunday { | ||
return true | ||
} | ||
|
||
if year == 2013 { | ||
if month == 1 && day == 1 || month == 3 && (day == 28 || day == 29) || month == 4 && (day == 1 || day == 30) || month == 5 && (day == 1 || day == 8 || day == 9) || month == 6 && (day == 5 || day == 6 || day == 21) || month == 7 || month == 11 && day == 1 || month == 12 && (day == 24 || day == 25 || day == 26 || day == 31) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package calculator | ||
|
||
type Motorbike struct { | ||
} | ||
|
||
func (m Motorbike) getVehicleType() string { | ||
return "Motorbike" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package calculator | ||
|
||
type Vehicle interface { | ||
getVehicleType() string | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module congestion-calculator | ||
|
||
go 1.15 |
Oops, something went wrong.