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,34 @@
require "table2"
local function gen_sequence(ones, num_zeros)
if #ones == 0 then return {string.rep("0", num_zeros)} end
local result = {}
for x = 1, num_zeros - #ones + 1 do
local skip_one = ones:slice(2)
for gen_sequence(skip_one, num_zeros - x) as tail do
result:insert(string.rep("0", x) .. ones[1] .. tail)
end
end
return result
end
local function print_block(data, len)
local a = data:split("")
local sum_bytes = 0
if #a > 0 then sum_bytes = table.sum(a:mapped(|c| -> c:byte() - 48)) end
print($"\nblocks \{{a:concat(", ")}}, cells {len}")
if len - sum_bytes <= 0 then
print("No solution")
return
end
local prep = a:mapped(|c| -> string.rep("1", c:byte() - 48))
for gen_sequence(prep, len - sum_bytes + 1) as r do
print(r:sub(2))
end
end
print_block("21", 5)
print_block("", 5)
print_block("8", 10)
print_block("2323", 15)
print_block("23", 5)

View file

@ -0,0 +1,34 @@
import arrays
fn print_block(data string, len u8) {
mut a := data.split("").map(int(it.bytes()[0] - u8(48)))
mut sum_bytes := arrays.sum(a) or {0}
mut prep := a.map("1".repeat(it))
println("\n" + "blocks ${a}, cells ${len}")
if len - sum_bytes <= 0 {
println("No solution")
return
}
for r in gen_sequence(prep, len - sum_bytes + 1) {println(r[1..])}
}
fn gen_sequence(ones []string, num_zeros int) []string {
mut result := []string{}
mut skip_one := []string{len: ones.len}
if ones.len == 0 {return ["0".repeat(num_zeros)]}
for x := 1; x < num_zeros - ones.len + 2; x++ {
skip_one = ones[1..].clone()
for tail in gen_sequence(skip_one, num_zeros - x) {
result << "0".repeat(x) + ones[0] + tail
}
}
return result
}
fn main() {
print_block("21", 5)
print_block("", 5)
print_block("8", 10)
print_block("2323", 15)
print_block("23", 5)
}