Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Clock by kasprogiannis
def checkio(data):
def to_morse(digit, width):
return bin(digit)[2:2+width].zfill(width).replace('0', '.').replace('1', '-')
h, m, s = map(int, data.split(":"))
h1, h2 = (h // 10) % 10, h % 10
m1, m2 = (m // 10) % 10, m % 10
s1, s2 = (s // 10) % 10, s % 10
h1, h2 = to_morse(h1, 2), to_morse(h2, 4)
m1, m2 = to_morse(m1, 3), to_morse(m2, 4)
s1, s2 = to_morse(s1, 3), to_morse(s2, 4)
return "%s %s : %s %s : %s %s" % (h1, h2, m1, m2, s1, s2)
Oct. 25, 2016