9
\$\begingroup\$

Note: This challenge has nothing to do with actual assembly language.


As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines.

Specification:

In this challenge, the goal is to write a quine such that a proper subsection of it is also a quine.

This is code-golf, so the fewest bytes (of the main program) win. Standard loopholes are forbidden, and both the main program and the subsection must be true quines.

The subsection must be at least 2 characters shorter than the main program, meaning that the minimum score is 3 bytes.

You only need 1 subsection of your choice to work.

\$\endgroup\$
  • \$\begingroup\$ Does this need to work for all possible subsections of the code? \$\endgroup\$ – Tyler Aug 22 '17 at 14:12
  • \$\begingroup\$ @JulianLachniet I think the part that needs clarifying is "a subsection of your preference". \$\endgroup\$ – Erik the Outgolfer Aug 22 '17 at 14:16
  • 9
    \$\begingroup\$ I must say, whenever I see a Quine question, my head immediately short circuits. \$\endgroup\$ – Daniel Aug 22 '17 at 18:14
6
\$\begingroup\$

JavaScript (ES6), 14 bytes

f=_=>"f="+f+""

Try it online!

This subsection is also a quine:

f=_=>"f="+f

Try it online!

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

Jelly, 5 bytes

”ṘṘ10

Try it online!

The subsection ”ṘṘ is also a quine. Try it online!

\$\endgroup\$
  • \$\begingroup\$ The main program is not a true quine. \$\endgroup\$ – Leaky Nun Aug 22 '17 at 18:49
  • 1
    \$\begingroup\$ @LeakyNun Well, ”ṘṘ is a true quine and the definition of a true quine is that a part of your code identifies another part, in this case the ”Ṙ identifies the other . I don't think the added 10 makes the ”Ṙ not identify the other anymore. \$\endgroup\$ – Erik the Outgolfer Aug 22 '17 at 18:50
3
\$\begingroup\$

CJam, 10 bytes

11"`_~"`_~

Try it online!

This is also a quine:

"`_~"`_~

Try it online!

\$\endgroup\$
2
\$\begingroup\$

V, 13 bytes

ñÉÑ~"qpx:2i2i

Try it online!

The subsection 2i2i is also a quine.

\$\endgroup\$
2
\$\begingroup\$

Alice, 13 bytes

"!&d<@o&dh.##

Try it online!

This is also a quine:

"!&d<@o&dh.

Try it online!

This modifies the standard quine by clearing the stack before the relevant string is pushed, and using the stack height to determine how many bytes to output. This allows any no-op to be added at the end.

\$\endgroup\$
0
\$\begingroup\$

Python 2, 60 bytes

This is a really simple answer, so there's probably a shorter one. This is just the standard Python quine twice. The trailing newline is required.

_='_=%r;print _%%_';print _%_
_='_=%r;print _%%_';print _%_


Try it online

\$\endgroup\$
0
\$\begingroup\$

Fission, 35 bytes

O abcdefghijklmnopqrstuvwxyz '#_OR"

Try it online!

An atom starts at R travelling right. The " toggles print mode, so it wraps around and prints everything until it encounters " again. This stops printing and sets the mass of the atom to the number of characters printed (34). It wraps around again, and O destroys the atom and prints the ASCII character represented by its mass, which is ".

This contains the simple Fission quine,

'#_OR"

Try it online!

Here, '# sets the mass of the atom to the ASCII value of # (35), and _ decrements it so that the O prints a quotation mark.

Fission, 8 bytes

'#_O  R"

Since the simple quine above starts at R and ends at O, any length quine can trivially be created by adding characters between the two.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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