-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASCII.py
79 lines (72 loc) · 2.05 KB
/
ASCII.py
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
import numpy as np
def ASCII(l):
N = len(l)
if N % 7 != 0:
print 'Your label vector is not a multiplum of 7!'
return
k = N/7;
for i in range(k):
start = i*7;
stop = start+7;
bits = l[start:stop]
if (bits == [-1, -1, -1, -1, -1, 1, 1]).all():
print(' '),
elif (bits == [1, -1, -1, -1, -1, 1, 1]).all():
print('a'),
elif (bits == [-1, 1, -1, -1, -1, 1, 1]).all():
print('b'),
elif (bits == [1, 1, -1, -1, -1, 1, 1]).all():
print('c'),
elif (bits == [-1, -1, 1, -1, -1, 1, 1]).all():
print('d'),
elif (bits == [1, -1, 1, -1, -1, 1, 1]).all():
print('e'),
elif (bits == [-1, 1, 1, -1, -1, 1, 1]).all():
print('f'),
elif (bits == [1, 1, 1, -1, -1, 1, 1]).all():
print('g'),
elif (bits == [-1, -1, -1, 1, -1, 1, 1]).all():
print('h'),
elif (bits == [1, -1, -1, 1, -1, 1, 1]).all():
print('i'),
elif (bits == [-1, 1, -1, 1, -1, 1, 1]).all():
print('j'),
elif (bits == [1, 1, -1, 1, -1, 1, 1]).all():
print('k'),
elif (bits == [-1, -1, 1, 1, -1, 1, 1]).all():
print('l'),
elif (bits == [1, -1, 1, 1, -1, 1, 1]).all():
print('m'),
elif (bits == [-1, 1, 1, 1, -1, 1, 1]).all():
print('n'),
elif (bits == [1, 1, 1, 1, -1, 1, 1]).all():
print('o'),
elif (bits == [-1, -1, -1, -1, 1, 1, 1]).all():
print('p'),
elif (bits == [1, -1, -1, -1, 1, 1, 1]).all():
print('q'),
elif (bits == [-1, 1, -1, -1, 1, 1, 1]).all():
print('r'),
elif (bits == [1, 1, -1, -1, 1, 1, 1]).all():
print('s'),
elif (bits == [-1, -1, 1, -1, 1, 1, 1]).all():
print('t'),
elif (bits == [1, -1, 1, -1, 1, 1, 1]).all():
print('u'),
elif (bits == [-1, 1, 1, -1, 1, 1, 1]).all():
print('v'),
elif (bits == [1, 1, 1, -1, 1, 1, 1]).all():
print('w'),
elif (bits == [-1, -1, -1, 1, 1, 1, 1]).all():
print('x'),
elif (bits == [1, -1, -1, 1, 1, 1, 1]).all():
print('y'),
elif (bits == [-1, 1, -1, 1, 1, 1, 1]).all():
print('z'),
elif (bits == [-1, 1, 1, 1, -1, 1, -1]).all():
print('.'),
elif (bits == [1, -1, -1, -1, -1, 1, -1]).all():
print('!'),
else:
print('#'),
print('\n')