Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public static boolean isPythagTriple(int a, int b, int c) {
int[] sides = {a, b, c};
java.util.Arrays.sort(sides);

int x = sides[0];
int y = sides[1];
int hypotenuse = sides[2];
long x = sides[0];
long y = sides[1];
long hypotenuse = sides[2];

return x * x + y * y == hypotenuse * hypotenuse;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
public class PythagoreanTripleTest {

@ParameterizedTest
@CsvSource({"3, 4, 5, true", "6, 8, 10, true", "9, 12, 15, true", "12, 16, 20, true", "15, 20, 25, true", "18, 24, 30, true", "5, 20, 30, false", "6, 8, 100, false", "-2, -2, 2, false", "0, 0, 0, false", "5, 5, 5, false"})
void testIsPythagoreanTriple(int a, int b, int c, boolean expected) {
@CsvSource({"3, 4, 5, true", "6, 8, 10, true", "9, 12, 15, true", "12, 16, 20, true", "15, 20, 25, true", "18, 24, 30, true", "30000, 40000, 50000, true", "60000, 80000, 100000, true", "100000, 240000, 260000, true", "30000, 40000, 50001, false", "65536, 65536, 65536, false", "5, 20, 30, false",
"6, 8, 100, false", "-2, -2, 2, false", "0, 0, 0, false", "5, 5, 5, false"})
void
testIsPythagoreanTriple(int a, int b, int c, boolean expected) {
assertEquals(expected, PythagoreanTriple.isPythagTriple(a, b, c));
}

Expand Down
Loading