Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Clock by AwkwardSandwich
def checkio(time_string):
morse = []
time_string = ":".join([x.zfill(2) for x in time_string.split(":")])
for position, digit in enumerate(time_string):
if position in [1,4,7]: morse.append('{0:04b}'.format(int(digit)))
if position in [3,6] : morse.append('{0:03b}'.format(int(digit)))
if position in [2,5] : morse.append(':')
if position == 0: morse.append('{0:02b}'.format(int(digit)))
return " ".join(morse).replace('0', '.').replace('1','-')
Feb. 11, 2015