![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.](https://gotit-pro.com/wp-content/uploads/2023/10/69008673-ee0c-45df-9bee-67b55b580a1f.png)
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.
![](https://gotit-pro.com/wp-content/uploads/2021/05/info.png)