Skip to content

Instantly share code, notes, and snippets.

@ZechCodes
Last active January 8, 2021 05:00
Show Gist options
  • Save ZechCodes/406b144ee1977373e80c1f0f963c22be to your computer and use it in GitHub Desktop.
Save ZechCodes/406b144ee1977373e80c1f0f963c22be to your computer and use it in GitHub Desktop.
Challenge 160 - Car Timer 🏎️

Challenge 160 - Car Timer 🏎️

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(808) ➞ 14

car_timer(14) ➞ 5
import unittest
def car_timer(drive_time) -> int:
return 0 # Put your code here!!!
class Test(unittest.TestCase):
def test_1(self):
self.assertEqual(car_timer(240), 4)
def test_2(self):
self.assertEqual(car_timer(808), 14)
def test_3(self):
self.assertEqual(car_timer(1439), 19)
def test_4(self):
self.assertEqual(car_timer(0), 0)
def test_5(self):
self.assertEqual(car_timer(23), 5)
def test_6(self):
self.assertEqual(car_timer(8), 8)
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment