-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
72 lines (60 loc) · 1.48 KB
/
Copy pathtest2.py
File metadata and controls
72 lines (60 loc) · 1.48 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
def assign(types) :
memory = ""
pointer = 0
for type in types :
##BOOL
if type == "BOOL" :
pointer +=1
memory += "#"
##SHORT
elif type == "SHORT" :
while pointer %2 != 0 :
pointer +=1
memory += "."
for i in range(2) :
memory += "#"
pointer +=1
##FLOAT
elif type == "FLOAT" :
while pointer %4 != 0 :
pointer +=1
memory += "."
for i in range(4) :
memory += "#"
pointer +=1
##INT
elif type == "INT" :
while pointer %8 != 0 :
pointer +=1
memory += "."
for i in range(8) :
memory += "#"
pointer +=1
##LONG
else :
while pointer %8 != 0 :
pointer +=1
memory += "."
for i in range(16):
memory += "#"
pointer +=1
##OVERFLOW
if pointer > 128 :
return "HALT"
else :
while pointer %8 != 0 :
pointer +=1
memory += '.'
return memory
c = ["INT","INT","BOOL","SHORT","LONG"]
types1 = ["INT","SHORT","FLOAT","INT","BOOL"]
types2 = ["FLOAT","SHORT","BOOL","BOOL","BOOL","INT"]
types3= ["LONG","LONG","LONG","LONG","LONG","LONG","LONG","LONG",]
types4 = ["BOOL","LONG","SHORT","LONG","BOOL","LONG","BOOL","LONG","SHORT","LONG","LONG"]
answer = assign(types2)
if answer == "HALT" :
print("HALT")
else :
for i in range(len(answer)//8-1) :
print(answer[8*i : 8*(i+1)], end =",")
print(answer[-8:-1])