I’m new user and i need you help with a prolog program.
The sailing club “Thalassa” recently held a contest for young sailors, with boats of two people. The crew of each vessel was a boy and a girl.
- One member of the crew of the vessel “Ostria” was “Argiris”.
- Magda was neither with “Miltos” nor with “Taki”. “Xronis” and “Maro” was not in the “Albatross” and not finished in 24 minutes.
- “Olga” aboard the “Batis”, while the “Aetos” did not finish in 27 minutes.
- In “Thiella” was or “Miltos” or “Takis” and not aboard the “Basia”.
- “Xara” finished in 16 minutes. “Olga” took more time than “Magda” to finish.
- “Takis” with her partner finished the race in 21 minutes.
Vessel: “Aetos, “Ostria”, “Batis”, “Albantros”, “Thiella”
Men: “Miltos”, “Takis”, “Argiris”, “Xronis”, “Foibos”
wemen: “Maro”, “Olga”, “Basia”, “Magda”, “Xara”
times: “16”, “19”, “21”, “24”, “27”
i need a program to ask ? solve(X) and gives me a list with the right combination
e.g. X=Aetos, Takis, Maro, 16
edit: I missed the “eclipse” tag, so perhaps this isn’t the answer you’re looking for. It works in plain Prolog though, i.e. SWI.
So you do have the enumeration of participants, at least we don’t need to deduce that. Start with it:
Rules: Use the times as values!:
Use
select/2for domain selection:We’re ready to start coding. The most definite statements go first. It is important to not test any variable until it is defined:
This gives me 57 solutions. So perhaps
XronisandMarodo need to be put into same boat. Try it.How to report your answer is an additional concern. The above shows the solver.
One way is to tweak the above code as e.g.
and call it as
?- solve(Men), to see the time assignments for each ofMen. Another is to alter the code as e.g.If you further want to convert the four lists in
Resultinto one transposed list of combined data, you can do that too with few moremaplist/4calls, e.g.