forked from sorear/metamath-turing-machines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbms.nql
67 lines (67 loc) · 1.31 KB
/
bms.nql
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
/*
Based on a program by Patcail
https://discord.com/channels/206932820206157824/376768078450786304/1276039180710969386
*/
global big_num;
global child;
global i;
global j;
global m_copy;
global matrix;
global newEl;
global order;
global rows;
global t2;
global threshold;
proc extract(to, from){
to = 0;
t2 = from - ((from / 2) * 2);
while(t2 == 1){
to = to + 1;
from = from / 2;
t2 = from - ((from / 2) * 2);
}
}
proc main(){
if(rows == 0){
rows = 2;
/* 0b11011011 */
matrix = 219;
order = 1;
}
if(order == 0){
order = rows;
}
order = order - 1;
threshold = order;
m_copy = matrix;
extract(newEl, matrix);
child = newEl;
i = 0;
while(i < child){
m_copy = matrix;
j = 0;
while(j < child){
extract(newEl, m_copy);
m_copy = m_copy / 2;
j = j + 1;
}
extract(newEl, m_copy);
if(newEl > threshold){
newEl = newEl + child;
}
threshold = threshold + 1;
j = 0;
while(j < newEl){
matrix = matrix * 2;
matrix = matrix + 1;
j = j + 1;
}
i = i + 1;
}
matrix = matrix / 2;
big_num = big_num + 1;
if(matrix == 0){
return;
}
}