• Barley_Man@sopuli.xyz
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 month ago

            oooooooooooooooooooooooooooooooo

            00000000000000000000000000000000

            88888888888888888888888888888888

            oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

            • Arthur Besse@lemmy.mlOP
              link
              fedilink
              English
              arrow-up
              0
              ·
              1 month ago

              python -c 'import sys,itertools as it,time as t;a="o\n";[(t.sleep(max(.3,1-(i/50))),sys.stdout.write(a),a:=a.replace(*["o","O","8","oo"][i%3:i%3+2]))for i in it.count()]'

                • Arthur Besse@lemmy.mlOP
                  link
                  fedilink
                  English
                  arrow-up
                  0
                  ·
                  edit-2
                  30 days ago

                  Does that loop infinitely

                  The first version I posted would loop infinitely… if you have infinite RAM, that is 🫠 (the string will reach 1KB after 30 iterations, and 1MB after 60, 2MB after 63, and so on).

                  Fortunately the rate of memory consumption is not too fast because python string replacement is very slow, but, thanks to your question making me think about it, to avoid eventually crashing someone’s computer if they don’t know to hit ctrl-c to kill it, i’ve now edited it so that it will stop after 60 iterations.

                  here is the original which will in fact run until it runs out of memory:

                  python -c 'import itertools as I,time as t;a="o";[(print(a),a:=a.replace(*["o","O","8","oo"][i%3:i%3+2]),t.sleep(max(.3,1-(i/50))))for i in I.count()]'

                  if you leave this running long enough, you will be at the mercy of your operating system’s out-of-memory-killer… if it decides to kill other things before it kills this python process you might have a bad time.

    • Nima@leminal.space
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 month ago

      bash. org for the win. (the site has been down for some time now I am pretty sure)