Description
Write a Lisp program that generates a list containing all legal successor states for any state in the Missionaries and Cannibals problem. Your program should be invoked by the function call:
(mac-next state)
where state is of the form (m,n,b), with m representing the number of missionaries (0-3) on the left bank, n representing the number of cannibals (0-3) on the left bank, and b representing whether the boat is on the right side (r) or the left side (I) of the river.
For example:
(mac-next (33I)) => ((22r) (32r) (31r))
(mac-next (31r)) => ((32I) (33l))
(mac-next (33r)) => nil
Your function should check whether the inputted state is in the proper format. If not, an error message should be displayed instead of the list of successor states.
Tangela Arnwine –
Tutor wrote it quickly and effectively. Great solution.
David Leedberg –
Second time coming to this website for a paper and it worked out great.