A similar anecdote about Turing appears in Neal Stephenson's "Cryptonomicon", except without the clever solution or the "absent-minded professor" stereotype.