Sloth’s Meal Time

Challenge Difficulty: Medium | Estimated completion time: ~20 minutes

Sloth is a very habitual person. He eats breakfast at 7:00 a.m. each morning, lunch at 12:00 p.m. and dinner at 7:00 p.m. in the evening.

Create a function that takes in the current time as a string and determines the duration of time before Sloth’s next meal.

Represent this as an array with the first and second elements representing hours and minutes, respectively.

Examples

timeToEat("2:00 p.m.")
#5 hours until the next meal, dinner
output = [5, 0]
 
timeToEat("5:50 a.m.")
# 1 hour and 10 minutes until the next meal, breakfast
output = [1, 10]

Solution

Python
Output