aboutsummaryrefslogtreecommitdiff
path: root/doc/problemexamples/problemtemplate/compare/py3
diff options
context:
space:
mode:
authorBruno Ribas <brunoribas@gmail.com>2016-11-04 17:13:59 +0000
committerBruno Ribas <brunoribas@gmail.com>2016-11-04 17:13:59 +0000
commitda1ef60ac7e8ebe530b0502473c1d59c06970f15 (patch)
tree4909994d211601e7f64b6f8990c60493cf9063b8 /doc/problemexamples/problemtemplate/compare/py3
parent48401f08bea422bdfbf273e904947d9abbfc4659 (diff)
downloadboca-da1ef60ac7e8ebe530b0502473c1d59c06970f15.tar.gz
boca-da1ef60ac7e8ebe530b0502473c1d59c06970f15.zip
problemtemplate: Adding py2 and py3 support
Tests scripts for both py2 and py3 are working. Signed-off-by: Bruno Ribas <brunoribas@gmail.com>
Diffstat (limited to 'doc/problemexamples/problemtemplate/compare/py3')
-rwxr-xr-xdoc/problemexamples/problemtemplate/compare/py397
1 files changed, 97 insertions, 0 deletions
diff --git a/doc/problemexamples/problemtemplate/compare/py3 b/doc/problemexamples/problemtemplate/compare/py3
new file mode 100755
index 0000000..4998be3
--- /dev/null
+++ b/doc/problemexamples/problemtemplate/compare/py3
@@ -0,0 +1,97 @@
+#!/bin/bash
+# ////////////////////////////////////////////////////////////////////////////////
+# //BOCA Online Contest Administrator
+# // Copyright (C) 2003-2012 by BOCA Development Team (bocasystem@gmail.com)
+# //
+# // This program is free software: you can redistribute it and/or modify
+# // it under the terms of the GNU General Public License as published by
+# // the Free Software Foundation, either version 3 of the License, or
+# // (at your option) any later version.
+# //
+# // This program is distributed in the hope that it will be useful,
+# // but WITHOUT ANY WARRANTY; without even the implied warranty of
+# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# // GNU General Public License for more details.
+# // You should have received a copy of the GNU General Public License
+# // along with this program. If not, see <http://www.gnu.org/licenses/>.
+# ////////////////////////////////////////////////////////////////////////////////
+# // Last modified 21/jul/2012 by cassio@ime.usp.br
+#
+# This script receives:
+# $1 team_output
+# $2 sol_output
+# $3 problem_input (might be used by some specific checkers, here it is not)
+#
+# BOCA reads the last line of the standard output
+# and pass it to judges
+#
+if [ ! -r "$1" -o ! -r "$2" ]; then
+ echo "Parameter problem"
+ exit 43
+fi
+
+# Next lines of this script just compares team_output and sol_output,
+# although it is possible to change them to more complex evaluations.
+
+diff -q "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff \"$1\" \"$2\" # files match"
+ echo "Files match exactly"
+ exit 4
+fi
+diff -q -b "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b \"$1\" \"$2\" # files match"
+ echo -e "diff -c \"$1\" \"$2\" # files dont match - see output"
+ diff -c "$1" "$2"
+ echo "Files match with differences in the amount of white spaces"
+ exit 5
+fi
+diff -q -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b "$1" "$2"
+ echo "Files match with differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -i -b -B "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B "$1" "$2"
+ echo "Files match if we ignore case and differences in the amount of white spaces and blank lines"
+ exit 5
+fi
+diff -q -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B "$1" "$2"
+ echo "Files match if we discard all white spaces"
+ exit 5
+fi
+diff -q -i -b -B -w "$1" "$2" >/dev/null 2>/dev/null
+if [ "$?" == "0" ]; then
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files match"
+ echo -e "diff -c -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -b -B -w "$1" "$2"
+ echo "Files match if we ignore case and discard all white spaces"
+ exit 5
+fi
+wd=`which wdiff`
+if [ "$wd" != "" ]; then
+ wdiff \"$1\" \"$2\" >/dev/null 2>/dev/null
+ if [ "$?" == "0" ]; then
+ echo -e "wdiff \"$1\" \"$2\" # files match"
+ echo -e "diff -c -i -b -B -w \"$1\" \"$2\" # files dont match - see output"
+ diff -c -i -b -B -w "$1" "$2"
+ echo "BUT Files match if we compare word by word, ignoring everything else, using wdiff"
+ echo "diff has a bug that, if a line contains a single space, this is not discarded by -w"
+ exit 5
+ fi
+fi
+echo -e "### files dont match - see output"
+diff -c -i -b -B -w "$1" "$2"
+echo "Differences found"
+exit 6