Blast from the past. This is one of the puzzles from my early days:
Can you write a method (a function) which when called outputs its own source - literally including all the quotes, indentations, etc?
No cheating - no reading from a file
Blast from the past. This is one of the puzzles from my early days:
Can you write a method (a function) which when called outputs its own source - literally including all the quotes, indentations, etc?
No cheating - no reading from a file
This is known as a “quine”. As it's a pretty standard puzzle, there are already lots of solutions out there; a better challenge might be a more specific puzzle that adds an additional constraint.
I had never heard of it before. Thought about it, then gave in to curiosity and looked it up. This page has many different ways to solve the puzzle in most languages. http://www.nyx.net/~gthompso/quine.htm
Thanks for the mental twister.