#!/bin/bash
if test $# -eq 0
then
	echo Usage: $0 pythonprog.py
	exit 1
fi
PROG=$1
if test $# -eq 2
then
	TIME=time
else
	TIME=""
fi
testcase=1

while true
do
	infile=`printf "../../data/sample/%d.in" $testcase`
	ansfile=`printf "../../data/sample/%d.ans" $testcase`
	if ! test -e "$infile"
	then
		break
	fi
	$TIME python3 $PROG < $infile >z
	diff $ansfile z >zz
	if test -s zz
	then echo $ansfile
		cat zz
	fi
	testcase=$((testcase+1))
done

testcase=1001

for infile in ../../data/secret/*.in
do
#	infile=`printf "../../data/secret/%d.in" $testcase`
	ansfile=${infile/.in/.ans}
	if ! test -e "$infile"
	then
		break
	fi
	$TIME python3 $PROG < $infile >z
	diff $ansfile z >zz
	if test -s zz
	then echo $ansfile
		cat zz
	fi
	testcase=$((testcase+1))
done
rm -f z zz
