Ctrl K

A Date in Binary

Easy
The string day is a date in yyyy-mm-dd format, such as "2024-07-15". Write the year, the month and the day in binary, each without leading zeros, and join them with hyphens in the same order: year, month, day. Return the resulting string.
Example 1
day="2024-07-15" → '11111101000-111-1111'

2024 = 11111101000₂, 7 = 111₂, 15 = 1111₂.

Example 2
day="1961-04-12" → '11110101001-100-1100'

The month's leading zero disappears: 04 becomes just 100.

Constraints
  • len(day) = 10
  • day[4] and day[7] are hyphens and every other character is a digit
  • day is a real calendar date from January 1, 1900 to December 31, 2100 inclusive
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasySum of Binary Strings EasySpreadsheet Column Label EasySpreadsheet Column Index EasyCounting Off by Threes and Fives Easy
loading Python…
Input
day="2024-07-15"
Expected
'11111101000-111-1111'

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