-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha05q2.py
More file actions
43 lines (32 loc) · 1 KB
/
a05q2.py
File metadata and controls
43 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# coding: utf-8
# In[1]:
from typing import *
import check
def make_transformation(pattern: str) -> Dict[str, str]:
"""Return answer with the transformation from a string, pattern, where the index of the dictionary is the next character in pattern"""
answer={}
counter = 0
for i in pattern:
if counter == len(pattern)-1:
answer[i] = " "
else:
answer[i] = pattern[counter+1]
counter += 1
return answer
check.expect("T0", make_transformation("wthraib"),
{'w': 't',
't': 'h',
'h': 'r',
'a': 'i',
'r': 'a',
'i': 'b',
'b': ' '})
check.expect("T1", make_transformation("Oo."), {'O': 'o', 'o': '.', '.': ' '})
check.expect("T2", make_transformation("hike"),
{'h':'i',
'i':'k',
'k':'e',
'e': " "})
check.expect("T3", make_transformation("max"), {'m':'a', 'a':'x', 'x':' '})
# In[ ]: