g | x | w | all
Bytes Lang Time Link
nan250805T104735ZSteve Be
018CJam150623T223210Zjimmy230
006Runic Enchantments190401T025613ZDraco18s
002Japt181206T183728ZKamil Dr
00105AB1E legacy181206T144547ZKevin Cr
002MathGolf181206T124335Zmaxb
002Dyalog APL151210T020221ZAdá
001Microscript150624T044429ZSuperJed
008Python150630T045613Zrp.beltr
003Mathematica151117T154244Zalephalp
001TIBASIC150623T195743Zlirtosia
007MATLAB150629T132017ZStewie G
005Lenguage150627T155909Zrandomra
008Swift and a lot more150629T225016ZKametrix
003APL150627T162513Zjimmy230
005J150627T101321Zrandomra
005CJam150626T145320Zaditsu q
006PHP150625T203730ZVoitcus
002GolfScript150625T152949ZDennis
011Clojure150624T150132ZZach Tha
003K150624T010709Zkirbyfan
001Sed150624T123811ZToby Spe
005JavaScript and a lot more150624T103240ZC5H8NNaO
nan150624T081113ZFatalize
006Python REPL150624T054130ZSp3000
005Octave150624T003309ZCraig Ro
003Pyth150623T200411ZJakube
005Any REPL with caret XOR operation150623T194725Zfeersum

Javascript REPL

34-25

Produces 9 unchanged, or -21, -22, 3425, 29 or 32 depending on the character removed.

CJam, JavaScript, Python, etc, 18 bytes

8.8888888888888888

Or simpler:

9.9999999999999999

The outputs in CJam are:

8.8888888888888888 -> 8.88888888888889
8.888888888888888  -> 8.888888888888888
88888888888888888  -> 88888888888888888
.8888888888888888  -> 0.8888888888888888

9.9999999999999999 -> 10.0 or 10 depending on the interpreter
9.999999999999999  -> 9.999999999999998
99999999999999999  -> 99999999999999999
.9999999999999999  -> 0.9999999999999999

JavaScript and Python work in similar ways. It isn't competitive in JavaScript and Python, but it's not easy to find a shorter one in CJam.

Runic Enchantments, 6 (modifiable) bytes

