13
\$\begingroup\$

In this challenge, you'll take an answer as input, and print the answer before it. If the answer passed as input is the first answer, print your own submission's source. You'll be passed any answer in the chain up to and including your own answer, but none after it in the chain.

For example, if the first submission is xyz, the second is ABCD, and you submit pQrSt as a third answer, you should support the following input/output pairs:

xyz -> pQrSt
ABCD -> xyz
pQrSt -> ABCD

The first answer's only possible input is its own source code, in which case it should print its own source (i.e., it can be a cat program).

Rules

  • Inputs and outputs should be treated as bytestrings. While some or most answers may be valid UTF-8, you cannot assume all programs will be representable with Unicode
  • If your language doesn't support raw binary I/O, you may use lists of numbers (representing bytes) with some consistent formatting (e.g., newline separated) for I/O in place of binary data
  • Answers may be in any programming language
  • Answers with a negative score (more downvotes than upvotes) are invalid, and someone else may submit a different answer in their place
  • Answers must follow quine rules; no reading your own source code (stringifying functions is allowed here; you just can't read your source code directly from a file or similar) or accessing the internet or other external resouces
  • No duplicate answers are allowed (same or different language)
  • If a user answers multiple times in a row, only their first answer counts for scoring (so that sandbagging with the first for a low score on the second doesn't work)

Scoring

Scoring is based on percentage increase in byte count. Whatever answer has the lowest percent increase in byte count over the previous submission wins (this may be negative). You may not golf or otherwise change your answer's code after posting it.

\$\endgroup\$
2
  • \$\begingroup\$ With this 'percentage over previous submission' scoring system, I suppose that after each answer in a general-purpose programming language there will be a mad rush to answer in golf-languages, followed by a long wait.. \$\endgroup\$ Sep 28 at 14:12
  • 1
    \$\begingroup\$ @DominicvanEssen I suspect that most answers after the first two or three will be mainly for the accomplishment of having done it rather than the scoring. The scoring's mostly just to make it fit site rules :p \$\endgroup\$ Sep 28 at 14:13

5 Answers 5

6
\$\begingroup\$

3: Pip, 103 bytes

VST Y`h:[v:"x=>x"w:"\`I?L4≠[4Nȯ,Q".vX:2\"a=b=>(t='\w',b==t?'\v':b>a?'a='+a:t)\""VST Y".RPy]h@D:h@?a`

Try it online!

This is a pretty standard Pip quine structure. We store a code string in the variable y then evaluate it, and then construct all the pieces of code in an array and return the one at the index before the input.

\$\endgroup\$
5
\$\begingroup\$

2: JavaScript (Node.js), 74 bytes

a=b=>(t='`I?L4≠[4Nȯ,Qx=>x`I?L4≠[4Nȯ,Qx=>x',b==t?'x=>x':b>a?'a='+a:t)

Try it online!

\$\endgroup\$
4
\$\begingroup\$

1: Vyxal D, 32 bytes

`I?L4≠[4Nȯ,Qx=>x`I?L4≠[4Nȯ,Qx=>x

Try it Online!

Returns the nasty ahh string when given x=>x.

Returns x=>x when given the nasty ahh string.

\$\endgroup\$
1
  • \$\begingroup\$ well this is going to get messy really fast \$\endgroup\$
    – math scat
    Sep 28 at 14:15
4
\$\begingroup\$

4: Vyxal D, 149 bytes

`q‛:Ė+»∧⋏≬¥Cİ}ż^₀:⅛°Ṅ.V=j₈@Yʁḃk∩Ŀʁ<Kf]ȧ∪?≥]ċ@Kȯ⇩Ż.ε⅛Ṡ↓√⁽∵0}İ∆3ẋ⟇n↳p°5≬≥U≠0rb½¨hĖ¤¢|c¦ẋQƒ∷ε.¼₅Jǔ(;Ḃ…%ɖbU≠r.₍p∞ėwn2¢ȧH↔$[Ṙ»kQ‛ȯ≠pτn8ȯ7Ẏ(n/ṫj)ṫ/J~ḟ‹i`:Ė

Try it Online!

I'm quite proud of this one, and I spent way too long compressing it. The basic idea is to use a port of RegPack to efficiently compress redundancies in previous answers. Also, we're out of quote types and I hate backslashes, so I used a giant compressed integer. For future answers, here's a program to convert from the Vyxal codepage to raw bytes (output as hexadecimal)

`q‛:Ė+                              `:Ė # Standard eval quine glue: Uneval the string and add the code to eval it
      »...»                             # Giant compressed integer
                 τ                      # Converted to custom string base
           kQ‛ȯ≠p                       # Printable ascii + "ȯ≠" (to deal with previous Vyxal)
                  n8ȯ7Ẏ                 # "ijklmno"
                       (    )           # For every item of that
                        n/ṫj            # Split on that character, and join all but the last item by the last item (regpack bit)
                             ṫ/         # Split on the remaining trailing semicolon, converting into list
                               J        # Prepend the existing source code 
                                ~ḟ      # Find the index of the input in the list
                                  ‹i    # Decrement that, and index back into the list
\$\endgroup\$
3
\$\begingroup\$

0: JavaScript (Node.js), 4 bytes

x=>x

Just a cat program, to get us started

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ Can I follow another same cat? If no, why? \$\endgroup\$
    – l4m2
    Sep 28 at 14:11
  • \$\begingroup\$ @l4m2 Oops, I need to add a rule against duplicate answers. Just a sec. \$\endgroup\$ Sep 28 at 14:11
  • 4
    \$\begingroup\$ Now that it boosts up duplicate answers is automatically impossible :) \$\endgroup\$
    – l4m2
    Sep 28 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.