-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16281208-熊超-4.31.py
39 lines (37 loc) · 1.17 KB
/
16281208-熊超-4.31.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
M = {
'+':{'+':'>','*':'<','↑':'<','(':'<',')':'>','i':'<','#':'>'},
'*':{'+':'>','*':'>','↑':'<','(':'<',')':'>','i':'<','#':'>'},
'↑':{'+':'>','*':'>','↑':'<','(':'<',')':'>','i':'<','#':'>'},
'(':{'+':'<','*':'<','↑':'<','(':'<',')':'=','i':'<','#':'?'},
')':{'+':'>','*':'>','↑':'>',')':'>','#':'>','(':'?','i':'?'},
'i':{'+':'>','*':'>','↑':'>',')':'>','#':'>','(':'?','i':'?'},
'#':{'+':'<','*':'<','↑':'<','(':'<','i':'<','#':'=',')':'?'}
}
Vt = ['+','*','↑','(',')','i','#']
f = dict.fromkeys(Vt,1)
g = dict.fromkeys(Vt,1)
print(" ",end="")
for i in Vt:
print("%c "%i,end="")
print("")
for i in Vt:
print("%c "%i,end="")
for j in Vt:
print('%c '%M[i][j],end='')
print()
while True:
ft = f.copy()
gt = g.copy()
for i in Vt:
for j in Vt:
if M[i][j] == '>' and f[i]<=g[j]:
f[i] = g[j] + 1
if M[i][j] == '<' and f[i]>=g[j]:
g[j] = f[i] + 1
if M[i][j] == '=' and f[i] != g[j]:
f[i] = max(f[i],g[j])
g[j] = f[i]
if f == ft and gt == g:
print("f",f)
print('g:',g)
break