-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEuler_Problem-055.py
165 lines (152 loc) · 2.15 KB
/
Euler_Problem-055.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env python3
# transpiled with BefunCompile v1.3.0 (c) 2017
def td(a,b):
return ((0)if(b==0)else(a//b))
def tm(a,b):
return ((0)if(b==0)else(a%b))
s=[]
def sp():
global s
if (len(s) == 0):
return 0
return s.pop()
def sa(v):
global s
s.append(v)
def sr():
global s
if (len(s) == 0):
return 0
return s[-1]
x0=32
x1=32
def _0():
sa(0)
sa(10000)
sa(10000)
sa(0)
sa(10000)
sa(0)
return 1
def _1():
return (3)if(sp()!=0)else(2)
def _2():
global t0
global x1
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sp()*10)
v0=sp()
v1=sp()
sa(v0)
sa(v1)
t0=sr()%10
x1=t0
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sp()+x1)
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sp()/10);
sa(sr());
sa((0)if(sp()!=0)else(1))
return 1
def _3():
sp();
sa(sp()+sp());
sa(24)
sa(0)
return 4
def _4():
return (5)if(sp()!=0)else(9)
def _5():
sp();
sp();
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sp()+1)
v0=sp()
v1=sp()
sa(v0)
sa(v1)
return 6
def _6():
sa(sp()-1)
sa(sr());
return (8)if(sp()!=0)else(7)
def _7():
sp();
print(sp(),end=" ",flush=True)
return 15
def _8():
sa(sr());
sa(sr());
sa(0)
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sr());
sa((0)if(sp()!=0)else(1))
return 1
def _9():
global t0
t0=0
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sr());
sa(sr());
return 10
def _10():
sa(sr());
return (14)if(sp()!=0)else(11)
def _11():
global x0
global t0
global t1
x0=t0
sp();
sa(sp()-t0)
t1=sp()
return (12)if((t1)!=0)else(13)
def _12():
global x0
sa(sr());
sp();
sa(sp()+x0)
v0=sp()
v1=sp()
sa(v0)
sa(v1)
sa(sp()-1)
sa(sr());
sa((0)if(sp()!=0)else(1))
return 4
def _13():
sp();
sp();
return 6
def _14():
global t0
global t1
global x1
t0=t0*10
t1=sr()%10
x1=t1
t0=t0+x1
sa(sp()/10);
return 10
m=[_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14]
c=0
while c<15:
c=m[c]()