Created
February 28, 2015 20:17
-
-
Save christianp/43845abde2c745bd1bb3 to your computer and use it in GitHub Desktop.
ratio of dots to dashes in Gulliver's Travels in International Morse Code - https://twitter.com/wacnt/status/566748866477694976
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulliver = open(r'c:\users\christian\downloads\gulliver.txt',encoding='utf-8').read() | |
letters = 'abcdefghijklmnopqrstuvwxyz1234567890' | |
morse = '.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. .---- ..--- ...-- ....- ..... -.... --... ---.. ----. -----'.split(' ') | |
dashes = {letter:code.count('-') for letter,code in zip(letters,morse)} | |
dots = {letter:code.count('.') for letter,code in zip(letters,morse)} | |
ndashes = sum(dashes.get(l,0) for l in gulliver.lower()) | |
ndots = sum(dots.get(l,0) for l in gulliver.lower()) | |
print(ndots/float(ndashes)) | |
print(ndots,ndashes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1.5240217474538633
696577 457065