diff --git a/java/src/main/java/euler/p0076.java b/java/src/main/java/euler/p0076.java index c4998472..bd18ce0c 100644 --- a/java/src/main/java/euler/p0076.java +++ b/java/src/main/java/euler/p0076.java @@ -28,21 +28,24 @@ public Object answer() { counts[2] = 100; while (counts[100] == 0) { counts[2] += 2; + sum += 2; if (sum >= 100) { answer += (100 + counts[2] - sum) / 2; idx = 2; do { + sum -= counts[idx]; counts[idx] = 0; idx++; counts[idx] += idx; - sum = 0; - for (int i = idx - 1; i < 101; i++) - sum += counts[i]; + sum += idx; + // sum = 0; + // for (int i = idx - 1; i < 101; i++) + // sum += counts[i]; } while (sum > 100); } - sum = 0; - for (int i = 0; i < 101; i++) - sum += counts[i]; + // sum = 0; + // for (int i = 0; i < 101; i++) + // sum += counts[i]; } return answer; }