Live data from Hacker News

A Quine Puzzle

wgreenberg.github.io

11–20 of 36 posts

Re: A Quine Puzzle

#12

Spoiler: cmVwZWF0IDMgMgpwcmludCAyCnJlcGVhdCAzIDIKcHJpbnQgMgpyZXBlYXQgMyAyCg==

Variant that doesn't rely on potentially undefined behavior of asking "repeat" to repeat before the beginning: cHJpbnQgMApwcmludCAyCnByaW50IDAKcHJpbnQgMgpwcmludCAwCnJlcGVhdCAzIDIKcHJpbnQgMgpyZXBlYXQgMyAyCnByaW50IDIKcmVwZWF0IDMgMgo=

Good eye.

Also, https://github.com/wgreenberg/quine.zip/blob/gh-pages/test/i...

Re: A Quine Puzzle

#14

My solution, featuring only 2 distinct commands, no NOPs, and not relying on `repeat` at the beginning: cHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcmVwZWF0IDMgMg0KcHJpbnQgMg0KcmVwZWF0IDMgMg0KcHJpbnQgMg0KcmVwZWF0IDMgMg==

Maybe it copy-pasted wrong, but this doesn't look like a solution to me. The output is shorter than the input, and contains commands in a different order.

Re: A Quine Puzzle

#15
post #14

My solution, featuring only 2 distinct commands, no NOPs, and not relying on `repeat` at the beginning: cHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcHJpbnQgMg0KcmVwZWF0IDMgMg0KcHJpbnQgMg0KcmVwZWF0IDMgMg0KcHJpbnQgMg0KcmVwZWF0IDMgMg==

Maybe it copy-pasted wrong, but this doesn't look like a solution to me. The output is shorter than the input, and contains commands in a different order.

I just tried it again, and then copy pasted from the output to the input; it still works. Did you select the full string and decode with base64?

Re: A Quine Puzzle

#17

    cHJpbnQgMQpwcmludCAxCnByaW50IDEKcHJpbnQgMQpwcmludCAxCnByaW50IDEKcmVwZWF0IDMg
    MgpwcmludCAyCnJlcGVhdCAzIDIKcHJpbnQgMgpyZXBlYXQgMyAyCgo=
Wasn't terribly difficult, though not the shortest. What's the code golf answer?

Re: A Quine Puzzle

#18
A related idea:

It should be possible to write a zip (rar?) file that encodes a PRNG, such that it contains one zip: itself with the PRNG stepped forward one. (Even a "PRNG" that just outputs 1, then 11, then 111, etc, would be sufficient in most cases)

The hard part is making sure the checksum is consistent.

This would wreak havoc with any file checker that checks for recursive archive files.

Re: A Quine Puzzle

#19

Earlier quoted context omitted.

Variant that doesn't rely on potentially undefined behavior of asking "repeat" to repeat before the beginning: cHJpbnQgMApwcmludCAyCnByaW50IDAKcHJpbnQgMgpwcmludCAwCnJlcGVhdCAzIDIKcHJpbnQgMgpyZXBlYXQgMyAyCnByaW50IDIKcmVwZWF0IDMgMgo=

Good eye. Also, https://github.com/wgreenberg/quine.zip/blob/gh-pages/test/i...

Sure, but LZ doesn't necessarily allow that.

Re: A Quine Puzzle

#20
Does there exist a solution that doesn't rely on undefined repeat behavior? I finally gave in and looked at the answers, but it looks like they all use `repeat M N>M`, or `repeat M N>currentOutputSize`.

I kinda assumed that the interpreter was just there for convenience, and that its implementation of undefined behavior was irrelevant. But is the interpreter's implementation critical to the solution?

(Then again, I'm now reading the examples and realizing that the implementation of undefined behavior was front-and-center, so that's kinda my bad xP)

Post reply on HN