-
Notifications
You must be signed in to change notification settings - Fork 0
/
kattis
executable file
·52 lines (43 loc) · 904 Bytes
/
kattis
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
#!/bin/sh
clear;
STEP_BY_STEP=0;
SHOW_INPUTS=1;
if [ ! -d "samples" ]; then
mkdir "samples";
fi
if [ ! -d "archive" ]; then
mkdir "archive";
fi
if [ -f "archive/$1.py" ]; then
echo "already found in archive!";
exit 1
fi
if [ ! -d "samples/$1" ]; then
echo "Downloading samples...";
wget -O "samples/$1.zip" "https://open.kattis.com/problems/$1/file/statement/samples.zip";
unzip "samples/$1.zip" -d "samples/$1";
rm "samples/$1.zip";
fi
if [ ! -f "$1.py" ]; then
echo "Problem file created from template:"
cp _kattis.py $1.py;
subl $1.py
exit 1
fi
for ff in `ls samples/$1/*.in`; do
echo $ff;
echo '=== Input ===';
if [ $SHOW_INPUTS != 0 ]; then
cat $ff;
fi;
echo "=== Result ===";
cat $ff | python $1.py;
echo "=== Expected result ===";
oo=`echo $ff | sed 's/\.in/\.ans/'`;
cat $oo;
echo "";
echo "";
if [ $STEP_BY_STEP != 0 ]; then
read canigonext
fi
done