Skip to main content

code_flows_forth.py

#!/usr/bin/env python

code = ["print('flows')", "print('forth')"]
code.append("code += code")
code.append("exec(code.pop())")
code.append("pass")

the_limit = len(code)

[exec(_) for i, _ in enumerate(code) if i < the_limit]

while code:
    print(f"{len(code)=}")
    exec(code.pop())
    if code:
        if not len(code) % the_limit:
            code.pop()
        if not len(code) % 1337:
            code = list(set(code))

print(code)
assert not code
del code

Comments