There was a great SF story I read some time ago (probably 25+ years ago) where there was a well known treasure trove, guarded by a killer robot that would ask all comers a series of difficult questions from all areas (math, physics, literature, history, etc.) But everyone eventually failed and died... until the last person managed to make it past the robot:
By just answering gibberish to the robot. Unfortunately, after collecting a ton of treasure, the robot casually asked him why he wanted it, he answered in a sensible way (something like "because it's valuable"), and the robot killed him, because he failed the final test.
Any ideas who wrote this? What it was titled?