Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose sides' lengths are \$\sqrt{a}, \sqrt{b}, \sqrt{c}\$. By "on the square lattice" I mean that its vertices are in the \$xy\$ plane, and their \$x\$ and \$y\$-coordinates are all integers
This is code-golf so the shortest code in bytes wins.
Test cases:
- 16 9 25: true (3-4-5 triangle)
- 8 1 5: true (e.g. (0,0), (1,0), (2,2))
- 5 10 13: true (e.g. (0,1), (1,3), (3,0); sides needn't be on grid lines)
- 10 2 1: false (not a triangle: long side is too long for short sides to meet)
- 4 1 9: false (not a triangle: three points in a straight line)
- 3 2 1: false (triangle is on the cubic lattice but not the square lattice)
- 3 7 1: false (triangle is on the hex lattice but not the square lattice)
- 25 25 25: false (no such triangle on this lattice)
- 5 5 4: true (isosceles is OK)
- 15 15 12: false (OK shape, wrong size)
- 25 25 20: true (OK shape and size; common prime factor 5 is OK)
- 4 4 5: false (Bubbler's suggestion)
- 17 17 18: true (acute isosceles with equal short sides OK)
- 26 37 41: true (acute scalene is OK)
These same test cases, but just the numbers. First, those that should return true:
16 9 25
8 1 5
5 10 13
5 5 4
25 25 20
17 17 18
26 37 41
Then those that should return false:
10 2 1
4 1 9
3 2 1
3 7 1
25 25 25
15 15 12
4 4 5 -> false
, which prevents set-based comparison of side lengths. \$\endgroup\$