393
quick explanation (thelemmy.club)
you are viewing a single comment's thread
view the rest of the comments
[-] Opisek@piefed.blahaj.zone 22 points 17 hours ago

oooooooooooooooo

0000000000000000

8888888888888888

oooooooooooooooooooooooooooooooo

[-] Barley_Man@sopuli.xyz 22 points 17 hours ago

oooooooooooooooooooooooooooooooo

00000000000000000000000000000000

88888888888888888888888888888888

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

[-] Etterra@discuss.online 3 points 8 hours ago

Do it 27 times and you have a million dollars and the IRS all over your ass.

[-] cypherpunks@lemmy.ml 20 points 16 hours ago* (last edited 7 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)]'

note: edited to stop after reaching 1MB, to avoid consuming all available RAM

[-] Etterra@discuss.online 3 points 8 hours ago

Does that loop infinitely? Because if it does Reddit needs to know ALL about it.

[-] cypherpunks@lemmy.ml 1 points 1 hour ago* (last edited 6 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 will probably have a bad time.

[-] cypherpunks@lemmy.ml 1 points 15 minutes ago* (last edited 4 minutes ago)

here is a version which will loop infinitely without consuming more RAM:python -c 'import itertools as I,time as T; list(filter(None,(list(filter(None,(print(["o","O","8","oo"][i%3],end="") for _ in range(2**(i//3))))) or print() or T.sleep(max(.3,1-(i/50))) for i in I.count())))'

It's technically not completely constant-space because i and 2**(i//3) are still growing... but it will take a very long time before it needs to allocate a small bit more.

I'm leaving the space-inefficient one in my original comment because it is easier to read.

[-] Barley_Man@sopuli.xyz 6 points 16 hours ago* (last edited 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...

[-] jol@discuss.tchncs.de 4 points 17 hours ago
[-] gratux@lemmy.blahaj.zone 1 points 3 hours ago* (last edited 3 hours ago)

โŒ›

๐Ÿง’

this post was submitted on 29 May 2026
393 points (98.3% liked)

Science Memes

20319 readers
837 users here now

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

founded 3 years ago
MODERATORS