Skip to content

Commit

Permalink
Reenable p76, use int not byte
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 12, 2024
1 parent 4a6ecc9 commit 9edbf32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions java/src/main/java/euler/p0076.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
public class p0076 implements IEuler {
@Override
public Object answer() {
byte idx, sum = 100;
int answer = 0;
byte[] counts = new byte[101];
int idx, sum = 100, answer = 0;
int[] counts = new int[101];
counts[2] = 100;
while (counts[100] == 0) {
counts[2] += (byte) 2;
counts[2] += 2;
if (sum >= 100) {
answer += (100 + counts[2] - sum) / 2;
idx = 2;
Expand All @@ -37,12 +36,12 @@ public Object answer() {
idx++;
counts[idx] += idx;
sum = 0;
for (byte i = (byte) (idx - 1); i < 101; i++)
for (int i = idx - 1; i < 101; i++)
sum += counts[i];
} while (sum > 100);
}
sum = 0;
for (byte i = 0; i < 101; i++)
for (int i = 0; i < 101; i++)
sum += counts[i];
}
return answer;
Expand Down
2 changes: 1 addition & 1 deletion java/src/test/java/EulerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static Stream<Object[]> data() throws IOException {
new Object[] { p0020.class, false, Utilities.getAnswer(20) },
new Object[] { p0022.class, false, Utilities.getAnswer(22) },
new Object[] { p0034.class, false, Utilities.getAnswer(34) },
// new Object[] { p0076.class, true, Utilities.getAnswer(76) },
new Object[] { p0076.class, true, Utilities.getAnswer(76) },
new Object[] { p0836.class, false, Utilities.getAnswer(836) });
}

Expand Down

0 comments on commit 9edbf32

Please sign in to comment.