Hot answers tagged

302

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


177

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


125

Windows Command Prompt & was unexpected at this time.


120

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


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


114

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


110

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


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


98

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!


96

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


86

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


83

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


76

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


72

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

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


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.


67

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


66

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


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


52

awk, 4 bytes The structure of an awk program is pattern { action }. If pattern evaluates to true, { action } is performed. If { action } is omitted, the default is to output the current input record. Code: 2020 As 2020 always evaluates to true, the program always prints it's input, therefore satisfying properties 1. and 2. When the input is the program ...


51

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.


47

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


47

Windows .EXE, 248 bytes The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher. No, really. Save as quine.txt, then rename to quine.exe (or download it here):


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


45

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


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