Binary Watch

Advanced

Binary Watch Challenge

A binary watch displays time with LEDs that represent binary numbers. Each LED can be on or off, showing a binary code that represents the time.

Your task is to write a function binary_watch(hour, minute) that takes two parameters, hour and minute, representing time in standard 12-hour format, and returns the time in a simulated binary watch format.

In a binary watch:

  • Hours have 4 LEDs (i.e., 4 binary bits)
  • Minutes have 6 LEDs (i.e., 6 binary bits)

Each LED can be either 0 or 1, based on whether it is off or on respectively. Your function should convert the given hour and minute into a binary string of these LEDs.

Here's an example to help you out:

Example

binary_watch(3, 25)

Output should be:

('0011', '011001')

Explanation:

  • The hour 3 in binary is represented with 4 bits as 0011.
  • The minute 25 in binary is represented with 6 bits as 011001.

More Examples:

binary_watch(10, 45)

Output should be:

('1010', '101101')
binary_watch(7, 0)

Output should be:

('0111', '000000')

Let's have fun with Binary Watches!

Geek
Inputs

Arg 1:

3

Arg 2:

25
Expected Output
["0011", "011001"]
Actual Output
Binary Watch [advanced] | Coding for Kids