Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 5
added 1 character in body
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Hyper about quines

Inspired by Hyperprogramming: N+N, N×N, N^N all in one.
Thanks to @MartinEnder and @trichoplax for their help in the sandbox.

Definitions

Hyperquines

Define a hyperquine of order n as a quine-like full program or function P that satisfies all rules that apply to proper quines and, in addition, has the following structure.

P is the concatenation of character groups that consist of n copies of the same character. When P is executed, the output is the concatenation of the same groups, augmented by one more copy of the character.

Examples

  • In a hypothetical programming language where the source code aabbcc generates the output aaabbbccc, this program constitutes a hyperquine of order 2.

  • The definition does not require the characters of different groups to be different.

    If the source code aabbcc generates the output aaaabbbbcccc, the program is a hyperquine of order 1; the source code consists of six single-character groups, the output of six character pairs.

  • In GS2, the empty program prints \n, and the program \n prints \n\n. However, neither \n nor \n\n are hyperquines, since they they do not satisfy all properties of proper quines; no part of the source code encodes a different part of the output.

Hyperquine chains

Define a hyperquine chain of length n as a finite sequence of n full programs or n functions
(P1, ..., Pn) that satisfies the following constraints.

  1. The outputs of P1, ..., Pn-1 are P2, ..., Pn, respectively.

  2. P1, ..., Pn are hyperquines.

  3. The orders of P1, ..., Pn form a strictly increasing sequence of adjacent integers.

Finally, define an infinite hyperquine chain as an infinite sequence of full programs or functions (P1, P2, ...) such that each initial interval (P1, ..., Pn) constitutes a hyperquine chain of length n.

Examples

  • In a hypothetical programming language where the source code aabbcc generates the output aaabbbccc, which, in turn, generates the output aaaabbbbcccc, the pair (aabbcc, aaabbbccc) constitutes a hyperquine chain of length 2.

    Note that aaaabbbbcccc – the output of the last hyperquine in the chain – doesn't have to produce a specific output; it doesn't even have to be valid source code.

  • Continuing the previous example, if aaaabbbbcccc generates the output aaaaabbbbbccccc, the triplet (aabbcc, aaabbbccc, aaaabbbbcccc) constitutes a hyperquine chain of length 3.

    If this pattern continues forever, the sequence (aabbcc, aaabbbccc, aaaabbbbcccc, ...) constitutes an infinite hyperquine chain.

  • The pair of programs (abc, aabbcc) with outputs (aabbcc, aaaabbbbcccc) is not a hyperquine chain, since the orders of the hyperquines are both 1, so they do not form a strictly increasing sequence.

  • The pair of programs (aabbcc, aaaabbbbcccc) with outputs (aaaabbbbcccc, aaaaabbbbbccccc) is not a hyperquine chain, since the orders of the hyperquines are 1 and 4, so they do not form a sequence of adjacent integers.

Rules

Task

In a programming language of your choice, write a non-trivial hyperquine chain, i.e., a chain that consists of at least 2 hyperquines.

As usual, your programs may not take any input or access their own source code in any form.

If your interpreter prints an implicit newline, your hyperquines have to account for this.

All standard loopholes – especially those related to quines – apply.

Scoring

The longest hyperquine chain wins. If two or more submissions are tied, the submission among these that starts with the shortest hyperquine (measured in characters) wins. As usual, posting time is the final tiebreaker.


You must use the same character encoding for source code, output, character count, and execution. For example, the Python program print 42 is not a 2-character UTF-32 submission, since the interpreter treats each byte as a single character. If your language of choice is not character-based, treat all individual bytes as characters.

Dennis
  • 211.7k
  • 41
  • 380
  • 830

AltStyle によって変換されたページ (->オリジナル) /