Skip to main content
fixed byte count
Source Link
corvus_192
  • 5.7k
  • 15
  • 24

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

Java, 71 bytes, 2 exit codes

Full program:

interface I{static void main(String[]a){int x=a[0].equals("1")?1/0:1;}}

Function taking an int as an argument:

i->1/(i-1)

Java doesn't seem to like the ? : operator if you you don't assign the result ot a variable. Crashes with exit code 1 while trying to calculate 1/0 when given an input of 1.

Java, 71 66 bytes, 2 exit codes

4 bytes saved thanks to Holger

###Full program:

interface I{static void main(String[]a){a[a[0].charAt(0)-48]="";}}

###Function taking an int as an argument:

i->1/(i-1)

The program takes the first char of the first argumant (either '0' or '1' and subtracts 48 (ascii value of '0') to get an integer (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 ArrayIndexOutOfBoundsException, beacuse the argument array only has one element at position 0 (zero-indexed).

fix typo
Source Link
corvus_192
  • 5.7k
  • 15
  • 24

Java, 71 bytes, 2 exit codes

Full program:

interface I{static void main(String[]a){int x=a[0].equals("1")?1/0:1;}}

Function taking an int as an argument:

i->1/(i-1)

Java doesn't seem to like the ? : operator if you you don't assign the result ot a variable. Crashes with exit code 1 while trying to calculate 1/0 hwenwhen given an input of 1.

Java, 71 bytes, 2 exit codes

Full program:

interface I{static void main(String[]a){int x=a[0].equals("1")?1/0:1;}}

Function taking an int as an argument:

i->1/(i-1)

Java doesn't seem to like the ? : operator if you you don't assign the result ot a variable. Crashes with exit code 1 while trying to calculate 1/0 hwen given an input of 1.

Java, 71 bytes, 2 exit codes

Full program:

interface I{static void main(String[]a){int x=a[0].equals("1")?1/0:1;}}

Function taking an int as an argument:

i->1/(i-1)

Java doesn't seem to like the ? : operator if you you don't assign the result ot a variable. Crashes with exit code 1 while trying to calculate 1/0 when given an input of 1.

Source Link
corvus_192
  • 5.7k
  • 15
  • 24

Java, 71 bytes, 2 exit codes

Full program:

interface I{static void main(String[]a){int x=a[0].equals("1")?1/0:1;}}

Function taking an int as an argument:

i->1/(i-1)

Java doesn't seem to like the ? : operator if you you don't assign the result ot a variable. Crashes with exit code 1 while trying to calculate 1/0 hwen given an input of 1.