You are to write a program that will output source code that is
- Larger than the original program (character wise)
- Will print another program larger than itself when run (i.e. the new program is also a valid answer to this challenge) indefinitely
This is code-golf, so shortest answer wins.
63 Answers 63
H9+ : 1 char
9
That's right. One character. Outputs the lyrics to 99 bottles of beer, which is a valid program. All the extraneous data does not count, but there are plenty of 9s in there.
The output of the outputted program is the lyrics to 99 bottles of beer 59 times.
This function gives the number of times the lyrics are outputted if you run the program n times (if my calculation is correct):
f(n) = 59n-1
-
41\$\begingroup\$ A 0 char program in a given language, given that it's valid, will likely output 0 characters. And since 0*x=0 for any finite value x, I can claim that my outputted program is actually 9999999999999999 times bigger than the source code. \$\endgroup\$nitro2k01– nitro2k012014年02月23日 18:33:23 +00:00Commented Feb 23, 2014 at 18:33
-
48\$\begingroup\$ @JohannesH. For all(solvable) problems there exists a programming language that solves the problem in 0 chars. \$\endgroup\$Cruncher– Cruncher2014年02月24日 18:48:54 +00:00Commented Feb 24, 2014 at 18:48
-
21\$\begingroup\$ I still move that we name that "Cruncher's Theorem", unless it's already been discovered. \$\endgroup\$Erty Seidohl– Erty Seidohl2014年02月25日 18:31:44 +00:00Commented Feb 25, 2014 at 18:31
-
31\$\begingroup\$ One interesting feature is that it will also contain
2*59^n-2instances of "Hello, world!", due to the "h" in "the". \$\endgroup\$AJMansfield– AJMansfield2015年03月11日 18:37:24 +00:00Commented Mar 11, 2015 at 18:37 -
10\$\begingroup\$ Looks like you've been beat. \$\endgroup\$Christopher King– Christopher King2016年10月17日 22:03:16 +00:00Commented Oct 17, 2016 at 22:03
Java 7: 0 chars
Save as file Blank.java. If you save it as any other file, replace any instance of Blank with the appropriate file name.
Then, run in command line via first compiling, then running. If compiling fails, stop.
I list this as Java 7 because it might output differently for different versions of Java.
First few outputs (outputted to stderr):
Error: Could not find or load main class Blank
Blank.java:1: error: class, interface, or enum expected
Error: Could not find or load main class Blank
^
Blank.java:1: error: reached end of file while parsing
Error: Could not find or load main class Blank
^
2 errors
Blank.java:1: error: class, interface, or enum expected
Blank.java:1: error: class, interface, or enum expected
^
Blank.java:1: error: expected
Blank.java:1: error: class, interface, or enum expected
^
Blank.java:1: error: expected
Blank.java:1: error: class, interface, or enum expected
^
Blank.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Blank.java:1: error: class, interface, or enum expected
^
(use -source 1.4 or lower to use 'enum' as an identifier)
Blank.java:1: error: = expected
Blank.java:1: error: class, interface, or enum expected
^
Blank.java:2: error: expected
Error: Could not find or load main class Blank
^
Blank.java:2: error: ';' expected
Error: Could not find or load main class Blank
^
Blank.java:2: error: = expected
Error: Could not find or load main class Blank
^
Blank.java:2: error: = expected
Error: Could not find or load main class Blank
^
Blank.java:2: error: expected
Error: Could not find or load main class Blank
^
Blank.java:3: error: = expected
^
^
Blank.java:3: error: ';' expected
^
^
Blank.java:4: error: illegal start of type
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: illegal start of type
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: illegal start of type
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: ';' expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: = expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:4: error: ';' expected
Blank.java:1: error: reached end of file while parsing
^
Blank.java:5: error: expected
Error: Could not find or load main class Blank
^
Blank.java:5: error: ';' expected
Error: Could not find or load main class Blank
^
Blank.java:5: error: = expected
Error: Could not find or load main class Blank
^
Blank.java:5: error: = expected
Error: Could not find or load main class Blank
^
Blank.java:5: error: expected
Error: Could not find or load main class Blank
^
Blank.java:6: error: = expected
^
^
Blank.java:6: error: ';' expected
^
^
Blank.java:7: error: reached end of file while parsing
2 errors
^
30 errors
-
26\$\begingroup\$ "You are to write a program that will output source code that is" The output is arguably not source code. And furthermore, depending on the definition of output (whether output must come specifically from
stdout) nothing is actually output. \$\endgroup\$nitro2k01– nitro2k012014年02月23日 18:48:31 +00:00Commented Feb 23, 2014 at 18:48 -
55\$\begingroup\$ @nitro2k01 I quote the same: "You are to write a program that will output source code". Anything is source code. But only some things are valid source code. Additionally, it was not specified what is considered output, so I am allowed freedom there. \$\endgroup\$Justin– Justin2014年02月23日 18:50:36 +00:00Commented Feb 23, 2014 at 18:50
-
24\$\begingroup\$ @PyRulez That's right. I exploited your rules. You don't need to accept this answer. When I posted this, I knew that a controversy would follow, complete with many up and down votes. I decided that it would be worth it, though. \$\endgroup\$Justin– Justin2014年02月23日 21:40:17 +00:00Commented Feb 23, 2014 at 21:40
-
34\$\begingroup\$ Are you sure that the program itself printed the output? Wasn't that only the compiler? The program gets never compiled and itself is not interpreted nor executed, thus it wasn't able to produce any output. \$\endgroup\$V-X– V-X2014年02月24日 08:25:32 +00:00Commented Feb 24, 2014 at 8:25
-
18\$\begingroup\$ @blabla999 I disagree - people don't try these challenges because someone else does something crazy. We just challenge ourselves to do it some other way. As Mark Rosewater says, "Restrictions breed creativity" \$\endgroup\$corsiKa– corsiKa2014年02月24日 23:40:48 +00:00Commented Feb 24, 2014 at 23:40
GolfScript, 9 chars
{.'.~'}.~
This code outputs:
{.'.~'}{.'.~'}.~
which outputs:
{.'.~'}{.'.~'}{.'.~'}.~
which outputs:
{.'.~'}{.'.~'}{.'.~'}{.'.~'}.~
and so on.
I believe this is the shortest answer in a "real" Turing-complete programming language so far.
Explanation:
Basically, the original code above is a "quine-layer": it outputs a normal quine followed by itself.
In GolfScript, any code block literal (e.g. {foo}), if left undisturbed on the stack, is a quine. Thus, on its own, {.'.~'} simply outputs itself, just like any other code block would.
The .~ at the end of the code takes the last code block on the stack, duplicates it, and executes the copy. When executed, the code .'.~' inside the code block duplicates the topmost item on the stack (i.e. the copy of itself) and appends the string .~.
At the end of the program, the GolfScript interpreter stringifies and outputs everything on the stack, which, in this case, consists of one more {.'.~'} block than in the input, plus the string .~.
Bonus:
Adding a ] before the first . (to collect all the code blocks on the stack into an array before they're duplicated) makes it grow exponentially:
{].'.~'}.~
outputs:
{].'.~'}{].'.~'}.~
which outputs:
{].'.~'}{].'.~'}{].'.~'}{].'.~'}.~
which outputs:
{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}{].'.~'}.~
and so on.
-
232\$\begingroup\$
{].'.~'}.~( ┻━┻\$\endgroup\$nitro2k01– nitro2k012014年02月23日 18:34:23 +00:00Commented Feb 23, 2014 at 18:34 -
2\$\begingroup\$ @nitro2k01 my first thoughts exactly :D \$\endgroup\$Songo– Songo2014年02月27日 12:50:00 +00:00Commented Feb 27, 2014 at 12:50
-
1\$\begingroup\$ Sorry I don't think I get the joke about the table can someone please explain? \$\endgroup\$Maxwell Zhao– Maxwell Zhao2016年03月27日 03:22:08 +00:00Commented Mar 27, 2016 at 3:22
-
1\$\begingroup\$ Is "real" in quotes because HQ9+ is not real or because GolfScript is not real, or both? \$\endgroup\$None– None2016年09月13日 08:37:39 +00:00Commented Sep 13, 2016 at 8:37
-
1
GS2 (8636bd8e), 0 bytes
This prints a single newline, which prints two newlines, which prints three newlines, et cetera.
-
3\$\begingroup\$ Isn't this technically non-competing since gs2 is newer than the challenge? \$\endgroup\$DJMcMayhem– DJMcMayhem2016年10月17日 22:22:06 +00:00Commented Oct 17, 2016 at 22:22
-
30\$\begingroup\$ This commit predates the challenge by a month and a half. I just tested it, and it works as intended. \$\endgroup\$Dennis– Dennis2016年10月17日 22:24:01 +00:00Commented Oct 17, 2016 at 22:24
-
17\$\begingroup\$ @MamaFunRoll Why would it be? This isn't different from an empty Retina program printing 1, an empty Jelly program printing 0, or an empty Stuck program printing Hello, World!. \$\endgroup\$Dennis– Dennis2016年11月12日 17:21:34 +00:00Commented Nov 12, 2016 at 17:21
-
3\$\begingroup\$ @Dennis well it is slightly different, in that the Jelly program
0doesn't print00, the stuck programHello, World!doesn't printHello, World!Hello, World!, etc. \$\endgroup\$Cyoce– Cyoce2016年12月17日 21:12:40 +00:00Commented Dec 17, 2016 at 21:12 -
3\$\begingroup\$ @Cyoce It just happens that a newline outputs another newline in GS2. \$\endgroup\$Esolanging Fruit– Esolanging Fruit2017年05月31日 18:51:37 +00:00Commented May 31, 2017 at 18:51
HQ9+, HQ9++ and similars, 2 characters
QQ
This is the output:
QQQQ
-
47\$\begingroup\$ I saw this and thought "Oh no, nothing can beat this." I started trying to come up with something, then it hit me. So I posted an answer. \$\endgroup\$Justin– Justin2014年02月23日 06:09:18 +00:00Commented Feb 23, 2014 at 6:09
-
1\$\begingroup\$ @Quincunx Bravo, upvoted your answer. \$\endgroup\$Victor Stafusa– Victor Stafusa2014年02月23日 06:10:03 +00:00Commented Feb 23, 2014 at 6:10
-
4\$\begingroup\$ @Quincunx No, I think it's
2^2^n, where the initial program is generation 0. The length recursesm -> m^2. \$\endgroup\$Vortico– Vortico2014年02月23日 20:11:48 +00:00Commented Feb 23, 2014 at 20:11 -
3\$\begingroup\$ @Vortico Good point. Even though I said it wrong, I meant: At code-length
n, the output becomesn^n. However, that is false; when the code-length isn, the output's length isn^2\$\endgroup\$Justin– Justin2014年02月23日 21:00:52 +00:00Commented Feb 23, 2014 at 21:00 -
2\$\begingroup\$ It is funny though because even the first two iterations are possible contenders for this question. \$\endgroup\$Christopher King– Christopher King2014年02月23日 21:47:54 +00:00Commented Feb 23, 2014 at 21:47
Ruby 27
A very slightly modified version of this (via):
puts <<3*3,3
puts <<3*3,3
3
The number of times that puts-line is printed grows exponentially.
$ ruby quine.rb | ruby | ruby
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
puts <<3*3,3
3
$ ruby quine.rb | ruby | ruby | ruby | ruby | ruby | ruby | ruby | wc -l
3283
-
20\$\begingroup\$ Answer inspired by the Kaiser Chiefs \$\endgroup\$Ben Jackson– Ben Jackson2014年02月23日 20:06:35 +00:00Commented Feb 23, 2014 at 20:06
Lambda Calculus - 29
A simple lambda term
(λu.(u u)(u u))(λu.(u u)(u u))
Reducing this term by one beta reduction yields
((λu.(u u)(u u))(λu.(u u)(u u)))((λu.(u u)(u u))(λu.(u u)(u u)))
And so on and so on. It's a simple variant on the classic (λu.u u)(λu.u u) which is a quine in lambda calculus, double self application here means we get twice the output.
-
11\$\begingroup\$ I'd argue that in lambda calculus, "running" a lambda term means computing its normal form, not performing a single beta reduction. Also, a term can contain multiple redexes, therefore "reducing a single redex" is an ambiguous operation. \$\endgroup\$Petr– Petr2014年02月24日 19:17:29 +00:00Commented Feb 24, 2014 at 19:17
-
4\$\begingroup\$ You're right, but since this term has no normal form it makes sense to talk about this in terms of small step reduction. Since lambda calculus lacks any inherent set evaluation, I can just define "running" it to be reducing a single redex top level redex with call-by-name semantics no? \$\endgroup\$daniel gratzer– daniel gratzer2014年02月24日 19:54:04 +00:00Commented Feb 24, 2014 at 19:54
-
6\$\begingroup\$ Well, terms with no normal form correspond to non-terminating programs. And the problem with top level redex is that a term can have two redexes, neither one being a sub-term of another. You could pick some criterion which one to reduce, but I'd say that then you're getting very far from the standard lambda calculus semantics. (Anyway I appreciate your novel idea.) \$\endgroup\$Petr– Petr2014年02月24日 19:56:43 +00:00Commented Feb 24, 2014 at 19:56
-
3\$\begingroup\$ (λx.x x x)(λx.x x x) :20 \$\endgroup\$Fabio Filippi– Fabio Filippi2014年02月24日 22:10:26 +00:00Commented Feb 24, 2014 at 22:10
-
3\$\begingroup\$ (λx. x x)(λx. x x x) reduces to that in a single step \$\endgroup\$Ben Millwood– Ben Millwood2014年02月26日 21:56:47 +00:00Commented Feb 26, 2014 at 21:56
SH script, 9
cat 0ドル 0ドル
Grows at exponential rate.
Either run as sh whatever.sh or set it as executable.
Windows version is here.
-
3\$\begingroup\$ At the time of me writing this comment, the Quine Wiki page says that reading from the filesystem is cheating. \$\endgroup\$NeRoboto– NeRoboto2016年12月07日 14:32:28 +00:00Commented Dec 7, 2016 at 14:32
-
8\$\begingroup\$ @LordRatte On the other hand, the challenge wasn't to write a quine. \$\endgroup\$Jason C– Jason C2016年12月07日 23:53:59 +00:00Commented Dec 7, 2016 at 23:53
dc 11
Quite simple:
6579792
dfP
The first line is repeated once every generation:
$ dc growing_quine.dc
6579792
6579792
dfP
$ dc growing_quine.dc | dc | dc
6579792
6579792
6579792
6579792
dfP
The last line consists of the following instructions: d duplicates the last value put on the stack (6579792) (so that we get one more copy each time we run it), f prints the whole stack (which is a bunch of that same number) and P prints the number (6579792) out as a byte stream, which displays as dfP.
-
1\$\begingroup\$ This can be made a little shorter:
6579792pP\$\endgroup\$m90– m902021年10月08日 14:19:25 +00:00Commented Oct 8, 2021 at 14:19 -
2\$\begingroup\$ @m90
6579792pPoutputs my original program, which isn't a strict superset of6579792pP; the minusculepdisappears. Therefore I assume that isn't valid, unfortunately. \$\endgroup\$daniero– daniero2021年10月08日 17:16:33 +00:00Commented Oct 8, 2021 at 17:16 -
2\$\begingroup\$ The requirement of the problem is only that the succesive programs be "larger", which I understood to mean having greater length, although I now see that it's not entirely clear. \$\endgroup\$m90– m902021年10月08日 17:32:56 +00:00Commented Oct 8, 2021 at 17:32
redcode (recursive solution)
This is the code of the easiest warrior writable in redcode, the famous Imp:
MOV 0, 1
When executed, the code writes a copy of its single instruction at the next address in memory; then executes it, etc.
Python 3 - 55
print(open(__file__).read())
f=lambda:print('f()')
f()
This could be made shorter by replacing __ file__ with a single character filename and saving the file as that, but I felt this answer was more in the spirit of the question. After one iteration it outputs:
print(open(__file__).read())
f=lambda:print('f()')
f()
f()
-
3\$\begingroup\$ This isn't a quine. See the definition. \$\endgroup\$Petr– Petr2014年02月24日 19:13:16 +00:00Commented Feb 24, 2014 at 19:13
-
21\$\begingroup\$ @PetrPudlák Nor are any programs in this question. This is a quine-variant problem, not strict quining. \$\endgroup\$AJMansfield– AJMansfield2014年02月25日 02:22:56 +00:00Commented Feb 25, 2014 at 2:22
-
\$\begingroup\$ The lambda isn't needed if the file ends in a newline character:
print(open(__file__).read()*2)\$\endgroup\$Matthew Willcockson– Matthew Willcockson2021年10月07日 09:24:17 +00:00Commented Oct 7, 2021 at 9:24 -
2\$\begingroup\$ One that meets the new quine definitions is:
s='s=%r;print(s%%s*2);';print(s%s)\$\endgroup\$Matthew Willcockson– Matthew Willcockson2021年10月07日 09:35:30 +00:00Commented Oct 7, 2021 at 9:35
Evoloop, ×ばつ9 rectangle (81 cells)
The Evoloop cellular automaton included with Golly supports patterns which replicate themselves in a "quine-like" way. Specifically, these patterns each contain a "program"; a pattern reproduces itself by first executing the program (which creates the "body" of the daughter), and then by copying the program into the daughter.
The above applies to the more famous "Langton's Loops" cellular automaton as well as Evoloop, but Evoloop has an interesting difference, which is that it's easy to create a pattern which grows in each successive generation.
(Much more interesting, in my opinion, is the fact that Evoloop is a simple cellular automaton which contains patterns which reproduce themselves and evolve in a very life-like manner! I think the only known cellular automata which do this are Evoloop and its descendants. A shortcoming of Evoloop, however, is that there is one particular "best" genome; evolution always eventually converges to this one genome.)
Now, there are two shortcomings to this submission. One is that it's not clear what the "output" of a cellular automaton is. But I think that a self-reproducing automaton is "close enough" to being a quine; it's certainly no less interesting! The other shortcoming is that these patterns don't merely create a single copy of themselves; each copy of the original pattern attempts to create infinitely many copies of itself, and these copies end up interacting with each other in a destructive manner. So, I think I've met the requirements of this challenge in spirit, but not in letter.
Without further ado, the pattern is:
022222220
270170172
212222202
202000212
272000272
212000202
202222212
271041032
022222250
Here's the pattern again, in a format that can be copied and pasted into Golly:
x = 9, y = 9, rule = Evoloop
.7B$BG.AG.AGB$BA5B.B$B.B3.BAB$BGB3.BGB$BAB3.B.B$B.5BAB$BGA.DA.CB$.6BE
!
Okay, but what does it look like? It looks like this:
A pattern in a cellular automaton which creates increasingly large copies of itself.
In the above animation, you can see the initial pattern create a larger daughter, which creates a larger granddaughter, then a larger great-granddaughter, and finally an even larger great-great-granddaughter which starts to construct a yet larger third-great-granddaughter. If you ran this pattern for a long time, it would keep going on like this forever (or perhaps they would eventually be overtaken by the evolved organisms, which are capable of reproducing much faster; I'm not sure).
-
\$\begingroup\$ When you run it long enough you get genomes which create smaller offspring, which eventually self-destruct. The 'mother' at the center stays alive. \$\endgroup\$Mark Jeronimus– Mark Jeronimus2020年06月12日 23:09:33 +00:00Commented Jun 12, 2020 at 23:09
-
\$\begingroup\$ @MarkJeronimus Yup. Those were the inspiration for this answer: I saw that there were organisms that get smaller with each generation, so I figured it would probably be possible to create one that would get larger with each generation. And sure enough. \$\endgroup\$Sophie Swett– Sophie Swett2020年06月13日 02:46:18 +00:00Commented Jun 13, 2020 at 2:46
Smalltalk, (削除) 125 61 (削除ここまで) 57
The golf version looks almost unreadable so I'll explain first (and use real identifiers).
This is a variant of the "weirdest-way-to-produce-a-stack-overflow" self modifying method.
The method prints out a hello message, and its current source (for the demonstration only). Then, the code is modified to output a longer string and installed. Finally, the new code is called recursively.
In order to protect myself from an immediate runaway, it lets the user confirm in each cycle.
compile in Object:
eatMe_alice
|msg mySource|
mySource := thisContext method source.
'**** Hello Alice' printCR.
' ---- my current code is:' printCR.
mySource printCR.
' ---------------' printCR.
(UserConfirmation confirm:'Again? ') ifTrue:[
Object compile:
(mySource
copyReplaceString:'Hello ','Alice'
withString:'Hello ','Alice !').
self eatMe_alice
]
start the show by sending "eatMe_alice" to any Object; nil will do:
nil eatMe_alice
A nice variant is to not call the new code recursively, but instead iteratively, by unwindig the call stack and reentering into the new method. This has the advantage of not leading to a recursion exception. To do this, replace the recursive call ("self eatMe_alice") by:
thisContext resend
Golfing:
Obviously, printing and self calling was not asked for, so the shortest (for golf) is to simply append a comment to my own source and return it. As a side effect, it also gets installed for the next call...
x|s|Object compile:(s:=thisContext method source,'""').^s
SH script, (削除) 12 (削除ここまで) (削除) 8 (削除ここまで) 7
Store a file with
sed p *
in its own, empty directory and run from this directory using sh [file] or set executable.
Old alternative with 8 characters, but doesn't need its own directory. Store a file with
sed p 0ドル
and run using sh [file] or set executable.
Old alternative with 12 characters:
sed -i- p 0ドル
This will actually output to the program file itself, but where to output was not specified. Replicates itself at an exponential rate.
-
1\$\begingroup\$ You might still have chance using
ed, didn't want to look through its man page... \$\endgroup\$Jens Erat– Jens Erat2014年02月24日 10:49:29 +00:00Commented Feb 24, 2014 at 10:49
ECMAScript 6 (38 Characters)
(f=_=>'(f='+f+')();(f='+f+')();')();
Which outputs:
(f=_=>'(f='+f+')();(f='+f+')();')();(f=_=>'(f='+f+')();(f='+f+')();')();
Edit
You could do (28 characters):
(f=_=>'(f='+f+')();'+f())();
However it will recurse infinitely and never return anything... but this can be solved by doing something like this (42 characters):
(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(3);
Which will output:
(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(3);(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(2);(f=_=>_?'(f='+f+')('+_+');'+f(_-1):'')(1);
-
5\$\begingroup\$
+_+ =_=+1 for emoticons \$\endgroup\$TuxCrafting– TuxCrafting2016年10月18日 12:21:09 +00:00Commented Oct 18, 2016 at 12:21 -
2\$\begingroup\$ 33:
(f=_=>(f=${f})();.repeat(2))();\$\endgroup\$emanresu A– emanresu A2021年04月08日 21:09:48 +00:00Commented Apr 8, 2021 at 21:09
JavaScript, (削除) 41 (削除ここまで), 40 chars
function f(){console.log(f+"f(f())")}f()
The first time you run it it outputs itself with another ;f() at the end. Subsequent runs of the output results in each "input" source printed twice.
alert would be shorter than console.log but I don't consider multiple alert dialogs to be "the" output while it seems reasonable to call multiple lines in the console as an output.
-
1\$\begingroup\$ You can save one byte with
"f(f())"instead of"f();f()"\$\endgroup\$Hedi– Hedi2016年11月12日 15:40:27 +00:00Commented Nov 12, 2016 at 15:40 -
1\$\begingroup\$ This doesn't seem to work for me... \$\endgroup\$Destructible Lemon– Destructible Lemon2016年11月12日 22:27:51 +00:00Commented Nov 12, 2016 at 22:27
Runic Enchantments, 6 bytes
"'<S@>
This one was weird. All I had to do was remove a ~ from the original quine found by Jo King.
Every additional run appends another < to the end, e.g.:
"'<S@><<<<<<<<<
All of which do nothing.
Microscript II, 6 bytes
"qp"qp
The first iteration adds an extra qp to the end, and each successive iteration adds an extra copy of this original program to the beginning.
Julia, 66 chars
x="print(\"x=\$(repr(x))\\n\$x;\"^2)";print("x=$(repr(x))\n$x;"^2)
Output (134 chars):
x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);
Result of executing the result (268 chars):
x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);
next result (536 chars):
x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);
Next result (1072 chars):
x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);x="print(\"x=\$(repr(x))\\n\$x;\"^2)"
print("x=$(repr(x))\n$x;"^2);
I hope this is according to the rules.
It produces larger output, and the output itself is valid source code that produces larger output again.
-
\$\begingroup\$ Will the output, when ran, produce a valid entry? \$\endgroup\$Christopher King– Christopher King2015年06月30日 01:11:08 +00:00Commented Jun 30, 2015 at 1:11
-
\$\begingroup\$ In the first example the output is valid code. It’s a string literal containing 5 periods. In the second example, entering the julia prompt itself wouldn’t do anything. I just thought that just giving the repl actually a newline character by hitting enter produces a longer output than the input. \$\endgroup\$M L– M L2015年06月30日 01:24:02 +00:00Commented Jun 30, 2015 at 1:24
-
\$\begingroup\$ Will "....." produce a larger version of itself? \$\endgroup\$Christopher King– Christopher King2015年06月30日 01:25:45 +00:00Commented Jun 30, 2015 at 1:25
-
\$\begingroup\$ Ah, now I understand. I just noticed it had to be recursive... time to correct my solution. Thanks for the hint. \$\endgroup\$M L– M L2015年06月30日 01:28:09 +00:00Commented Jun 30, 2015 at 1:28
-
1\$\begingroup\$ I guess the code is according to the rules now. \$\endgroup\$M L– M L2015年07月12日 02:26:35 +00:00Commented Jul 12, 2015 at 2:26
Husk, (削除) 15 (削除ここまで) 11 bytes
-4 bytes thanks to Unrelated String
S+s"So+uswg
Outputs So+uswg"So+uswg" then S o+uswg"S o + u s w g" then S o+uswg"S o + u s w g"... This is a variant of the usual quine S+s"S+s" but with increasing spaces between each character in the string. Currently there's a bug in the parser that prevents double spaces in the code itself, otherwise this could forgo the unique stripping out spaces in the code section and could be 9 bytes.
-
1\$\begingroup\$ Still can be 11 bytes:
S+s"So+uswg\$\endgroup\$Unrelated String– Unrelated String2020年10月06日 21:30:06 +00:00Commented Oct 6, 2020 at 21:30
Common Lisp, 16 Characters
(print `(or ,-))
Granted, it's interactive-only, but being able to reference the current top-level form is probably the single best way to minimize a non-trivial program that meets the specification.
What would be really interesting is what blows up the fastest. Maybe something like
(print `(progn ,@(loop repeat (length -) collect -)))
-
\$\begingroup\$ +1 For Common Lisp. Looks to me like you can skip
`and,? \$\endgroup\$daniero– daniero2014年02月26日 13:55:58 +00:00Commented Feb 26, 2014 at 13:55 -
\$\begingroup\$ @daniero Without the quotation, it just prints the original program, never growing. At that point, you may as well omit the
or, too:(print -)\$\endgroup\$Stuart Olsen– Stuart Olsen2014年02月26日 20:14:52 +00:00Commented Feb 26, 2014 at 20:14
reticular, 11 bytes, noncompeting
"'34'coo1o;
This is the standard quine framework, except an extra 1 is printed after each iteration. Try it online!
First few outputs:
"'34'coo1o;
"'34'coo1o;1
"'34'coo1o;11
"'34'coo1o;111
05AB1E, 15 bytes, noncompeting
0"DÐ34çý"DÐ34çý
Prints 0"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý,
which prints 0"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý"DÐ34çý,
etc.
J, 1 byte
'
The open quote gives, obviously, the open quote error:
|open quote
| '
| ^
|[-1] /home/runner/.code.tio
Note that, by the nature of J interpreter, the errors are printed to STDOUT, not STDERR.
When the above is run as code, it prints:
|open quote
| | '
| ^
|[-2] /home/runner/.code.tio
Then
|open quote
| | | '
| ^
|[-2] /home/runner/.code.tio
and so on. Each time the code runs, the second line is left-padded with four bytes | , fulfilling the requirement of this challenge.
J, proper quine variant, 25 bytes
echo,~'echo,:~(,quote)'''
Outputs
echo,:~(,quote)'echo,:~(,quote)'
And then it outputs itself twice, on separate lines:
echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'
then
echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'
echo,:~(,quote)'echo,:~(,quote)'
and so on.
The first output is a simple variant of standard J quine. The added ,:~ concatenates itself vertically, where the resulting 2D array is printed as two rows of the same string.
Python 2, (削除) 38 (削除ここまで) (削除) 37 (削除ここまで) (削除) 36 (削除ここまで) 34 bytes
-1 bytes thanks to Jo King
s='print"s=%r;exec s;"%s+s';exec s
Python 3.8 (pre-release), (削除) 39 (削除ここまで) (削除) 38 (削除ここまで) 36 bytes
exec(s:='print("exec(s:=%r);"%s+s)')
EcmaScript 6 (51 bytes):
(_=x=>'(_='+_+Array(x++).join(','+_)+')('+x+')')(2)
It produces a longer version of itself, which can produce a longer version of itself, which can produce a longer version of itself, etc. ...
Underload, 9 bytes
(:::aSSS):^
Modification on the standard underload quine, which is (:aSS):aSS. First, I changed the second :aSS into :^ since it still runs the same code (by duplicating and then running the top item of the stack, which is the stuff inside the bracket) whilst saving bytes. Then I added another S to make it so the program gets longer, and added two more :s to make it so the program it produces doesn't error.
Japt, 12 bytes
"iQ 2Ä"iQ 2Ä
Based off the Standard Japt quine
Explanation
For first iteration
"iQ 2Ä" // Take this string. iQ 2Ä
iQ // Insert a quote. "iQ 2Ä
2 // Double. "iQ 2Ä"iQ 2Ä
Ä // Concatenate 1 to end "iQ 2Ä"iQ 2Ä1
// Implicitly output.
On Each iteration it will concatenate another 1 to the end of the program
Jelly, 4 bytes
)ṘȮv
Originally written for a CMC in JHT.
)ṘȮ "ṘȮ"
v evaluated with the argument
)ṘȮ "ṘȮ".
Ṙ Print a Jelly string representation of the argument,
Ȯ print the argument,
then implicitly print it again.
:^)\$\endgroup\$