Question: Write a Prolog program to solve the problem described above. Define a predicate assignment_ok(+Assignment, +Employees) . Assignment is a list of three sub-lists, one for
Write a Prolog program to solve the problem described above. Define a predicate assignment_ok(+Assignment, +Employees). Assignment is a list of three sub-lists, one for each shift. Each sub-list contains the work assignment for that shift: two names for lifeguards, followed by two for the snack bar, followed by one for the front desk. Employees is a list of sub-lists; each sub-list contains an employee's name, then a number (1 or 0) indicating whether the person is qualified to be a lifeguard (1=yes, 0=no), then two nonnegative integers indicating the minimum and maximum number of shifts the person can work. Predicate assignment_ok should succeed if the work assignment is acceptable, and fail if the work assignment is not acceptable.
You may assume that the Assignment and Employees lists will be in the correct format when the function is called; you do not have to error-check for a non-list or an incorrectly formed list. In your program, you may write and call any additional predicates that are helpful in the computation.
Examples:
?- assignment_ok( [[abby, ethan, connor, gabriel, zoe], [sara, gabriel, jasmine, mia, tyler], [abby, sara, jasmine, zoe, lucas]], [[abby, 1, 0, 2], [connor, 0, 1, 3], [ethan, 1, 1, 1], [gabriel, 1, 1, 2], [jasmine, 0, 2, 3], [lucas, 0, 0, 3], [mia, 0, 1, 3], [sara, 1, 1, 2], [tyler, 0, 1, 2], [zoe, 0, 2, 2]] ).
should succeed, and
?- assignment_ok( [[lucas, ethan, connor, gabriel, zoe], [sara, gabriel, jasmine, mia, tyler], [abby, sara, jasmine, zoe, lucas]], [[abby, 1, 0, 2], [connor, 0, 1, 3], [ethan, 1, 1, 1], [gabriel, 1, 1, 2], [jasmine, 0, 2, 3], [lucas, 0, 0, 3], [mia, 0, 1, 3], [sara, 1, 1, 2], [tyler, 0, 1, 2], [zoe, 0, 2, 2]] ).
should fail.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
