A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
202

Jelly, 12 bytes N+N “(ẹ+)‘FQṖṪỌv Try it online! N×N ““((ẹẹ++))‘‘FFQQṖṖṪṪỌỌvv Try it online! N^N “““(((ẹẹẹ+++)))‘‘‘FFFQQQṖṖṖṪṪṪỌỌỌvvv Try it online! How it works Jelly has several different types of string literals; all of them start with a “. If the literal contains more than one “, a string array is returned, and “ separates the strings from each ...


196

Python 3, 61 bytes rant="partisn't" print(("HHeelllloo,, WWoorrlldd!!"""[::2])) Try it online! Abusing the fact that print is a function in Python 3 :) The least partisan solution you'll find here on PPCG. Becomes rn=print rn("Hello, World!"[:])


153

Python 2, 33 bytes print len(open(__file__).read())# Try it online! Try it doubled Python 3, 28 bytes print(len(*open(__file__)))# Try it online! Try it doubled Explanation This opens up the source code using open(__file__) and gets its length using len the # prevents any additional code from being read. When the source is doubled so is the length.


135

Befunge, Score 0 I think I cracked it - no single character deletion will change the output. Deleting any character from line 1 changes nothing - it still goes down at the same place. Lines 2 and 3 are redundant. Normally line 2 is executed, but if you delete a character from it, the < is missed, and line 3 takes charge. Deleting newlines doesn't break ...


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


97

Jelly, 1 byte ‘ Try it online! or Try it double! I have no idea how this works, but apparently it does.


87

><>, 41 bytes \< 1:: : &&* + i*n n c& %: 4l 0( .i n} &? Try it online: N+N, N*N, N^N. Assumes that the STDIN input is exactly one char. ><> is a 2D language, so we can make use of the fact that code semantics are mostly unchanged if we execute instructions downwards — the extra empty lines that ensue are just no-ops. The ...


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


75

Haskell, 11 bytes f=log pxe=f and in reverse order: f=exp gol=f This works without the "comment" trick. Instead each version defines an additional, but unused function (pxe/ gol).


70

zsh, 603 594 566 561 548 440 415 399 378 370 bytes ec ho \\n;ca t<<<$'\x20';exi t d$c -e8BC6P d0c -eKp $'\172\163\150' $'\055\143' $'\146\157\162 v \151\156 \173\043\056\056\134\175\175\073\173 \146\147\162\145\160 \055\161 $\166 '$0$'\174\174\074\074\074$\166\073\175' $'\145v\141\154' $':\073\072\046\046\145\170\151\164';#%&()*+,/9=>?@...


68

Python 2, 50 bytes print["Code\40Golf","Programming Puzzles"][" ">""] Try it online! With all spaces removed: print["Code\40Golf","ProgrammingPuzzles"]["">""] Try that online! Thanks to Stephen S for 3 bytes, and Erik the Outgolfer for 1


67

