% there are n teams - the number of teams is odd % so, we assume that it is of the form 2k+1 % and will receive the input k % and define a constant n const n = 2*k + 1. team(1..n). #domain team(T1;T2;T3). % each pair of teams (X,Y) plays one game, at the location % of the first team or the second team 1 { game(X,Y,Z) : good_location(X,Y,Z)} 1 :- team(X), team(Y), X > Y. good_location(T1,T2,T1). good_location(T1,T2,T2). % this is to count the number of games plays at a location % X,Y plays at one location is the same as Y,X plays at the same % location play_at(T1,T2,T3) :- game(T1,T2,T3). play_at(T2,T1,T3) :- game(T1,T2,T3). % there should be only k games at each location -- we count each % game as play twice so there should be only 2k games at each % location -- if there are more than that (2k+1 is n) it is % not a good schedule :- n { play_at(X,Y,Z) : team(X) : team(Y) }, team(Z). hide team(_). hide good_location(_,_,_). hide play_at(_,_,_).