dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.5 KiB
2.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69b1028d6e265413d0198a2c | Challenge 233: Wake-Up Alarm | 29 | challenge-233 |
--description--
Given a string representing the time you set your alarm and a string representing the time you actually woke up, determine if you woke up early, on time, or late.
- Both times will be given in
"HH:MM"24-hour format.
Return:
"early"if you woke up before your alarm time."on time"if you woke up at your alarm time, or within the 10 minute snooze window after the alarm time."late"if you woke up more than 10 minutes after your alarm time.
Both times are on the same day.
--hints--
alarm_check("07:00", "06:45") should return "early".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("07:00", "06:45"), "early")`)
}})
alarm_check("06:30", "06:30") should return "on time".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("06:30", "06:30"), "on time")`)
}})
alarm_check("08:10", "08:15") should return "on time".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("08:10", "08:15"), "on time")`)
}})
alarm_check("09:30", "09:45") should return "late".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("09:30", "09:45"), "late")`)
}})
alarm_check("08:15", "08:25") should return "on time".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("08:15", "08:25"), "on time")`)
}})
alarm_check("05:45", "05:56") should return "late".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("05:45", "05:56"), "late")`)
}})
alarm_check("04:30", "04:00") should return "early".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(alarm_check("04:30", "04:00"), "early")`)
}})
--seed--
--seed-contents--
def alarm_check(alarm_time, wake_time):
return alarm_time
--solutions--
def alarm_check(alarm_time, wake_time):
alarm_h, alarm_m = map(int, alarm_time.split(":"))
wake_h, wake_m = map(int, wake_time.split(":"))
alarm_minutes = alarm_h * 60 + alarm_m
wake_minutes = wake_h * 60 + wake_m
diff = wake_minutes - alarm_minutes
if diff < 0:
return "early"
if diff <= 10:
return "on time"
return "late"