Google Sheets, 11 5 Bytes Anonymous worksheet formula that takes no input and outputs into the cell which holds the formula =4/(2 As a single formula this evaluates to a call stack that looks a little something like =4/(2 =4/(2) =4/2 =2 2 However when this worksheet formula is doubled this call stack evaluates down to =4/(2=4/(2 =4/(2=4/(2) =4/(2=...


65

C, 53 characters main(){register*a="2012";(puts("2012"==a?a:"2012"));} A bit longer than the scripting language answers, and follows the same basic principle. Relies on the fact that due to the constraints of C's syntax, the only letters that would be possible to change without making the program invalid are within the strings! Edit: Shaved off 4 ...


63

Befunge-98, 602 bytes "^@<"v@@ "'I'"00v>00g:: "@v"0v@@@>g::a">#" "a">v@@> 0g::'"1> / ":\"'"v@> 'm'"00g:a ...


56

Cardinal, 29 bytes % " H e l l o , W o r l d ! Try it online! Removing every other character removes all the linefeeds, which still results in Hello, World!: %"Hello, World! Try it online! The reason this works is that % creates four instruction pointers, moving in each of the four cardinal directions. IPs that leave the source code are simply ...


53

Python 2, 48 47 bytes -1 byte thanks to Erik the Outgolfer print' 'and'Programming Puzzles'or'Code\40Golf' Try it online! print''and'ProgrammingPuzzles'or'Code\40Golf' Try it online!


52

Python, 54 + 56 = 110 bytes Counter: m=lambda x:sum(y.isspace()for y in x) +1 0<9or x.split() Splitter: m=lambda x:sum(y.isspace()for y in x)+10<9or x.split() For the counter, we use the fact that Python is okay with having just an expression on a line. It's necessary to split up +1 and 0<9or x.split() to stop a NameError from being thrown, as ...


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


49

C, 125 bytes xpxuxtxs( ) { }xuxs ( ) { } main( ) {puts ( "Hello, World!" ) ; } mxaxixn ( ) {xpxuxtxs ( " H e l l o , W o r l d ! " ) ; } Try it online! With even characters removed: xxxx(){}us(){}mi(){us("el,Wrd");}main(){puts("Hello, World!");} Try it online!


47

Javascript - action - 15x15 "Definetly not the shortest one, but PEW PEW PEW." - James Bond ction="action " ction+="means " actionac="PEW " ctionact="PEW " tionacti="PEW " ionactio="PEW " onaction="PEW " nactiona="PEW " ction+=actionac ction+=ctionact ction+=tionacti ction+=ionactio ction+=onaction ction+=nactiona alert(""+ction) Link to the jsfiddle ...


46

05AB1E, 2 bytes Original XO Try it online! Doubled XOXO Try it online! Explanation X pushes 1 to the stack. O sums the stack.


44

APL, 3 bytes *⊣⍟ This is a function train. Monadic * returns e^x, monadic ⍟ returns ln(x). ⊣ is a dyadic function that returns its left argument. Thus, *⊣⍟ is equivalent to just *, and the reverse ⍟⊣* is equivalent to just ⍟.


44

C (gcc), 37 bytes i;main(){putchar(i+49);}/* i=1;//*/// The file does not contain a trailing newline. Doubled version, for syntax highlighting: i;main(){putchar(i+49);}/* i=1;//*///i;main(){putchar(i+49);}/* i=1;//*/// TIO links: single, double.


44

05AB1E, 2 bytes (1 Try it online! !enilno ti yrT ( # negate nothing 1 # push 1 (and implictly output it) 1 # push 1 ( # negate it (and implictly output it)


42

HQ9+ This will never fail to produce the intended result when a character is deleted so gets a score of zero. HH When do I start?


42

APL (1x3 = 3) 5!3 This solution uses the extra rule that any output that is correct mod 4 works. In APL, x!y is the number of way to choose x elements from y, commonly known as binom(y,x) or choose(y,x). Let's check that each rotation gives the right answer. 0 rotations 5!3 There's no way to choose 5 elements from 3, so we get 0, which is automatically ...


42

Python 2, 59 bytes print " Hello, world!"[ 2::] #rint "T w i s t e r !"[ ::2] Twisted: print "T weils,twerrd!"[ ::2] #rint " H l o o l !"[ 2::] Basically, puts the Twister! data in the odd indices of the string and then changes from removing the first two (padding) characters to removing every other character instead.


42

Hexagony, 7 bytes /)!@.). Prints 1 regularly then 2 doubled. Try it online! or Try it doubled online! Expanded versions: Regular: / ) ! @ . ) . Doubled: / ) ! @ . ) . / ) ! @ . ) . . . . . . The regular program follows the path: /)!.@ which increments a memory edge (all are initialised to zero) then prints its numeric value. The doubled ...


41

Ruby, 7×9 (63) 30;p 0||p=p 0|0;p;p ;p;p|p; p=p ||0 ;p p; 2||p =p 00;1 p A bit longer than the other solution, but at least this solution doesn't depend on any implicit printing or rule abuse. For all four rotations, the full code is parsed and other than some short-circuiting, all of it is executed. Surprisingly, there's absolutely no ...


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