Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,61 @@
fastfunc isprim n .
for i = 2 to sqrt n
if n mod i = 0 : return 0
.
return 1
.
len isPrime[] 64
proc .
for i = 2 to 63
if isprim i = 1 : isPrime[i] = 1
.
.
global a[] .
fastfunc findRow start length .
if length = 2
return isPrime[a[start] + a[start + 1]]
.
for i = 1 step 2 to length - 2
if isPrime[a[start] + a[start + i]] = 1
swap a[start + i] a[start + 1]
if findRow (start + 1) (length - 1) = 1 : return 1
swap a[start + i] a[start + 1]
.
.
return 0
.
fastfunc countRows start length .
if length = 2
if isPrime[a[start] + a[start + 1]] = 1 : count += 1
else
for i = 1 step 2 to length - 2
if isPrime[a[start] + a[start + i]] = 1
swap a[start + i] a[start + 1]
count += countRows (start + 1) (length - 1)
swap a[start + i] a[start + 1]
.
.
.
return count
.
proc printRow .
numfmt 2 0
for i range0 len a[]
if i <> 0 : write " "
write a[i]
.
print ""
.
for i = 2 to 20
len a[] i
for j range0 i : a[j] = j + 1
if findRow 0 i = 1 : printRow
.
print ""
for i = 2 to 20
len a[] i
for j range0 i : a[j] = j + 1
if i > 2 : s$ &= " "
s$ &= countRows 0 i
.
print s$

View file

@ -0,0 +1,50 @@
local fmt = require "fmt"
local int = require "int"
require "table2"
local can_follow = {}
local arrang = {}
local bfirst = true
local function ptrs(res, n, done)
local ad = arrang[done]
if n - done <= 1 then
if can_follow[ad][n] then
if bfirst then
fmt.tprint("%2d", arrang, #arrang)
bfirst = false
end
res += 1
end
else
done += 1
for i = done, n - 1, 2 do
local ai = arrang[i]
if can_follow[ad][ai] then
local aid = arrang[done]
arrang[i], arrang[done] = aid, ai
res = ptrs(res, n, done)
arrang[i], arrang[done] = ai, aid
end
end
end
return res
end
local function prime_triangle(n)
can_follow = table.create(n)
for i = 1, n do
can_follow[i] = table.rep(n, false)
for j = 1, n do can_follow[i][j] = int.isprime(i + j) end
end
arrang = range(1, n)
bfirst = true
return ptrs(0, n, 1)
end
local res = {}
for i = 2, 20 do
res:insert(prime_triangle(i))
end
print()
print(res:concat(" "))

View file

@ -0,0 +1,7 @@
IsPrime ← =⊣⊸°/×
# Successors (<len) of n where n + S(n) is prime.
Nexts ← memo(⊂□[]≡◇(□≡⊣)↘1⊕□⊸≡⊢▽⊸≡(IsPrime/+)⧅≠ 2+1⇡)
# For each partial soln: add valid Nexts, exclude dupes.
Step ← /◇⊂≡(□▽⊸≡(=∩⧻⊸◴)≡⊂¤⟜(°□˜⊡Nexts⊃⋅∘∘⊣))
Matches ← ▽=⟜(⊸≡⊣⍥Step-1⊸⊙[[1]])
&p≡(⧻&p⊸⊢Matches)+1⇡14