11-{{B\
/B~~@/
\00<
R"Error"@

Try it online!

Runic does not have a REPL environment and writing a full program to satisfy the constraints is not readily feasible (leading to either invalid programs or no output). So the portion of the code 11-{{B is acting as an inner function and only this portion can be modified. The B instruction is close enough to a function pointer and return statement that this classification should be acceptable (as it jumps the IP to a position in the code as well as pushing a return location to the stack which may be accessed by a subsequent B or discarded).

The final \ on the end of the first line provides an external boundary around the inner function in the event that the return instruction is removed so that the IP doesn't go meandering all over everywhere willy nilly (and print no output).

Note that Error051 is just an arbitrary string, I could put anything I wanted into that portion of the code and "Error" was an amusing result for having code that feks up the return coordinates and the IP teleports to an arbitrary location.

Japt, 2 bytes

Try it online!

A is pre-initialized to 10, É subtracts 1, and the result is 1 byte: 9.

Removing É results in the program A, which outputs A's value, 10, so the result is 2 bytes.

Similarly, removing A results in just É which is interpreted as -1 and output as -1, so the result is 2 bytes.

05AB1E (legacy), 1 byte

Any single byte in 05AB1E (legacy) would work, except for [ (infinite loop).

See here all possible outputs for all possible single-byte 05AB1E programs.

Removing that single byte so an empty program remains will output the content of info.txt to STDOUT instead by default.

Try it online.


05AB1E, 1 byte

?

Try it online.

Unfortunately an empty program in the new version of 05AB1E only outputs a 1-byte newline by default (Try it online), so almost none of the 1-byte characters are possible since they'll have to output nothing. The only possible program that outputs nothing (so also not the implicit newline) is ? as far as I know.

MathGolf, 2 bytes

♂(

Try it online!

Explanation

♂   Push 10
 (  Decrement TOS by 1

Why does this work?

The regular output is 9. If the ( is removed, the output is 10. If the is removed, the program implicitly pops a 0 from the stack to feed the ( operator, which outputs -1.

Dyalog APL, 2 bytes

⍴0 returns an empty string (length 0)

returns (length 1)

0 returns 0 (length 1)

Microscript, 1 byte

h

This produces no ouput, as h suppresses the language's implicit printing. Removing the sole character produces a program whose output is 0\n.

I'll try to come up with a better answer later.

EDIT ON NOVEMBER 17:

This also works in Microscript II, with the exception that, instead of yielding 0\n, the empty program yields null.

Python, 10 8 bytes

256**.25

Works in Python and friends. Thanks to Jakube for showing how to make it 2 bytes smaller.

From IDLE:

>>> 256**.25
4.0
>>> 26**.25
2.2581008643532257
>>> 56**.25
2.7355647997347607
>>> 25**.25
2.23606797749979
>>> 256*.25
64.0
>>> 256*.25
64.0
>>> 256**25
1606938044258990275541962092341162602522202993782792835301376L
>>> 256**.5
16.0
>>> 256**.2
3.0314331330207964

originally I had this (10 bytes):

14641**.25

From IDLE:

>>> 14641**.25
11.0
>>> 4641**.25
8.253780062553423
>>> 1641**.25
6.364688382085818
>>> 1441**.25
6.161209766937384
>>> 1461**.25
6.18247763499657
>>> 1464**.25
6.185648950548194
>>> 14641*.25
3660.25
>>> 14641*.25
3660.25
>>> 14641**25
137806123398222701841183371720896367762643312000384664331464775521549852095523076769401159497458526446001L
>>> 14641**.5
121.0
>>> 14641**.2
6.809483127522302

and on the same note:

121**.25*121**.25

works identically due to nice rounding by Python, in 17 bytes.

>>> 121**.25*121**.25
11.0
>>> 21**.25*121**.25
7.099882579628641
>>> 11**.25*121**.25
6.0401053545372365
>>> 12**.25*121**.25
6.172934291446435
>>> 121*.25*121**.25
100.32789990825084
>>> 121*.25*121**.25
100.32789990825084
>>> 121**25*121**.25
3.8934141282176105e+52
>>> 121**.5*121**.25
36.4828726939094
>>> 121**.2*121**.25
8.654727864164496
>>> 121**.25121**.25
29.821567222277217
>>> 121**.25*21**.25
7.099882579628641
>>> 121**.25*11**.25
6.0401053545372365
>>> 121**.25*12**.25
6.172934291446435
>>> 121**.25*121*.25
100.32789990825084
>>> 121**.25*121*.25
100.32789990825084
>>> 121**.25*121**25
3.8934141282176105e+52
>>> 121**.25*121**.5
36.4828726939094
>>> 121**.25*121**.2
8.654727864164496

Mathematica, 3 bytes

4!0

4!0  ->  0    the factorial of 4, times 0
4!   ->  24   the factorial of 4
40   ->  40
!0   ->  !0   the logical not of 0, but 0 is not a boolean value

TI-BASIC, 3 1

"

When the last line of a program is an expression, the calculator will display that expression. Otherwise, the calculator displays Done when the program finishes. The expression here is the empty string, but it could also work with any one-digit number.

2 bytes:

isClockOn

Same as the above but with a 2-byte token.

3 bytes:

ππ⁻¹

Prints 1 due to implied multiplication. Can be extended indefinitely by adding pairs of ⁻¹'s. The below also work.

√(25
e^(πi
⁻ii
ii³
2ππ   
cos(2π

Longer solutions:

11/77►Frac
ᴇ⁻⁻44
cos(208341   //numerator of a convergent to pi; prints "-1"

There are probably also multi-line solutions but I can't find any.

MATLAB, 9 7 bytes

It's 2 bytes longer than the other MATLAB/Octave answer, but I like it nonetheless, as it's a bit more complex.

Matlab's ' operator is the complex conjugated transpose. Using this on a scalar imaginary number, you get i' = -i. As imaginary numbers can be written simply as 2i one can do:

2i--2i'
ans =
     0    

Removing any one of the characters will result in one of the below:

ans =
   0.0000 - 1.0000i
   2.0000 - 2.0000i
   0.0000 + 4.0000i
   0.0000 + 4.0000i
   0.0000 + 1.0000i
   2.0000 + 2.0000i
   0.0000 + 4.0000i

Lenguage, 5 bytes

00000

The length of the program is 5 which corresponds to the brainf*** program , reading an end of input character and terminating without output.

Removing any char results in the code 0000 which has a length of 4 corresponding to the brainf*** program . printing out one character (codepoint 0) and terminating.

The Unary equivalent would be 0000000000000 (13 zeros) because you have to prepend a leading 1 to the binary length of the code so 101 becomes 1101.

Swift (and a lot more), 8 bytes

93^99<84

output (4 chars):

true

When removing the nth character the output is:

n -> out
----------
0 -> false
1 -> false
2 -> false
3 -> false
4 -> false
5 -> 10077
6 -> false
7 -> false

There are 78 possible solutions like this in the format of a^b<c.

I think the goal of this challenge should be as many bytes as possible, because the more bytes, the more possible bytes to remove and therefore more difficult.

APL, J and possibly other variants, 3 bytes

--1

It outputs 1 in APL. -1 outputs ¯1, and -- outputs the following in TryAPL:

┌┴┐
- -

J, 5 bytes

|5j12

Magnitude of the complex number 5 + 12i in REPL.

   |5j12 NB. original, magnitude of the complex number `5 + 12i`
13
   5j12  NB. the complex number `5 + 12i`
5j12
   |j12  NB. magnitude of the undefined function j12
| j12
   |512  NB. magnitude of 512
512
   |5j2  NB. magnitude of 5 + 2i
5.38516
   |5j1  NB. magnitude of 5 + 1i
5.09902

.

J, 9 bytes

%0.333333

Based on floating point precision, reciprocal and matrix inverse.

   %0.333333 NB. original, reciprocal of 0.333333
3
   0.333333  NB. 0.333333
0.333333
   %.333333  NB. matrix inverse of 333333
3e_6
   %0333333  NB. reciprocal of 333333
3e_6
   %0.33333  NB. reciprocal of 0.33333
3.00003

Try it online here.

CJam, 5

''''=

Try it online

''''=   compares two apostrophes and prints 1
'''=    prints '=
''''    prints ''

PHP, 6 bytes

I have been watching this group for a couple of weeks and am amazed of your programming techniques. Now I had to sign in, there is something I can do, sorry :-) However, this might be my last post here...

<?php 

(note the space after second p)

This outputs empty string. Removing any character outputs the text without the character. Note it can produce HTML errors (content not rendered by browsers for eg. <?ph).

I also tried with the echo tag. ie. eg.:

<?= __LINE__;;

This one outputs 1. If = is omitted, <? __LINE__;; is the output. However, removing any of the magic constant character will result in E_NOTICE: Notice: Use of undefined constant LNE - assumed 'LNE' in...

If notices are not considered errors (point 4 of rules), this also applies :-)

GolfScript, 2 bytes

This answer is non-competing, but since it is the piece of code that inspired this challenge, I wanted to share it anyway.

:n

By default, all GolfScript programs print the entire stack, followed by a linefeed, by executing puts on the entire stack. The function puts itself is implemented as {print n print} in the interpreter, where print is an actual built-in and n is a variable that holds the string "\n" by default.

Now, a GolfScript program always pushes the input from STDIN on the stack. In this case, since there isn't any input, an empty string is pushed. The variable assignment :n saves that empty string in n, suppressing the implicit linefeed and making the output completely empty.

By eliminating n, you're left with the incomplete variable assignment : (you'd think that's a syntax error, but nope), so the implicit linefeed is printed as usual.

By eliminating :, you're left with n, which pushes a linefeed on the stack, so the program prints two linefeeds.

Clojure, 11 bytes

(defn x[]1)

At first I thought to just post a single character answer in the REPL like the other languages, e.g.

user=> 1
1

But the problem is that if you remove that character, the REPL doesn't do anything upon the enter keypress. So instead it had to be wrapped with a function as permitted by the question's rules. When you call this function, it returns 1. If you remove the only character in the function,

(defn x[])

the function returns nil which prints an additional two bytes.

user=> (defn x[]1)
#'user/x
user=> (x)
1
user=> (defn y[])
#'user/y
user=> (y)
nil

K, 3 bytes

2!2

Outputs 0 in the REPL. Removing the first 2 outputs 0 1, removing the exclamation results in 22, and removing the last 2 results in a string that varies between K implementations but is always at least 2 characters (in oK, it's (2!); according to @Dennis, Kona outputs 2!).

Sed, 1 byte

d

As sed requires an input stream, I'll propose a convention that the program itself should be supplied as input.

$ sed -e 'd' <<<'d' | wc -c
0
$ sed -e '' <<<'d' | wc -c
2

An alternative program is x, but that only changes from 1 to 2 bytes of output when deleted.

JavaScript (and a lot more), 5byte

44/44 or

44/44 -> 1
44/4  -> 11
4444  -> 4444
4/44  -> 0.09090909090909091

SWI-Prolog interpreter

__A=__A.

Note: You cannot remove the final .. Prolog interpreters will always look for a final period to run your query, so if we stick strictly to the rules of this contest and allow ourselves to remove the period it won't run, it will jump a line and wait for additional commands until one is ended by a period.

The original query __A=__A. outputs true..

The query _A=__A. outputs _A = '$VAR'('__A'). Similar modifications (i.e. removing one _ or one of the two A) will result in similar outputs.

Finally, the query __A__A. outputs in SWI-Prolog:

% ... 1,000,000 ............ 10,000,000 years later
% 
%       >> 42 << (last release gives the question)

Python REPL, 6 bytes

Not the shortest, but here's another floating point abuse answer:

>>> 1e308
1e+308
>>> 11308
11308
>>> 11e08
1100000000.0
>>> 11e38
1.1e+39
>>> 11e30
1.1e+31

But...

>>> 11e308
inf

Octave, 5 bytes

10:10

(x : y) gives the array of numbers between x and y in increments of 1, so between 10 and 10 the only element is 10:

> 10:10
ans = 10

When the second argument is less than the first, octave prints the empty matrix and its dimensions:

> 10:1
ans = [](1x0)

> 10:0
ans = [](1x0)

When a character is removed from the first number, there are more elements in the array:

> 1:10
ans = 1 2 3 4 5 6 7 8 9 10

> 0:10
ans = 0 1 2 3 4 5 6 7 8 9 10

When the colon is removed, the number returns itself:

> 1010
ans = 1010

Pyth, 3 bytes

cGG

G is preinitialized with the lowercase letters in the alphabet. c is the split-function.

cGG splits the alphabet by occurrences of the alphabet, which ends in ['', ''] (8 bytes).

When the second parameter is missing, c splits the string by whitespaces, tabs or newlines. Since none of them appear in G, the output for cG is ['abcdefghijklmnopqrstuvwxyz'] (30 bytes).

And GG simply prints twice the alphabet on two seperate lines: abcdefghijklmnopqrstuvwxyz\nabcdefghijklmnopqrstuvwxyz (53 bytes).

Try it online: Demonstration

Any REPL with caret XOR operation, 5 bytes

11^11

11^11 is of course 0. The only other possibilities are 1^11 or 11^1 which are 10, or 1111 which produces itself.