We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

301

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 ...


171

JavaScript, 9 7 bytes N=>a=-N Outputs: NaN Try it online!


119

Windows Command Prompt & was unexpected at this time.


118

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 ...


117

Ed (1 byte) All the other solutions thus far are long and ugly. I suppose that is because of the nature of most error messages. But a good error message is elegant in its simplicity. For that, look no further than ed. ? Save this to a file called edscript and run with ed < edscript, or run ed<<<?. The result: ? The question mark is written ...


109

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): ...


107

Hexagony, side-length 17 16, 816 705 bytes ...


104

Perl, 7×7 (42 non-spaces) for$i( 1..56 ) {$_= $i %8? $i% 7? $":7 : $/;1; print} Output: 7 7 7 7 7 7 7


96

huh?, 5 characters !hcuO I actually have NO idea how it works, but If you download the interpreter, and if you write !hcuO, then you get Ouch! To run this, you need to execute the program like this: huh.exe !hcuO It will actually look for a file called !hcuO, but it doesn't exist, so it outputs Ouch!


92

GS2 (8636bd8e), 0 bytes This prints a single newline, which prints two newlines, which prints three newlines, et cetera. Try it online!


85

Mathematica, 3 chars a 2 a 2 means a times 2. So the answer is 2 a.


81

CoffeeScript, syntactically valid As tested on their website using Chrome or Firefox. ReferenceError: defined is not defined You can replace defined with anything that's not a built-in variable, but I thought this version was fun. Unfortunately, undefined is not defined in particular doesn't work as a quine. In CoffeeScript this isn't even a syntax error,...


80

HQ9+, HQ9++ and similars, 2 characters QQ This is the output: QQQQ


77

CJam, 4X4 (12 10 non-spaces) 6, SS + * 4/ N* Output: 0 1 2 3 4 5 Previous version with 12 non-spaces: 4a4 * 4S ** 4 /N* And the output is 4 4 4 4 As pointed out by Martin, this version has 4 Spaces, 4 *, 4 4, 4 other characters, and 4 4 as the output ;) Try it online here


71

Brain-Flak, 9.8e580 1.3e562 9.3e516 12818 11024 4452 4332 4240 4200 4180 3852 3656 3616 3540 2485 + 3 = 2488 bytes Now fits in the observable universe! (())(()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(()()()()())(())(())(())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()...


70

GolfScript - 2 1 (ie \n1 where \n is the newline character) Output: 1 (ie 1\n) To quote Ilmari: GolfScript automatically appends a newline to the end of the output Thus a newline followed by a number will print the number followed by a newline.


68

Prelude, 5157 4514 2348 1761 1537 664 569 535 423 241 214 184 178 175 169 148 142 136 133 bytes Thanks to Sp3000 for saving 3 bytes. This is rather long... (okay, it's still long ... at least it's beating the shortest known Brainfuck C# quine on this challenge now) but it's the first quine I discovered myself (my Lua and Julia submissions are really just ...


65

H9+, 13 characters !dlrow ,olleH As the web page says, all characters that are not H, 9 or + are ignored, so my program will print Hello, world!


60

Zsh, 4 bytes <$0 The Z shell has feline functionalities built in. The fourth character is a linefeed. Try it online! The code does not depend in any way on the file name; it works even if the file name contains special character, such as spaces or newlines. Test run $ cat "my quine.sh" <$0 $ zsh "my quine.sh" <$0 $ diff -s <(zsh "my quine....


58

Hexagony, side length 11, 314 bytes 164248894991581511673077637999211259627125600306858995725520485910920851569759793601722945695269172442124287874075294735023125483.....!/:;.........)%'=a':\....................\...................\..................\.................\................\...............\..............\..$@.........\$><>'?2='%.<\:;_;...


54

><>, 25 words + (22 + 11 + 11) extra = 57 49 Oh god, my brain. 'brr3deep*clap6beep+orb5flap*leap4deep+clap5beep5flap*leap9deep9clap*beep+flap0placed apple alp0leap=clip?lob8blip*flip0clip. Since the rules state "There is no input.", for this program to work you'll need to pipe in an empty file. Oh and yes, brr is a valid Scrabble word, as are tsktsk ...


50

Python Spyder Well, a rather trivial solution for the Spyder IDE is to raise a SyntaxError. Code and identical output: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile execfile(...


50

Marbelous - 16x16 ....@0..@1.... @3..0A08..@2 .. /\--....>1 ..Hp ..@2..\\ =0@3.. ss..// --\\\\.. @0/\ @1/\Hp..!! :s #the-cake-is 2020#a-pie/lie Test it here! Spaces as blanks, cylindrical board, and include libraries all must be checked. Output 07 06 05 04 03 02 ...


48

Bash, 6 bytes cat $0 Basically.


46

Vim, 11 bytes q"iq"qP<Esc>hqP iq"qP<Esc>: Manually insert a duplicate of the text that has to be outside the recording. q" and hqP: Record the inside directly into the unnamed "" register, so it can be pasted in the middle. The h is the only repositioning required; if you put it inside the macro, it will be pasted into the result. Edit A note ...


46

Python (27 characters) In the Python shell, the following script will output the desired result: TzoubyFssps;!jowbmje!tzouby Yes! it outputs: SyntaxError: invalid syntax


44

Cubix, 20 bytes 3434Qu$v@!<"OOw\o;/" Almost got the \o/... Net: 3 4 3 4 Q u $ v @ ! < " O O w \ o ; / " . . . . Try it online Try it here! Additional notes Background story After being impressed by reading this great answer by @ais523, I started thinking about further golfing the quine. After all, there were quite a few no-ops ...


42

Javascript ES6 - 21 bytes $=_=>`$=${$};$()`;$() I call this quine "The Bling Quine." Sometimes, you gotta golf in style.


42

><> - 25 Bytes something smells fishy... In Fish, any bad instruction outputs the error: "something smells fishy...". Since s is not a valid command, it errors immediately.


Only top voted, non community-wiki answers of a minimum length are eligible