Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
29
Task/Knuths-algorithm-S/Pluto/knuths-algorithm-s.pluto
Normal file
29
Task/Knuths-algorithm-S/Pluto/knuths-algorithm-s.pluto
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require "table2"
|
||||
|
||||
local function s_of_n_creator(n)
|
||||
local s = table.rep(n, 0)
|
||||
local next = 1
|
||||
local m = n
|
||||
return function(item)
|
||||
if next <= n then
|
||||
s[next] = item
|
||||
next += 1
|
||||
else
|
||||
m += 1
|
||||
if math.random(m) <= n then
|
||||
local t = math.random(n)
|
||||
s[t] = item
|
||||
if next <= t then next = t + 1 end
|
||||
end
|
||||
end
|
||||
return s
|
||||
end
|
||||
end
|
||||
|
||||
local freq = table.rep(10, 0)
|
||||
for r = 0, 99_999 do
|
||||
local son = s_of_n_creator(3)
|
||||
for d = 48, 56 do son(d) end
|
||||
for son(57) as d do freq[d - 47] += 1 end
|
||||
end
|
||||
print(freq:concat(", "))
|
||||
Loading…
Add table
Add a link
Reference in a new issue