Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Clock by kurosawa4434
from re import match
def checkio(time_string):
rm = match('(\d+):(\d+):(\d+)', time_string)
fm = lambda x: format(int(rm.group(x)), '02')
dic = str.maketrans('10', '-.')
num_len = [2, 4, 3, 4, 3, 4]
result = ''
for i, num in enumerate(fm(1) + fm(2) + fm(3)):
result += format(int(num), '0' + str(num_len[i]) + 'b').translate(dic) + ' '
if i in (1, 3):
result += ': '
return result[:-1]
July 16, 2016
Comments: