Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
43
Task/Execute-Brain-/PARI-GP/execute-brain-.parigp
Normal file
43
Task/Execute-Brain-/PARI-GP/execute-brain-.parigp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
BF(prog)={
|
||||
prog=Vec(Str(prog));
|
||||
my(codeptr,ptr=1,v=vector(1000),t);
|
||||
while(codeptr++ <= #prog,
|
||||
t=prog[codeptr];
|
||||
if(t=="+",
|
||||
v[ptr]++
|
||||
,
|
||||
if(t=="-",
|
||||
v[ptr]--
|
||||
,
|
||||
if(t==">",
|
||||
ptr++
|
||||
,
|
||||
if(t=="<",
|
||||
ptr--
|
||||
,
|
||||
if(t=="[" && !v[ptr],
|
||||
t=1;
|
||||
while(t,
|
||||
if(prog[codeptr++]=="[",t++);
|
||||
if(prog[codeptr]=="]",t--)
|
||||
);
|
||||
);
|
||||
if(t=="]"&&v[ptr],
|
||||
t=1;
|
||||
while(t,
|
||||
if(prog[codeptr--]=="[",t--);
|
||||
if(prog[codeptr]=="]",t++)
|
||||
)
|
||||
);
|
||||
if(t==".",
|
||||
print1(Strchr(v[ptr]))
|
||||
);
|
||||
if(t==",",
|
||||
v[ptr]=Vecsmall(input)[1]
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue