Law of cosines - triples: Difference between revisions
Content added Content deleted
Line 538: | Line 538: | ||
{{trans|zkl}} |
{{trans|zkl}} |
||
<lang julia>sqdict(n) = Dict( [(x*x, x) for x in 1:n]) |
<lang julia>sqdict(n) = Dict( [(x*x, x) for x in 1:n]) |
||
numnotsame(arrarr) = sum(map(x -> !all(y -> y == x[1], x), arrarr)) |
|||
numnotsame(arrarr) = sum(map(x -> notallsame(x), arrarr)) |
|||
function filtertriangles(N) |
function filtertriangles(N) |
||
Line 547: | Line 546: | ||
t120 = Vector{Vector{Int}}() |
t120 = Vector{Vector{Int}}() |
||
for x in 1:N, y in 1:x |
for x in 1:N, y in 1:x |
||
xsq = x*x |
xsq, ysq, xy = (x*x, y*y, x*y) |
||
ysq = y*y |
|||
xy = x*y |
|||
if haskey(sqd, xsq + ysq - xy) |
if haskey(sqd, xsq + ysq - xy) |
||
push!(t60, sort([x, y, sqd[xsq + ysq - xy]])) |
push!(t60, sort([x, y, sqd[xsq + ysq - xy]])) |