Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
d(faerun, tristram, 65). d(faerun, tambi, 129). d(faerun, norrath, 144). d(faerun, snowdin, 71). d(faerun, straylight, 137). d(faerun, alphacentauri, 3). d(faerun, arbre, 149). d(tristram, tambi, 63). d(tristram, norrath, 4). d(tristram, snowdin, 105). d(tristram, straylight, 125). d(tristram, alphacentauri, 55). d(tristram, arbre, 14). d(tambi, norrath, 68). d(tambi, snowdin, 52). d(tambi, straylight, 65). d(tambi, alphacentauri, 22). d(tambi, arbre, 143). d(norrath, snowdin, 8). d(norrath, straylight, 23). d(norrath, alphacentauri, 136). d(norrath, arbre, 115). d(snowdin, straylight, 101). d(snowdin, alphacentauri, 84). d(snowdin, arbre, 96). d(straylight, alphacentauri, 107). d(straylight, arbre, 14). d(alphacentauri, arbre, 46). % Make facts symmetric. f(X,Y,Z) :- d(X,Y,Z). f(X,Y,Z) :- d(Y,X,Z). % All possible routes locations(List) :- setof(X, (Y,Z)^f(X,Y,Z), Locations), permutation(Locations,List). % Calculate route length route_length([],0). route_length([_],0). route_length([X,Y|Tail],Distance) :- f(X,Y,D1), route_length([Y|Tail],D2), Distance is D1 + D2. distance(Distance) :- locations(Z), route_length(Z,Distance). shortest_distance(Distance) :- aggregate(min(D, _), distance(D), min(Distance, _)). longest_distance(Distance) :- aggregate(max(D, _), distance(D), max(Distance, _)).