Thursday 5th November, 2009
Java should not look like this: code from the undergraduate archive.

private static int[] s(int[] a, int sd) {
        int b=0, ds = sd, dsa = (sd!= 0 ? Math.abs(sd) : (ds=1)), f=0; // assume 0 is positive
        for (int d=0; d < a.length; d++) b = (a[d] >  b ? a[d] : b);
        int[] c = new int[b], e = new int[a.length];
        for (int d=0; d < a.length; d++) c[a[d]-1]++;
        for (int d=(sd < 0 ? b-1 : 0); (sd < 0 ? d >= 0 : d < b); d+=(ds/dsa)) while (c[d] > 0) {e[f++]=d+1; c[d]--;}
        return e;
}

posted by Rob Mitchelmore, 14:13 (anchor)
June 2015May 2015April 2015June 2014
January 2014November 2013October 2013July 2013
April 2013March 2013January 2013November 2012
older posts