Can You Solve the Virus Riddle?

In this video riddle, you're a researcher who needs to solve a math problem. The fate of humanity is at stake!

Here's the setup. Your research group has isolated a lethal virus and is studying it in a lab. But one night after you leave the lab, an earthquake strikes and breaks the virus vials. This means that 15 of the 16 rooms in the lab are contaminated, and you have to get past the lab's security system in order to destroy the virus. (There is time pressure, as eventually the virus will escape the lab and kill us all!)

The lab is built as a 4x4 grid, containing a total of 16 rooms, with an entrance at the northwest corner and an exit at the southeast corner. Each room is connected to the adjacent rooms by an airlock. Only the entrance and exit rooms are connected to the outside. The virus has been released in every room except the entrance room.

To destroy the virus samples, you must enter each room and pull its self-destruct switch, destroying the room and the virus within it. But there's a problem—because the lab is in lockdown mode, once you enter a contaminated room, you can't exit without activating the self-destruct switch. Furthermore, once the self-destruct switch has been activated, you cannot re-enter a contaminated room.

Your job is to enter through the entrance room, exit through the exit room, and destroy the virus in every contaminated room. How can you do it?

From the video (at the 1:41 mark), here are the official rules and restrictions:

1. You must enter the building through the entrance and leave through the exit. 2. Every room except the entrance is contaminated. 3. Once you enter a contaminated room, you must pull the switch. 4. After pulling the switch, you must immediately leave the room. 5. You cannot return to a room after its switch has been activated.

Watch the video below for a visual explanation of the problem. This one's a bit of a forehead-smacker when you see the solution.

For more on this puzzle (and its solution), check out this TED-Ed page.

Note: If you're interested in math (without puzzle spoilers), this problem is related to Hamiltonian Paths, or paths that visit each point exactly once.