I decided to study prolog just for fun, I'm watching some video tutorials. Also I searched on the internet some problems to try to solve, but Can't find a way to solve this.
I was able to solve this puzzle on paper, but I can't pass it into code.
The problem:
I have 8 candidates (Lia, Mel, Nanda, Olga, Rute, Sara, Tina, Pilar).
They will all be tested from Monday to Friday on the time 8:00 and 9:00.
And I have some rules like:
Sara HAS TO be tested on Wednesday at 9.
No girl will be tested on Wednesday at 8.
Pilar HAS TO tested BEFORE Nanda.
Olga HAS TO be tested in same day of Mel.
IF Lia is tested at 8 of any day, so Rute HAS TO be tested at 8 in a different day.
I don't want full solution, I just want some help to start with this.
I was trying to write something but without success.
% Facts %
candidate(lia).
candidate(mel).
candidate(nanda).
candidate(olga).
candidate(pilar).
candidate(rute).
candidate(sara).
candidate(tina).
day(monday).
day(tuesday).
day(wednesday).
day(thursday).
day(friday).
time(8).
time(9).
/*Sara HAS TO be tested on Wednesday at 9*/
tested_on(sara, wednesday, 9).
/*No test will happen on Wednesday at 8*/
no_test(X, wednesday, 8) :- X == none.
I was even trying to build a struct
cand(
sara,
date(wednesday, 9)
).
After that my program would have to answer some questions like:
Which would be the right list of candidates to be tested on 8:00 from monday to friday ?
My main idea was to start writing the rules and facts then I'd go through all the rules testing each one. But I can't even write the facts and rules right...