59
12
Write a program that will generate a "true" output iff the input matches the source code of the program, and which generates a "false" output iff the input does not match the source code of the program.
This problem can be described as being related to quines, as the program must be able to somehow compute its own source code in the process.
This is code golf: standard rules apply. Your program must not access any special files, such as the file of its own source code.
Edit: If you so choose, true/false can be replaced with True/False or 1/0.
Example
If the source code of your program is bhiofvewoibh46948732));:/)4
, then here is what your program must do:
Input (Stdin)
bhiofvewoibh46948732));:/)4
Output (Stdout)
true
Input
(Anything other than your source code)
Output
false
7Is the
true
/false
output a strong requirement, or are variations (True
/False
,1
/0
) acceptable as well? – Cristian Lupascu – 2013-04-17T14:54:32.463Is it a problem if the program outputs a little more than true/false (if it keeps being unambiguous and ends with true/false) ? – Denys Séguret – 2013-04-19T11:31:01.993
5So you mean a Narcissist program? – PyRulez – 2017-07-15T05:57:22.700
1
Related: Interpret your lang, but not yourself?
– Ilmari Karonen – 2014-01-11T05:28:09.953Very much related – Deadcode – 2020-01-20T07:37:59.573