Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
I want to use Fibonacci-iterator solution in Clear category for Fibonacci Poem by U.V
def fib_iter():
a, b = 1, 1
yield a
yield b
while 1:
b, a = a + b, b
yield b
get_word = lambda x: x.pop(0) if x else '_'
def fibo_poem(text: str) -> str:
t = text.split()
fib = fib_iter()
lines=[]
while t:
lines.append(' '.join([get_word(t) for i in range(next(fib))]))
return '\n'.join(lines)
Jan. 6, 2023
Comments: