← Back to challenges

Car Timer 🏎️

PythonHardnumbersconditionsalgorithms

Instructions

A built-in timer inside your car can count the length of your ride in minutes and you have started your ride at 00:00.

Given the number of minutes n at the end of the ride, calculate the current time. Return the sum of digits that the digital timer in the format hh:mm will show at the end of the ride.

Examples

car_timer(240) ➞ 4
# 240 minutes have passed since 00:00, the current time is 04:00
# Digits sum up is 0 + 4 + 0 + 0 = 4

car_timer(14) ➞ 5
# Digits sum up is 0 + 0 + 1 + 4

car_timer(808) ➞ 14

Notes

N/A

python3
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Let's Talk Like a Monkey 🐡 β†’