Codementor Events

Array-3 Coding Bat

Published Oct 09, 2018

//I probably could have made this a lot more simple. However it wasn't a simple //problem

public int[] partOne(int n, int adder){
int main = adder;
int nTwo = n;
int x = 1;
int[] add = new int[nTwo];

while(x < n+1){

if(main > x){
add[(add.length)-x] = x;
}
x++;

}
return add;

}
public int[] sum(int[] One, int[] Two){

int oneAdder = 0;
int twoAdder = 0;
int threeAdder = 0;
int[] sumAsArray = new int[One.length+Two.length];
List<Integer> sumAsList = new ArrayList<Integer>();

while( oneAdder < One.length){

sumAsList.add(One[oneAdder]);
oneAdder++;

}
while( twoAdder < Two.length){

sumAsList.add(Two[twoAdder]);
twoAdder++;

}
while(threeAdder < sumAsList.size()){

sumAsArray[threeAdder] = sumAsList.get(threeAdder);
threeAdder++;

}

return sumAsArray;

}
public int[] squareUp(int n) {

int adder = 2;
int[] Null = {};
int[] End = {};
int y = 0;

while(y < n){
End = sum(End,partOne(n,adder));
adder++;
y++;

}

return End;
}

Discover and read more posts from Kavaughn Irons
get started
post commentsBe the first to share your opinion
Show more replies