Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Creative category for Morse Clock by Sim0000
def checkio(data):
to_bin = lambda x: '{:03b} {:04b}'.format(int(('0'+x)[-2]), int(x[-1]))
s = ' : '.join(map(to_bin, data.split(':')))
return s[1:].replace('0', '.').replace('1', '-')
#These "asserts" using only for self-checking and not necessary for auto-testing
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"
March 14, 2014
Comments: