What does this meeting cost
Finance wants every meeting priced: length × attendees × hourly rate, rounded down.
- Cost = floor(minutes × attendees × ratePerHour / 60).
- Any zero input makes the cost zero.
meetingCost(minutes: int, attendees: int, ratePerHour: int) → int
Go needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.
Where you start
func meetingCost(minutes int, attendees int, ratePerHour int) int {
}
Worked examples
| Call | Result |
|---|---|
meetingCost(30, 5, 100) | 250 |
meetingCost(60, 3, 80) | 240 |
meetingCost(45, 4, 60) | 180 |
meetingCost(0, 5, 100) | 0 |
Hint
Multiply first, then integer-divide by 60.
Reference solution in Go
func meetingCost(minutes int, attendees int, ratePerHour int) int {
return minutes * attendees * ratePerHour / 60
}