Algorithm · Square · Medium
A boatman stands on one bank of a river with three things he must get to the other side: a fox, a chicken and a sack of grain. His boat can carry him plus at most one of them on each crossing. Whenever he is away from a bank, the items left there must not include an unsafe pair, that is, two items where one would eat the other if left unattended together. Write code that models this puzzle. Specifically, implement: Move generation: given the current state, produce every move…