Skip to main content
deleted 4 characters in body
Source Link
feersum
  • 31.8k
  • 10
  • 66
  • 125

Java 8, 7977

(x)->{for(int i=x.length,j,t;;t=x[j*=(Matht;;t=x[j*=Math.random())],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=x.length,j,t;;t=x[j*=(Matht;;t=x[j*=Math.random())],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try { s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 

Java 8, 79

(x)->{for(int i=x.length,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=x.length,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try { s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 

Java 8, 77

(x)->{for(int i=x.length,j,t;;t=x[j*=Math.random()],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=x.length,j,t;;t=x[j*=Math.random()],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try { s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 
added 7 characters in body
Source Link
feersum
  • 31.8k
  • 10
  • 66
  • 125

Java 8, 7279

(x)->{for(int i=0i=x.length,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=0i=x.length,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try { s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 

Java 8, 72

(x)->{for(int i=0,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=0,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try { s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 

Java 8, 79

(x)->{for(int i=x.length,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=x.length,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try { s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 
added 90 characters in body
Source Link
feersum
  • 31.8k
  • 10
  • 66
  • 125

Java 8, 8372

(x)->{for(int i=x.lengthi=0,j,t;i>0;x[j]=x[i],x[i]=t)t=x[j=(int)t;;t=x[j*=(Math.random()*i)],x[j]=x[i],x[i]=t)j=i--)];;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=x.lengthi=0,j,t;i>0;x[j]=x[i],x[i]=t)t=x[j=(int)t;;t=x[j*=(Math.random()*i)],x[j]=x[i],x[i]=t)j=i--)];;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try {   s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 

Java 8, 83

(x)->{for(int i=x.length,j,t;i>0;x[j]=x[i],x[i]=t)t=x[j=(int)(Math.random()*i--)];} 

It's a lambda taking int[] and returning void.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=x.length,j,t;i>0;x[j]=x[i],x[i]=t)t=x[j=(int)(Math.random()*i--)];}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; s.shuff(x); for(int a:x) System.out.println(a); } } 

Java 8, 72

(x)->{for(int i=0,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; 

It's a lambda taking int[] and returning void. My first attempt seemed not very interesting, so I decided to have it exit by throwing an exception.

Test program:

interface shuff { void shuff(int[] x); } class Ideone { public static void main (String[] args) throws java.lang.Exception { shuff s = (x)->{for(int i=0,j,t;;t=x[j*=(Math.random())],x[j]=x[i],x[i]=t)j=i--;}; int[] x = {3, 9, 2, 93, 32, 39, 4, 5, 5, 5, 6, 0}; try {   s.shuff(x); } catch(ArrayIndexOutOfBoundsException _) {} for(int a:x) System.out.println(a); } } 
Source Link
feersum
  • 31.8k
  • 10
  • 66
  • 125
Loading