What you have been obliged to discover by yourself leaves a path in your
mind which you can use again when the need arises. — G. C. Lichtenberg
I am not familiar with Lichtenberg but he was apparently a German physictists from the 1742 to 1799.
Added quote from Project Euler, the context is sharing one’s solution.
Real learning is an active process and seeing how it is done is a long way from experiencing that epiphany of discovery. Please do not deny others what you have so richly valued yourself.
Added quote attributed to Plato, not quite about the magic of discovery but somewhat related.
Do not train a child to learn by force or harshness; but direct them to it by what amuses their minds, so that you may be better able to discover with accuracy the peculiar bent of the genius of each.