#!/bin/bash

# check-graph-colouring.sh
#
# Martin Brain
# mjb@cs.bath.ac.uk
# 20/03/09
#
# Checks the solution to an graph colouring problem
#
# Marcello Balduccini
# marcello.balduccini@gmail.com
# Jan 14, 2011
# Modified to comply with the requirements of ASPCOMP2011.
#

if [ -z $GROUNDER ]; then
    GROUNDER=gringo
fi

if [ -z $SOLVER ]; then
    SOLVER=clasp
fi

DIRNAME=`dirname $0`
REFERENCE_ENCODING=$DIRNAME/colour.lp
CHECK_SWITCH=$DIRNAME/check-switch.lp

cat $REFERENCE_ENCODING $CHECK_SWITCH - | $GROUNDER | $SOLVER | grep -q "^Answer: "

if [ $? = 0 ]; then
    echo "OK";
else
    echo "FAIL";
fi


