我知道:
Nick = 2*Kate
(Kate + Lea)= 2*Nick
(Chris + Nick)= 2*(Kate + Lea)
Ashley = 24
Ashley + Kate + Lea = 2*(Chris + Nick)
取消一些后,我发现:
Ashley = 12*Kate => Kate = 2
Lea = 3*Kate => Lea = 6
Nick = 2*Kate => Nick = 4
Chris = 6*Kate => Chris = 12
我试过这个:
:- use_module(library(clpfd)).
ages(As) :-
As = [Ashley, Lea, Nick, Chris, Kate],
Ashley #= 24,
12 * Kate #= Ashley,
Lea #= 3*Kate,
Nick #= …Run Code Online (Sandbox Code Playgroud) prolog ×1