Prime triangle: Difference between revisions

m
optimized slightly
m (optimized slightly)
Line 49:
counts, rowstrings = [1; zeros(Int, nrows - 1)], ["" for _ in 1:nrows]
@Threads.threads for r in shuffle(2:nrows)
p = zeros(Int, r - 1)
for e in permutations(2:2:r), o in permutations(3:2:r)
pi = Int[]0
for (x, y) in zip(e, o)
push!(p,[i x,+= y)1] = x
p[i += 1] = y
end
length(e) > length(o) && push!(p,[i += 1] = e[end])
if pmask[p[endi] + r + 1] && pmask[p[begin] + 1] && all(ij -> pmask[p[ij] + p[ij + 1]], 1:r-2)
if counts[r] == 0
rowstrings[r] = " 1" * prod([lpad(n, 3) for n in p]) * lpad(r + 1, 3) * "\n"
Line 87 ⟶ 89:
 
[1, 1, 1, 1, 1, 2, 4, 7, 24, 80, 216, 648, 1304, 3392, 13808, 59448]
191 62.172369956955 seconds (1699.4049 GM allocations: 15955.649571 GiB, 1822.1825% gc time, 0.0967% compilation time)
</pre>
 
4,103

edits