Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Morse Clock by yukirin
def checkio(time_string):
return "{0:.>2} {1:.>4} : {2:.>3} {3:.>4} : {4:.>3} {5:.>4}".format(
*(bin(int(i))[2:].replace('0', '.').replace('1', '-')
for n in time_string.split(':') for i in n.zfill(2)))
if __name__ == '__main__':
assert checkio("10:37:49") == ".- .... : .-- .--- : -.. -..-", "First Test"
assert checkio("21:34:56") == "-. ...- : .-- .-.. : -.- .--.", "Second Test"
assert checkio("00:1:02") == ".. .... : ... ...- : ... ..-.", "Third Test"
assert checkio("23:59:59") == "-. ..-- : -.- -..- : -.- -..-", "Fourth Test"
April 7, 2015
Comments: