### added beginnings of morse code problem

master
Stephen McQuay 8 years ago
parent
commit
8c7b4e0deb
2 changed files with 49 additions and 0 deletions
1. +48
-0
jt-dilema/dilema.py
2. +1
-0
jt-dilema/stdin1.txt

#### + 48 - 0 jt-dilema/dilema.pyView File

 @ -0,0 +1,48 @@ import sys translate = { '._': 'A', '_...': 'B', '_._.': 'C', '_..': 'D', '.': 'E', '.._.': 'F', '__.': 'G', '....': 'H', '..': 'I', '.___': 'J', '_._': 'K', '._..': 'L', '__': 'M', '_.': 'N', '___': 'O', '.__.': 'P', '__._': 'Q', '._.': 'R', '...': 'S', '_': 'T', '.._': 'U', '..._': 'V', '.__': 'W', '_.._': 'X', '_.__': 'Y', '__..': 'Z', } def mogrificate(l, your_index, r, sofars=None): if sofars is None: sofars = [] for i in xrange(MIN_LEN, MAX_LEN + 1): substr = ''.join(l[your_index:i]) if substr in translate: current_letter = translate[substr] sofars.append(current_letter) print sofars MIN_LEN = min(len(k) for k in translate) MAX_LEN = max(len(k) for k in translate) letters = [i for i in sys.stdin.readline().strip()] results = [] mogrificate(letters, 0, results)

#### + 1 - 0 jt-dilema/stdin1.txtView File

 @ -0,0 +1 @@ .__..__._..._