Skip to main content
4 of 4
added 83 characters in body
fireflame241
  • 16.3k
  • 2
  • 29
  • 72

Unfurling-Safe Quine

Write a proper quine containing at least one newline/linefeed whose every unfurling is either itself a proper quine or outputs the original quine. Your answer can mix and match outputting itself and outputting the original quine.

Unfurlings

Unfurlings consist of:

  1. Appending spaces to make the input a rectangle.
  2. Taking all lines above the bottom one and rotating them a quarter-turn clockwise about the lower-right corner so that the right edge is on the same level as the bottom edge.
  3. Repeat step (2) until the string is a single line to find all unfurlings.

For example, the first unfurling of

GFE
HID
ABC

is

   HG
   IF
ABCDE

and the rest are

   HG
   IF
ABCDE

     IH
ABCDEFG

       I
ABCDEFGH

ABCDEFGHI

This process is automated with this program adapted from Emigna's answer here,where each step of unfurling in the output is delimited by a dashed line.

Example

For example, if you have a program

K
AB

(no trailing spaces)

then it must be a proper quine and print itself('K\nAB', where \n represents a linefeed/newline). According to the output of the unfurling program, we see that the next step in unfurling is

  K
AB 

(note trailing space)

This must either print itself(' K\nAB ') or the original program ('K\nAB'). The next step in the unfurling is

AB K

This must either print itself ('AB K'), or the original program('K\nAB').

The byte-count of this program is 4 (K, \n, A, B).

Score

This is , so the shortest answer in bytes wins. Standard loopholes apply, as usual.

fireflame241
  • 16.3k
  • 2
  • 29
  • 72