-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
242 lines (236 loc) · 9.78 KB
/
main.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# main.py
import tkinter
from tkinter import *
from tkinter import ttk, filedialog
from tkinter.filedialog import askopenfile
def execute():
try:
print("---------------------------------")
file = askopenfile(mode="r")
code = file.read()
file.close()
characters = '\n !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~'
if code.lower().replace('fried chicken', '').replace(' ', '').replace('\n', '') == "":
real_code = ""
for line in code.split('\n'):
chicken_amount = line.lower().count("fried chicken")
if chicken_amount >= len(characters):
print("Chicken was MUTATED!!!")
else:
character = characters[chicken_amount]
real_code += str(character)
try:
cells_execute(real_code)
except:
print("Chicken was OVERFRIED!!!")
else:
print("Chicken had BIRD FLU!!!")
except:
print("Please input a valid file path...")
# cells
def cells_execute(__codeline__:str):
codeline = str(__codeline__)
for __________ in range(1):
code = []
iterated_code = "0skip "
push_to_next_line = ":"
for character in codeline:
if character == push_to_next_line:
code.append(iterated_code)
iterated_code = "0skip "
else:
if iterated_code == "0skip ":
iterated_code = ""
iterated_code = iterated_code + character
skip_lines = []
variables_name = []
variables_value = []
for cell in code:
if " < " in cell:
variable_name = ""
for character in cell.replace("nomenclate ", ""):
if character == " ":
break
else:
variable_name = variable_name + character
variable_value = cell.replace("nomenclate ", "")
variable_value = variable_value.replace(variable_name, "")
variable_value = variable_value.replace(" < ", "")
if "nomenclate " in cell:
variables_name.append(variable_name)
variables_value.append("")
variables_value[variables_name.index(variable_name)] = variable_value
skip_lines.append(int(code.index(cell)))
line = -1
while line < len(code) - 1:
line += 1
pure_command = str(code[line])
command = pure_command
skip_this_line = False
if code.index(pure_command) in skip_lines:
skip_this_line = True
skip_lines.remove(code.index(pure_command))
for name in variables_name:
if " " + name in command and not skip_this_line:
if "endocytosis " not in command and "grow " not in command and "exosmosis " not in command and "multinucleate " not in command and "mitosis " not in command and "meiosis " not in command and "fuse " not in command:
command = command.replace(" " + name, " " + str(variables_value[variables_name.index(name)]))
cell_contains_error = False
if not(skip_this_line):
if "exocytosis " in command:
output = command.replace("exocytosis ", "")
print(output)
elif "endocytosis " in command:
variable_name = command.replace("endocytosis ", "")
if variable_name in variables_name:
variables_value[variables_name.index(variable_name)] = input()
else:
cell_contains_error = True
elif "skip " in command:
skip_amount = (command.replace("skip ", ""))
try:
for after_index in range(1, int(skip_amount)+1):
index = code.index(pure_command) + after_index
skip_lines.append(index)
except:
cell_contains_error = True
elif "regulate ^ " in command:
try:
cell_number = int(command.replace("regulate ^ ", ""))
line = cell_number - 2
if line < -1:
line = -1
except:
cell_contains_error = True
elif ">" in command or ">" == command:
break
elif "eject " in command:
try:
variable_name = command.replace("eject ", "")
temporary_iterator = ""
for character in variable_name:
if character == ",":
break
else:
temporary_iterator = temporary_iterator + character
variable_name = temporary_iterator
add_value = command.replace("eject ", "")
add_value = add_value.replace(variable_name + ",", "")
try:
variables_value[variables_name.index(variable_name)] = int(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] -= int(add_value)
except:
variables_value[variables_name.index(variable_name)] = str(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] = variables_value[variables_name.index(variable_name)].replace(str(add_value), "")
except:
cell_contains_error = True
elif "mitosis " in command:
try:
variable_name = command.replace("mitosis ", "")
temporary_iterator = ""
for character in variable_name:
if character == ",":
break
else:
temporary_iterator = temporary_iterator + character
variable_name = temporary_iterator
add_value = command.replace("mitosis ", "")
add_value = add_value.replace(variable_name + ",", "")
try:
variables_value[variables_name.index(variable_name)] = int(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] /= int(add_value)
except:
variables_value[variables_name.index(variable_name)] = str(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] = variables_value[variables_name.index(variable_name)].replace(str(add_value), "")
except:
cell_contains_error = True
elif "grow " in command:
try:
variable_name = command.replace("grow ", "")
temporary_iterator = ""
for character in variable_name:
if character == ",":
break
else:
temporary_iterator = temporary_iterator + character
variable_name = temporary_iterator
add_value = command.replace("grow ", "")
add_value = add_value.replace(variable_name + ",", "")
try:
variables_value[variables_name.index(variable_name)] = int(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] += int(add_value)
except:
variables_value[variables_name.index(variable_name)] = str(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] += str(add_value)
except:
cell_contains_error = True
elif "multinucleate " in command:
try:
variable_name = command.replace("multinucleate ", "")
temporary_iterator = ""
for character in variable_name:
if character == ",":
break
else:
temporary_iterator = temporary_iterator + character
variable_name = temporary_iterator
add_value = command.replace("multinucleate ", "")
add_value = add_value.replace(variable_name + ",", "")
try:
variables_value[variables_name.index(variable_name)] = int(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] *= int(add_value)
except:
variables_value[variables_name.index(variable_name)] = str(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] += str(add_value)
except:
cell_contains_error = True
elif "fuse " in command:
try:
variable_name = command.replace("fuse ", "")
temporary_iterator = ""
for character in variable_name:
if character == ",":
break
else:
temporary_iterator = temporary_iterator + character
variable_name = temporary_iterator
add_value = command.replace("fuse ", "")
add_value = add_value.replace(variable_name + ",", "")
try:
variables_value[variables_name.index(variable_name)] = float(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] *= float(add_value)
except:
variables_value[variables_name.index(variable_name)] = str(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] += str(add_value)
except:
cell_contains_error = True
elif "meiosis " in command:
try:
variable_name = command.replace("meiosis ", "")
temporary_iterator = ""
for character in variable_name:
if character == ",":
break
else:
temporary_iterator = temporary_iterator + character
variable_name = temporary_iterator
add_value = command.replace("meiosis ", "")
add_value = add_value.replace(variable_name + ",", "")
try:
variables_value[variables_name.index(variable_name)] = float(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] /= float(add_value)
except:
variables_value[variables_name.index(variable_name)] = str(variables_value[variables_name.index(variable_name)])
variables_value[variables_name.index(variable_name)] = variables_value[variables_name.index(variable_name)].replace(str(add_value), "")
except:
cell_contains_error = True
else:
cell_contains_error = True
if cell_contains_error:
print("Error in cell::" + str(code.index(pure_command) + 1) + "::" + pure_command)
break
win = tkinter.Tk()
win.title("Fried Chicken")
win.configure(padx=20, pady=20)
btn1 = tkinter.Button(text="Browse Code File And Run In Console", command=execute)
btn1.pack()
win.mainloop()