Farmer, cabbage, goat, wolf

Farmer, Cabbage, Goat, Wolf

This is a pretty well known logic puzzle. However if you dont know it, it goes something like this.

A farmer has a wolf, goat, and cabbage on one side of the river. He needs to transport everything across the river in a small boat that can hold only himself and one other thing. He can’t leave the wolf and goat by themselves, he also cannot leave the goat with the cabbage. How does he get everything across?

In the post I build an adjacency matrix and use a dfns to get the shortest path through the graph.

2 Likes

@Ezno @F73x I suggest you grab the styles.css and www directory from the apl-study repo to get nice formatting of APL.

1 Like