How do three lions and three wildebeests, fleeing from a wildfire, cross over to the left bank of a crocodile-infested river to escape the flames? There’s a raft! But there are a few rules that must be followed in order to solve the puzzle: The raft can only hold two animals at a time, at least one animal is needed to row, if lions ever outnumber a wildebeest they’ll eat it, and there’s no swimming.

Pause this video to try and figure it out yourself! Then hit play to find out the answer. Lisa Winer wrote this math and logic lesson based on the classic river crossing puzzle variations (like the fox, chicken, and bag of grain puzzle) attributed to Alcuin. From TED Ed:

Alcuin (735 – 908 CE) was a famous English scholar who was an adviser to the Holy Roman Emperor Charlemagne. Charlemagne loved puzzles and it is believed he hired Alcuin to create them purely for his enjoyment. Alcuin collected puzzles in a book called Propositions ad acuendos iuvenes, or “Problems to sharpen the young.” Variations, such as increasing the number of animals or the size of the raft, began in the 16th century. Another version of this riddle that had an island in between the riverbanks was considered in the 19th century.

If you like math and logic puzzles like this, try the Tower of Hanoi, one of our favorite brainteasers.

Related vids: Can you solve the locker riddle? and Can you solve the frog riddle?