Skip to content

Instantly share code, notes, and snippets.

@adithya-badidey
Created October 30, 2021 16:38
Show Gist options
  • Save adithya-badidey/5ebb114b3d69e075b57f8f7ce18b2f3f to your computer and use it in GitHub Desktop.
Save adithya-badidey/5ebb114b3d69e075b57f8f7ce18b2f3f to your computer and use it in GitHub Desktop.
kattis.com Testcase Evaluator for Python
#!/bin/bash
## Directory Structure
# problem-folder/
# ├─ 1.in
# ├─ 1.ans
# ├─ ...
# ├─ main.py <- Your source file
# ├─ tester.sh
# > ./tester.sh
for ((i = 1 ; i <= 1000 ; i++)); do
if [ ! -f "$i.in" ]; then
# printf $i".in not found\n"
exit 0
fi
rm "$i".test
python main.py < $i.in > $i.test
if cmp -s "$i".ans "$i".test; then
printf "Testcase $i passes\n"
else
printf "++++++++++++++++++++++\n"
printf "\n"
printf "Testcase $i failed\n"
printf "\n"
printf "==== Your solution ===\n"
cat "$i".test
printf "=== Actual solution ==\n"
cat "$i".ans
printf "\n"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment