a light bulb goes on in (one's) brain
One is suddenly struck with an ingenious or inspired idea, insight, or revelation. We spent hours trying to come up with a solution, when suddenly a light bulb went on in my brain. I kept feeding him subtle hints about the truth of the matter, waiting for a light bulb to go on in his brain.