-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths2016.py
More file actions
80 lines (65 loc) · 1.63 KB
/
s2016.py
File metadata and controls
80 lines (65 loc) · 1.63 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# file os
import os
s1 = ["*|*|*"]
s2 = ["* *|*", "* * *", "* * *", "*|* *"]
s7 = ["* ", "* ", "* ", "*|*|*"]
dic = {"1": s1, "2": s2, "7": s7}
# reverse dic dict(zip(dic.values(),dic.keys()))
kvalue = []
for value in dic.values():
kvalue.append("".join(value))
dic2 = dict(zip(kvalue, dic.keys()))
file_t = "tmp.txt"
file_a = "out1.txt"
def reverse(s):
return list(map(list, zip(*s)))
def reverseFile(file_n):
with open(file_n, 'r') as f:
text = []
for row in f:
text.append(row[:-1])
newtext = reverse(text)
with open(file_n, 'w') as f:
for row in newtext:
for char in row:
f.write(char)
f.write('\n')
def printchar(s, blankline=1, blankn=5):
with open(file_a, 'a') as f:
for row in s:
f.write(row + '\n')
for i in range(blankline):
f.write(' ' * 5 + '\n')
def printnum(n):
sn = str(n)
while len(sn) > 1:
x = sn[0]
sn = sn[1:]
printchar(dic[x])
if len(sn) == 1:
printchar(dic[sn])
def recognize(file_n):
with open(file_n, 'r') as f:
text = []
for row in f:
text.append(row[:-1])
newtext = reverse(text)
num = ['']
i = 0
for row in newtext:
curr = ''.join(row)
if curr.strip():
num[i] += (curr)
else:
i += 1
num.append('')
for match in num:
if match in dic2:
print(dic2[match], end='')
def main():
os.remove(file_a)
printnum(127)
reverseFile(file_a)
recognize(file_a)
if __name__ == '__main__':
main()