3 ms·
There is one interesting conclusion to be derived from this exercise - in Python, '%r' is a fixed point of the function f(x)=x%x. And yes, this is the most bor
by Asooka 4y ago
There is one interesting conclusion to be derived from this exercise - in Python, '%r' is a fixed point of the function f(x)=x%x.
And yes, this is the most boring quine, you've punted the problem to the formatting mini-language and solved it in a manner equivalent of print(open(argv[0]).read()). I would say perhaps the ideal formulation for producing an interesting quine that doesn't leverage other languages would be "write a quine in C, using no preprocessor directives and no external functions except the POSIX write function, you may assume stdout is 1". So your program would look like:
extern long write(int, const void *, unsigned long);
int main(int, char**) {
/* your code here, using write(1, buf, count) for output */
return 0;
}
You would of course end up writing a function equivalent to 'x%x' in Python, but getting there is a bit more exciting.
- panzi 4y agoOr write a binary quine that doesn't read it's own program memory. I wrote a Python script that generates appropriate NASM code: https://github.com/panzi/binary-quine https://github.com/panzi/binary-quine Did it that way so I don't need to learn about the ELF format, but use several passes to get a binary that is a quine.