my code for java class, it's probably stupid. play with it so you figure out how it works. it's been put on here as a purely "collaborative" learning effort
Wednesday, March 30, 2011
Sunday, March 6, 2011
lessBy10
public boolean lessBy10(int a, int b, int c) {
if(a-b>=10 || a-c>=10 || b-a>=10 || b-c>=10 || c-a>=10 || c-b>=10){
return true;
}
return false;
}
if(a-b>=10 || a-c>=10 || b-a>=10 || b-c>=10 || c-a>=10 || c-b>=10){
return true;
}
return false;
}
love6
public boolean love6(int a, int b) {
if(a == 6 || b == 6){
return true;
}
if(a + b == 6 || a - b == 6 || b - a == 6){
return true;
}
return false;
}
if(a == 6 || b == 6){
return true;
}
if(a + b == 6 || a - b == 6 || b - a == 6){
return true;
}
return false;
}
front11
public int[] front11(int[] a, int[] b) {
if(a.length == 0 && b.length == 0){
int[] c = new int[] {};
return c;
}
if(a.length == 0){
int[] c = new int[1];
c[0] = b[0];
return c;
}
if(b.length == 0){
int[] c = new int[1];
c[0] = a[0];
return c;
}
else{
int[] c = new int[2];
c[0] = a[0];
c[1] = b[0];
return c;
}
}
if(a.length == 0 && b.length == 0){
int[] c = new int[] {};
return c;
}
if(a.length == 0){
int[] c = new int[1];
c[0] = b[0];
return c;
}
if(b.length == 0){
int[] c = new int[1];
c[0] = a[0];
return c;
}
else{
int[] c = new int[2];
c[0] = a[0];
c[1] = b[0];
return c;
}
}
reverse3
public int[] reverse3(int[] nums) {
int[] r = new int[3];
r[0] = nums[2];
r[1] = nums[1];
r[2] = nums[0];
return r;
}
int[] r = new int[3];
r[0] = nums[2];
r[1] = nums[1];
r[2] = nums[0];
return r;
}
commonEnd
public boolean commonEnd(int[] a, int[] b) {
if(a[0] == b[0] || a[a.length - 1] == b[b.length - 1]){return true;}
else{return false;}}
if(a[0] == b[0] || a[a.length - 1] == b[b.length - 1]){return true;}
else{return false;}}
Subscribe to:
Posts (Atom)