Harry Potter and the hall of 100 doors
Here is a classic puzzle wrapped in a silly piece of fan fiction I wrote.
In their frantic pursuit of the Dark Lord, Harry Potter and his friends found themselves at the end of a long hallway, open doors along one side, as far as the eye can see.
“What is this place?” asked Harry.
“Haven’t you read Hogwarts, a History by now, Harry?” asked Hermione.
“I think I’ve been pretty busy saving all your asses over the years, thank you very much. Why don’t you just tell me.”
“Well alright. This is clearly the Hall of One Hundred Doors!”
“Great,” said Ron. “Now can we get going? He’s getting away.”
“Not yet,” replied Hermione. “If we pass through without ﬁrst closing exactly the correct doors, we face certain peril.”
“So which doors do we close?” asked Harry and Ron in unison.
“I’m not sure,” mused Hermione. “The problem is, it’s not that simple. The legend states that one must ﬁrst close every door; all 100. Then you go back and open ever other door. After that, you go to every third door and open the closed ones, and close the open ones. Then again to every 4th door. And you keep doing this until you only open or close the 100th door.”
“That will take forever,” whined Ron. “We’ll never catch up to him now.”
“What if we could just close the doors that would be closed after that long process?” asked Harry. “Would that work?”
“Well yes, of course. But how in the name of Dumbledore will we know which ones to close?”
“Come on,” yelled Harry, already closing the ﬁrst door. “I’ll explain as we go!”
And with that, the three friends set down the hall, closing the correct doors as they went. But which doors was Harry closing? And how did he know?