Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
29
Task/Generator-Exponential/Pluto/generator-exponential.pluto
Normal file
29
Task/Generator-Exponential/Pluto/generator-exponential.pluto
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
local function powers(n)
|
||||
local i = 0
|
||||
while true do
|
||||
coroutine.yield(i ** n)
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
|
||||
local function squares_not_cubes()
|
||||
local cosq = coroutine.create(powers)
|
||||
local cocu = coroutine.create(powers)
|
||||
local cube = 0
|
||||
while true do
|
||||
local _, square = coroutine.resume(cosq, 2)
|
||||
while cube < square do
|
||||
_, cube = coroutine.resume(cocu, 3)
|
||||
end
|
||||
if cube != square then coroutine.yield(square) end
|
||||
end
|
||||
end
|
||||
|
||||
local co = coroutine.create(squares_not_cubes)
|
||||
local count = 0
|
||||
while count < 30 do
|
||||
local _, square = coroutine.resume(co)
|
||||
count += 1
|
||||
if count > 20 then io.write($"{square} ") end
|
||||
end
|
||||
print()
|
||||
Loading…
Add table
Add a link
Reference in a new issue