Ctrl K

Lamp Clock Times

Easy
A designer clock shows the time with ten lamps in two rows. The top row of 4 lamps is the hour from 0 to 11 in binary, and the bottom row of 6 lamps is the minute from 0 to 59, also in binary. A lit lamp is a one and a dark lamp is a zero, with the lowest bit on the right. For example, if the top row has the lamps worth 2 and 1 lit and the bottom row has 32, 8 and 2 lit, the clock reads 3:42. Right now exactly lit lamps are on. Return every time the clock could be showing. Format each string like this: - the hour has no leading zero: "5:07", not "05:07"; - the minutes always have two digits: "10:03", not "10:3". The times may be listed in any order.
Example 1
lit=0 → ['0:00']

All lamps are off, so the clock shows 0:00.

Example 2
lit=9 → []

The hour row can have at most 3 lamps lit (7 or 11) and the minute row at most 5 (such as 59 or 47): 4 lamps would mean hour 15, and 6 would mean minute 63. So at most 8 lamps can be on, and the answer is empty.

Example 3
lit=1 → ['0:01', '0:02', '0:04', '0:08', '0:16', '0:32', '1:00', '2:00', '4:00', '8:00']

One lamp: either an hour of 1, 2, 4 or 8 with 00 minutes, or 0 hours with 01, 02, 04, 08, 16 or 32 minutes.

Constraints
  • 0 ≤ lit ≤ 10
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsXOR of Every Subset EasyEvery Topping Combo MediumMirrored One-Bit Codes MediumAll Distinct Card Hands MediumEvery Shorthand of a Word Medium
loading Python…
Input
lit=0
Expected
['0:00']

Run checks the first 3 tests in your browser. Submit checks all 14 tests on the server, hidden ones included.