mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-20 20:16:26 +02:00
Merge branch 'master' of ssh://github.com/engineer-man/piston
This commit is contained in:
commit
f358b58cb6
8 changed files with 73 additions and 2 deletions
|
@ -1,4 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd /tmp/$1
|
||||
timeout -s KILL 3 xargs -a args.args -d '\n' brainfuck code.code < stdin.stdin
|
||||
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
|
||||
|
||||
# Merging args.args and stdin.stdin for emkc challenges
|
||||
cat stdin.stdin >> args.args
|
||||
|
||||
# execution
|
||||
timeout -s KILL 3 ./binary < args.args
|
||||
|
|
9
lxc/executors/prolog
Executable file
9
lxc/executors/prolog
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd /tmp/$1
|
||||
|
||||
sed 's/^.*$/:- forall((Goal = (\0), call(Goal)), (write(Goal), nl))./' input.input |
|
||||
cat code.code - > code.pl
|
||||
|
||||
timeout -s KILL 3 swipl -g true -t halt code.pl
|
||||
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
cd /tmp/$1
|
||||
cp code.code main.zig
|
||||
timeout -s KILL 10 zig build-exe main.zig
|
||||
timeout -s KILL 10 zig build-exe main.zig && \
|
||||
timeout -s KILL 3 xargs -a args.args -d '\n' ./main
|
||||
|
|
|
@ -52,6 +52,8 @@ echo -n 'testing perl = '
|
|||
../../cli/execute perl perl.pl
|
||||
echo -n 'testing php = '
|
||||
../../cli/execute php php.php
|
||||
echo -n 'testing prolog = '
|
||||
../../cli/execute prolog prolog.pl
|
||||
echo -n 'testing python2 = '
|
||||
../../cli/execute python2 python2.py
|
||||
echo -n 'testing python3 = '
|
||||
|
|
1
lxc/tests/prolog.pl
Normal file
1
lxc/tests/prolog.pl
Normal file
|
@ -0,0 +1 @@
|
|||
:- write('good'), nl.
|
|
@ -105,6 +105,10 @@ echo 'php'
|
|||
lxc-attach --clear-env -n piston -- /bin/bash -l -c "php -v"
|
||||
echo '---'
|
||||
|
||||
echo 'prolog'
|
||||
lxc-attach --clear-env -n piston -- /bin/bash -l -c "swipl --version"
|
||||
echo '---'
|
||||
|
||||
echo 'python2'
|
||||
lxc-attach --clear-env -n piston -- /bin/bash -l -c "python -V"
|
||||
echo '---'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue