Skip to content

Instantly share code, notes, and snippets.

@thepushkarp
Created July 8, 2020 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thepushkarp/e73f8e8347a79a42746f292629ff8c68 to your computer and use it in GitHub Desktop.
Save thepushkarp/e73f8e8347a79a42746f292629ff8c68 to your computer and use it in GitHub Desktop.
def solution(s):
codes = { ' ' : '000000',
'a' : '100000',
'b' : '110000',
'c' : '100100',
'd' : '100110',
'e' : '100010',
'f' : '110100',
'g' : '110110',
'h' : '110010',
'i' : '010100',
'j' : '010110',
'k' : '101000',
'l' : '111000',
'm' : '101100',
'n' : '101110',
'o' : '101010',
'p' : '111100',
'q' : '111110',
'r' : '111010',
's' : '011100',
't' : '011110',
'u' : '101001',
'v' : '111001',
'w' : '010111',
'x' : '101101',
'y' : '101111',
'z' : '101011' }
ans = ''
for c in s:
if c.isupper():
ans += '000001'
ans += codes[c.lower()]
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment