2021-01-17 01:54:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-02-05 16:50:57 +01:00
|
|
|
cd /tmp/$1
|
2021-02-07 22:31:06 +01:00
|
|
|
sedarg="\
|
|
|
|
s/+/P/g;\
|
|
|
|
s/-/M/g;\
|
|
|
|
s/>/++p;/g;\
|
|
|
|
s/</--p;/g;\
|
|
|
|
s/P/++*p;/g;\
|
|
|
|
s/M/--*p;/g;\
|
|
|
|
s/\\./putchar(*p);/g;\
|
|
|
|
s/,/*p=(c=getchar())==EOF?0:c;/g;\
|
|
|
|
s/\\[/while(*p){/g;\
|
|
|
|
s/]/}/g\
|
|
|
|
"
|
|
|
|
|
|
|
|
# compilation
|
|
|
|
MEMSIZE=15
|
|
|
|
cat <<EOF > code.c
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
char mem[1<<$MEMSIZE];
|
|
|
|
char *p = mem + (1<<$((MEMSIZE - 1)));
|
|
|
|
int c;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
$(timeout -s KILL 3 sed 's/[^][<>.,+-]//g' code.code | timeout -s KILL 3 sed $sedarg)
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
timeout -s KILL 3 gcc -std=c11 -o binary code.c
|
|
|
|
|
|
|
|
# execution
|
|
|
|
timeout -s KILL 3 ./binary < args.args < stdin.stdin
|