Day 02 p2 complete
Signed-off-by: Eoghan Conlon <git@eoghanconlon.ie>
This commit is contained in:
parent
d544a7b5c7
commit
b7eff97777
1 changed files with 6 additions and 14 deletions
|
@ -120,25 +120,17 @@ public class Day02 extends Input{
|
||||||
} else {
|
} else {
|
||||||
safe -= 1;
|
safe -= 1;
|
||||||
int[] reading_cut = new int[readings.length - 1];
|
int[] reading_cut = new int[readings.length - 1];
|
||||||
for(int i = 0, j = 0; i < readings.length; i += 1){
|
while(danger >= 0 && oldSafeRead == safeReadings){
|
||||||
if(i != danger){
|
for(int a = 0, b = 0; a < readings.length; a += 1){
|
||||||
reading_cut[j] = readings[i];
|
if(a != danger){
|
||||||
j += 1;
|
reading_cut[b] = readings[a];
|
||||||
|
b += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(safe_p2(reading_cut) == -1){
|
if(safe_p2(reading_cut) == -1){
|
||||||
safeReadings += 1;
|
safeReadings += 1;
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0, j = 0; i < readings.length; i += 1){
|
danger -= 1;
|
||||||
if(i != danger - 1){
|
|
||||||
reading_cut[j] = readings[i];
|
|
||||||
j += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(safe_p2(reading_cut) == -1){
|
|
||||||
safeReadings += 1;
|
|
||||||
} else {
|
|
||||||
safe -= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue