Code-Golf Assembly Line

9

2

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.

Julian Lachniet

Posted 2017-08-22T14:06:52.753

Reputation: 3 216

Does this need to work for all possible subsections of the code? – Tyler – 2017-08-22T14:12:30.137

@JulianLachniet I think the part that needs clarifying is "a subsection of your preference". – Erik the Outgolfer – 2017-08-22T14:16:03.670

9I must say, whenever I see a Quine question, my head immediately short circuits. – Daniel – 2017-08-22T18:14:08.660

Answers

6

JavaScript (ES6), 14 bytes

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

Try it online!

This subsection is also a quine:

f=_=>"f="+f

Try it online!

Stephen

Posted 2017-08-22T14:06:52.753

Reputation: 12 293

4

Jelly, 5 bytes

”ṘṘ10

Try it online!

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

Erik the Outgolfer

Posted 2017-08-22T14:06:52.753

Reputation: 38 134

The main program is not a true quine. – Leaky Nun – 2017-08-22T18:49:40.217

1@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. – Erik the Outgolfer – 2017-08-22T18:50:47.470

3

CJam, 10 bytes

11"`_~"`_~

Try it online!

This is also a quine:

"`_~"`_~

Try it online!

Business Cat

Posted 2017-08-22T14:06:52.753

Reputation: 8 927

2

V, 13 bytes

ñÉÑ~"qpx:2i2i

Try it online!

The subsection 2i2i is also a quine.

James

Posted 2017-08-22T14:06:52.753

Reputation: 54 537

2

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.

Nitrodon

Posted 2017-08-22T14:06:52.753

Reputation: 9 181

0

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

mbomb007

Posted 2017-08-22T14:06:52.753

Reputation: 21 944

0

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.

KSmarts

Posted 2017-08-22T14:06:52.753

Reputation: 1 830