"I thought that that was the answer."

Back to my school days, I learned that when a word is used like this in a sentence, the two occurrences should be separated by a comma as in:

"Did you know that, that was the way we were going?"