Hmm, perhaps a higher-level explanation:
First I considered everything involved: a boat, the side of the river everything is on, the other side of the river when they are trying to get to, a man, a fox, a goose, and beans.
I decided I could treat the man, fox, goose, and beans as items I wanted to move around. I could treat the riverbanks and boat as containers of items. I would move items from one container to another—riverbank, into the boat, across the river, and out of the boat onto the other river bank. I just needed to program the rules for what could be left on a bank, what could go into a boat, and moving items between the containers. Whenever I moved items from one container to another I would output the result.
Example some logic: when passengers get on the boat, they are removed from the riverbank and added to the boat:
current_bank = current_bank – passengers
boat = boat + passengers
Example checking one of the rules, if a set of passengers is allowed on the boat
(boat + passengers).okay?