In this riddle from TED-Ed, you've got a tricky math problem to solve.

In the riddle, you're trying to infiltrate the headquarters of an enemy organization, locate a secret control panel, and shut down their death ray. There are various reasons why this isn't easy.

First off, the enemy headquarters is a ten-story pyramid. It has a regular structure, where the top level contains one room, the floor below that has two rooms, and so on—the ground floor has 10 rooms. The control panel is hidden behind a painting, on the highest floor that satisfies the conditions listed below.

Each room has exactly three doors to three other rooms on that floor...except the control panel room, which only connects to one room. (Thus, the control panel room only has one door in it.)

There are no hallways, and you can ignore stairs while figuring the layout of the building.

You have no floor plan.

You only have enough time to search a single floor before the alarm system goes off.

Given the rules above, can you figure out which floor the control room (with its associated control panel) is on? Watch this video, and pause at the one-minute mark (when instructed), for a video view of the same problem. The solution is then presented, with a step-by-step breakdown of how to get there.

To figure out the solution, it may help to start drawing room maps, starting at the highest floor. If you're interested in this kind of puzzle, read up on graph theory.

For more on this puzzle, check out this TED-Ed page, and be sure to visit the "Dig Deeper" section, which includes links to the puzzle author's website, Doctor Ecco.