Java, 7171 66 bytes, 2 exit codes
Full4 bytes saved thanks to Holger
###Full program:
interface I{static void main(String[]a){int x=a[0]a[a[0].equalscharAt("1")?1/0:1;)-48]="";}}
Function###Function taking an int as an argument:
i->1/(i-1)
Java doesn't seem to likeThe program takes the first char of the first argumant (either ? :'0'
operator if you you don't assign the result ot a variable. Crashes with exit code 1 while trying to calculateor 1/0'1'
when givenand subtracts 48 (ascii value of '0'
) to get an inputinteger (0 or 1). It then tries to set the argument at the position of that integer to the empty string. If the input is 1, the program crashes with an 1ArrayIndexOutOfBoundsException
, beacuse the argument array only has one element at position 0 (zero-indexed).