• Barley_Man@sopuli.xyz
            link
            fedilink
            English
            arrow-up
            22
            ·
            17 hours ago

            oooooooooooooooooooooooooooooooo

            00000000000000000000000000000000

            88888888888888888888888888888888

            oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

            • Arthur Besse@lemmy.mlOP
              link
              fedilink
              English
              arrow-up
              20
              ·
              edit-2
              37 minutes ago

              python -c 'import 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 range(60)]'

                • Arthur Besse@lemmy.mlOP
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  edit-2
                  24 minutes 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.

              • Barley_Man@sopuli.xyz
                link
                fedilink
                English
                arrow-up
                6
                ·
                edit-2
                16 hours ago

                What on earth? Works on my machine

                Edit: oh I actually read the code and now I get that you are not replying back a error you got from my message…

    • Nima@leminal.space
      link
      fedilink
      English
      arrow-up
      5
      ·
      17 hours ago

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