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,39 @@
max = 12
#
len cnt[] max
global sp[] pos .
#
fastfunc r n .
if n = 0 : return 0
c = sp[pos - n]
cnt[n] -= 1
if cnt[n] = 0
cnt[n] = n
if r (n - 1) = 0 : return 0
.
sp[pos] = c
pos += 1
return 1
.
fastproc callr n .
while r n = 1
#
.
.
proc superperm n .
pos = n
f = 1
for i = 1 to n
f *= i
le += f
.
len sp[] le
for i = 0 to n : cnt[i] = i
for i = 1 to n : sp[i - 1] = i
callr n
.
for n = 0 to max - 1
write "superperm(" & n & ") "
superperm n
print "len = " & len sp[]
.

View file

@ -0,0 +1,52 @@
const max = 12
struct SuperPerm {
mut:
sp []rune
count []int
pos int
}
fn fact_sum(nir int) int {
mut sir, mut xir, mut fir := 0, 0, 1
for xir < nir {
xir++
fir *= xir
sir += fir
}
return sir
}
fn (mut spm SuperPerm) rbl(nir int) bool {
if nir == 0 { return false }
cir := spm.sp[spm.pos - nir]
spm.count[nir]--
if spm.count[nir] == 0 {
spm.count[nir] = nir
if !spm.rbl(nir - 1) { return false }
}
spm.sp[spm.pos] = cir
spm.pos++
return true
}
fn (mut spm SuperPerm) super_perm(nir int) {
spm.pos = nir
len := fact_sum(nir)
if len > 0 { spm.sp = []rune{len: len} }
for ial in 0 .. max {
spm.count[ial] = ial
}
for ial in 1 .. nir + 1 {
spm.sp[ial - 1] = rune(`0` + ial)
}
for spm.rbl(nir) {}
}
fn main() {
mut spm := SuperPerm{count: []int{len: max}}
for nal in 0 .. max {
spm.super_perm(nal)
println("superPerm(${nal:2d}) len = ${spm.sp.len}")
}
}