Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
short solution in Creative category for Morse Clock by ciel
#if sys.version_info[0]>=3:
if 'maketrans' in str.__dict__:
maketrans=str.maketrans
else:
from string import maketrans
checkio=lambda data: ' : '.join('{:03b} {:04b}'.format(int(e)//10,int(e)%10) for e in data.split(':'))[1:].translate(maketrans('01', '.-'))
#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 15, 2014
Comments: