To hit on

to light upon; to come to by chance; to discover unexpectedly; as, he hit on the solution after days of trying.
- Addison.

See also: Hit