Skip to main content
Commonmark migration
Source Link

##Java 7, 86 bytes

Java 7, 86 bytes

No fancy folds or matrices, just a good ol' fashioned for loop :)

int[]o(int[]a,int l){int i=0,o[]=new int[l];for(;i<a.length;)o[i%l]+=a[i++];return o;}

Try it on Ideone

Lined:

int[]o(int[]a,int l){
    int i=0,
        o[]=new int[l];
    for(;i<a.length;)
        o[i%l]+=a[i++];
    return o;
}

##Java 7, 86 bytes

No fancy folds or matrices, just a good ol' fashioned for loop :)

int[]o(int[]a,int l){int i=0,o[]=new int[l];for(;i<a.length;)o[i%l]+=a[i++];return o;}

Try it on Ideone

Lined:

int[]o(int[]a,int l){
    int i=0,
        o[]=new int[l];
    for(;i<a.length;)
        o[i%l]+=a[i++];
    return o;
}

Java 7, 86 bytes

No fancy folds or matrices, just a good ol' fashioned for loop :)

int[]o(int[]a,int l){int i=0,o[]=new int[l];for(;i<a.length;)o[i%l]+=a[i++];return o;}

Try it on Ideone

Lined:

int[]o(int[]a,int l){
    int i=0,
        o[]=new int[l];
    for(;i<a.length;)
        o[i%l]+=a[i++];
    return o;
}
Source Link
Geobits
  • 19.7k
  • 4
  • 55
  • 125

##Java 7, 86 bytes

No fancy folds or matrices, just a good ol' fashioned for loop :)

int[]o(int[]a,int l){int i=0,o[]=new int[l];for(;i<a.length;)o[i%l]+=a[i++];return o;}

Try it on Ideone

Lined:

int[]o(int[]a,int l){
    int i=0,
        o[]=new int[l];
    for(;i<a.length;)
        o[i%l]+=a[i++];
    return o;
}