Programming Brain Teaser #2: Self-reference
Let’s continue where we stopped last time with our robot programming language. We’ll need only two rules today, the Q rule (quotation) and the R rule (repetition). Should you need to refresh your memory, the rules are described here.
The brain-teaser of the day is: can you find statement x that names itself (i.e. “resolves to string” x)?
Are there more of them or just one? Find the self-reference statement pattern or explain why there is no such pattern and only one self-referencing statement exists in this programming language.
Side note: this question is similar to what is in computer science known as quine. It is a program that has no input and prints its own source code on its output. After solving the brain-teaser here, you can apply the same idea and create a quine in your favorite programming language.
« Programming Brain Teaser #1: Getting Started - Programming Brain Teaser #3: Repetition riddle »