This question already has an answer here:
In The Sorcerer's Stone Harry and Quirrell have to get through a series of challenges to get the stone. But they all have a solution. For example, the flying keys: you find the right key, you get through. The chessboard: win the game, you pass through.
Why wouldn't Hogwarts simply put a spell on it that allowed no one to pass except Dumbledore, Nicolas Flamel, and a few others? I am sure there are spells that could do that, so why weren't they used?