Last active
October 21, 2018 19:26
-
-
Save patrickbucher/5eb6f1d39ce9002423f4fffa531b90cf to your computer and use it in GitHub Desktop.
Will Hamilton become World Champion in the 2018 US Grand Prix?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- use_module(library(clpfd)). | |
points(1, 25). | |
points(2, 18). | |
points(3, 15). | |
points(4, 12). | |
points(5, 10). | |
points(6, 8). | |
points(7, 6). | |
points(8, 4). | |
points(9, 2). | |
points(10, 1). | |
current(hamilton, 331). | |
current(vettel, 264). | |
current(bottas, 207). | |
current(raikkoennen, 196). | |
driverchampion(Hamilton, Vettel) :- | |
Hamilton #\= Vettel, | |
H1 + H #> V1 + V + 75, | |
current(hamilton, H1), | |
current(vettel, V1), | |
points(Hamilton, H), | |
points(Vettel, V), | |
label([H, V, H1, V1]). | |
constructorchampion(Hamilton, Bottas, Vettel, Raikkoennen) :- | |
current(hamilton, H1), | |
current(bottas, B1), | |
current(vettel, V1), | |
current(raikkoennen, R1), | |
points(Hamilton, H), | |
points(Bottas, B), | |
points(Vettel, V), | |
points(Raikkoennen, R), | |
H + H1 + B + B1 #> V + V1 + R + R1 + 3 * (25 + 18), | |
all_distinct([Hamilton, Bottas, Vettel, Raikkoennen]), | |
label([H, H1, B, B1, V, V1, R, R1]). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
swipl formula1.pl ?- driverchamption(Hamilton, Vettel).