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
1.9 KiB
1.9 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69a890af247de743333bd4d0 | Challenge 227: Cooldown Time | 29 | challenge-227 |
--description--
Given two timestamps, the first representing when a user finished an exam, and the second representing the current time, determine whether the user can take an exam again.
- Both timestamps will be given the format:
"YYYY-MM-DDTHH:MM:SS", for example"2026-03-25T14:00:00". Note that the time is 24-hour clock. - A user must wait at least 48 hours before retaking an exam.
--hints--
can_retake("2026-03-23T08:00:00", "2026-03-25T14:00:00") should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(can_retake("2026-03-23T08:00:00", "2026-03-25T14:00:00"), True)`)
}})
can_retake("2026-03-24T14:00:00", "2026-03-25T10:00:00") should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(can_retake("2026-03-24T14:00:00", "2026-03-25T10:00:00"), False)`)
}})
can_retake("2026-03-23T09:25:00", "2026-03-25T09:25:00") should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(can_retake("2026-03-23T09:25:00", "2026-03-25T09:25:00"), True)`)
}})
can_retake("2026-03-25T11:50:00", "2026-03-23T11:49:59") should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(can_retake("2026-03-25T11:50:00", "2026-03-23T11:49:59"), False)`)
}})
--seed--
--seed-contents--
def can_retake(finish_time, current_time):
return finish_time
--solutions--
from datetime import datetime, timedelta
def can_retake(finish_time, current_time):
fmt = "%Y-%m-%dT%H:%M:%S"
finished_dt = datetime.strptime(finish_time, fmt)
current_dt = datetime.strptime(current_time, fmt)
diff = current_dt - finished_dt
cooldown = timedelta(hours=48)
return diff >= cooldown