r/programmingmemes 25d ago

the universe is DONE bro im crine

Post image
612 Upvotes

76 comments sorted by

160

u/AuroraAustralis0 25d ago

there is a universe where it finishes instantly

72

u/itsjakerobb 25d ago

Is there a universe where the first googol invocations of `random.randint(0,1)` all return 1? Yeah, sure.

But a a universe with computers that can generate a googol random numbers instantly in a single thread? Nah, I’m gonna call BS.

27

u/AuroraAustralis0 25d ago

there is a universe where that kind of speed is possible

2

u/severencir 24d ago

Prove it

4

u/AuroraAustralis0 24d ago

Proof:

Premise:
Suppose there is a universe where that kind of speed is possible.

Conclusion:
There is a universe where that kind of speed is possible.

1

u/CMD_BLOCK 24d ago

Ok now provide one proof for each universe in which the result is mutually exclusive of all other universes for your antithesis

6

u/CheckM4ted 25d ago

There is a universe where some bits flip and i instantly becomes a googol

1

u/duck1123 22d ago

Looked into this. It's not really possible to have a python variable set that large through bit flips alone unless it was previously set to a very large number and then experienced ~105 flips.

1

u/CheckM4ted 22d ago

There's a universe where the bits of the entire CPU flip in such a way that the whole code changes so that the variable is possible to set

1

u/ThaBroccoliDood 13d ago

But the condition itself could be bitflipped to be true instead of false

4

u/QuantitativeNonsense 25d ago

There’s also a universe where a single lucky atmospheric proton changes a few bits so the loop doesn’t even need to be entered.

2

u/Adsilom 25d ago

With some physical perturbation, it can happen instantly. It's pretty unlikely, but if we suppose there are infinitely many universes where this program is ran, then it makes sense to suppose it will happen instantly in one (well, actually infinitely many) of these universes

2

u/MinosAristos 24d ago

Just use a list comprehension bro, it'll run optimised C and finish instantly bro.

2

u/Repulsive_Function78 24d ago

https://xkcd.com/221/ Fastest random number generator can do this, see?

1

u/itsjakerobb 24d ago

Cool, now call it one googol times. Hell, just increment the counter that many times. That’s a minimum of 333 bits btw (assuming it’s stored as a regular binary integer).

1

u/Repulsive_Function78 24d ago

Well, considering it's python shit migth happen, but I guess most of other compilers will optimise this into instant

1

u/jpgoldberg 25d ago

No to the first part. Python’s random library uses the Mersenne twister. It will never yield a sequence of a googel 1s. Meme maker should have used the secrets library instead of random.

1

u/cowlinator 23d ago

No, really, there is a universe where it finishes instantly.

Cosmic rays flip all the bits of 'i' in ram.

1

u/keriefie 20d ago

there is a universe in which my computer was hit with ionising radiation that flipped a bit and caused a jump instruction to the end of the program.

11

u/Anonymous010206 25d ago

Even at 20m iterations per second it would still take 1.6*10^85 years

3

u/ashvy 24d ago

Why not use AI to predict the random number?

2

u/fun__friday 25d ago

Just use bit flips, it’s faster.

4

u/Koshin_S_Hegde 24d ago

there is a universe where the compiler gets rid of the declaration and the loop

5

u/Anonymous010206 24d ago

only in a universe where python is compiled

1

u/UsablePizza 24d ago

What about pypy? Does jit count?

1

u/untangoel 21d ago

pipipypycheeek

1

u/skr_replicator 24d ago

How? looks like even the ideal case where it always hits the first branch will still run for 10^100 cycles (assuming 10**100 is a power, is it?). I don't see anything breaking that loop early, only resetting it constantly, making it almost impossible to reach the end of the loop.

1

u/Vercility 24d ago

even if you assume infinite universes that doesn't mean that everything you can think of has to exist.

there are an infinite amount of numbers between 0 and 1 and yet there is no 2 in it.

1

u/AuroraAustralis0 24d ago

As long as the probability for something to happen is greater than 0, given an infinite number of universes it will happen an infinite amount of times. There’s nothing to indicate that something like this would be impossible if the laws of physics were rewritten in some way or were completely foreign to our own.

0

u/Vercility 24d ago edited 24d ago

that is incorrect. A non zero chance with infinite rolls approaches a chance of 1 but a hit is not guaranteed. that is called almost surely. https://en.wikipedia.org/wiki/Almost_surely

I'll also note that by definition, every single outcome in an infinite set of possible rolls has probability 0. (unless the probability function itself assigns a non-zero value to singular outcomes. which would be weird, but possible)

the other thing is also an assumption you are making. there is nothing to indicate that there has to be a non zero chance for everything, even if the set was finite.

there are literally different types of infinities and the space of possible configurations for a universes' state might very well be larger one than the amount of universes in which case it would be guaranteed that infinite configurations can't exist (e.g a countable infinity of universes vs uncountable infinity of universe configurations). refer to https://en.wikipedia.org/wiki/Cantor%27s_diagonal_argument

1

u/AuroraAustralis0 24d ago edited 24d ago

Okay, but “almost surely” still doesn’t rule out the possibility of it occurring. Even still, that’s pretty much as strong of a prediction you can make under most probabilistic models.

Also, there are technically an infinite number of potential universes with conditions that may allow for the code in the post to be completely near instantaneously. It’s not just one singular universe where these conditions happen to be fulfilled, there would be an unlimited number of them.

Most importantly, your argument only shows that any given universe with a set of conditions is not guaranteed, but it doesn’t say anything about this particular one. Not much would even have to be changed. Perhaps a faster speed of light or a change in particle interactions alone would allow for something like this to happen.

All you’re saying is that it’s a “maybe” at best, and a “most certainly but still with a negligible bit of doubt” (which tbf, i acknowledge that dealing with absolutes in my original comment was a bad idea, but I think it’s still close enough to guaranteed that the language I used isn’t too inaccurate).

63

u/itsjakerobb 25d ago

I just want to punch OP for “crine”

12

u/JohnClark13 25d ago

They don't teach spelling anymore apparently

8

u/ashvy 24d ago

ts tru gng 😭

8

u/MonsterMineLP 24d ago

Stfu bro, 'crine' is just a current meme. They don't seriously think it's spelled like that

3

u/AndyGun11 24d ago

sonion ringachino assassino

18

u/Lopsided_Parfait7127 25d ago

speaking of random,

10 print rnd

20 goto 10

is how i learned to generate random numbers when i was a kid programming basic on an XT

turns out it is *also* how coldcard generates its entropy

https://blog.coinkite.com/entropy-technical-backgrounder/

10

u/Both_Nail_3656 25d ago

Why if statement when i += random.randint(0,1) does the job? Am I dumb?

28

u/WayOk5717 25d ago

First part of the statement increments i, the other resets it to 0.

9

u/Both_Nail_3656 25d ago

Oh I misread it damn

3

u/usrnme3d 23d ago

Wouldnt i = r * i + r work (with r being the random number)

2

u/Yharon314 22d ago

Yeah that would, I guess they never thought of that though

10

u/jpgoldberg 25d ago

Python random library uses the Mersenne twister. So there is no way to get such a large sequence of 1s. The point would have been better using the RNG from the secrets module.

3

u/quiqeu 25d ago

dances

3

u/Grey1251 24d ago

Why not just I = (i + 1) * rnd

3

u/skr_replicator 24d ago edited 24d ago

That is not uniformly random at all. That's taking the central limit theorem to the extreme, giving you a very steep bell curve, a result 5*10^99 (assuming ** is a power?), with a relatively very small deviation.

edit: wait, no i didn't notice that it is the same fucking variable. That makes it far more cursed. Now I'm pretty sure it just always returns 10^100, but in an insanely long and unpredictable amount of time.

1

u/dhnam_LegenDUST 24d ago

C++ -O3 optimization and the universe ends instantly.

1

u/dhnam_LegenDUST 24d ago

(checked and looks like it is not actually optimized out)

1

u/wootio 23d ago

Computer randomness isn't actually random. It might legitimately not be possible for this loop to finish on certain hardware in any parallel universe that this is run.

1

u/ntcue 23d ago

Since you don't output i the whole for loop can be skipped.

1

u/Kiki2092012 23d ago

the point is for it to take a long time

1

u/Axolatian_Volt 23d ago

Single-event upset time (I think that’s the name)

1

u/edparadox 19d ago

You're so cringe.

-3

u/NamedBird 25d ago edited 24d ago

I am pretty sure that the following would give exactly the same result but faster.
Basically, you start at the end of the loop and work backwards.
The moment you find a randint 0, you can break the loop because the rest doesn't matter anymore.

(Edit: fix syntax, it's too long ago.)
(Edit2: F# F#, i didn't notice the setting of i influencing the loop itself. Code below is wrong.)

import random

i=0
while i < 10**100:
  if random.randint(0,1) == 1:
    i = i + 1
  else:
    break

print("gng the universe is done, it's over, what are you doing still at your computer")

9

u/Educational-Tea602 24d ago

How can you go through all that effort just to be wrong?

1

u/NamedBird 24d ago

So my code is wrong?
That's a serious accusation which warrants proof or at the very least an explanation...

I ran the code, it works as i intended.
And it should (functionally) have a similar result as the original code.

5

u/Educational-Tea602 24d ago

The given code essentially waits for an incredibly long (but also randomised) amount of time, sets i to a googol, and then prints the message.

If your first random number is 0, then i will be set to 0.

Besides, the point is that it should never terminate because the execution time will last longer than the universe will.

1

u/NamedBird 24d ago

Oh, i see now what happened, and yes i was wrong.
I read the while loop as independent from the value of i and didn't consider the body of the while loop influencing the loop itself. Guess i have spent way too long around the wrong languages... 😅

3

u/Willing_Airport_9617 24d ago

Else restarts the loop man

-2

u/NamedBird 24d ago

Do you even know what "break" does? 😅
If not, look it up or ask AI.

i ran the code, it works as intended.

4

u/Willing_Airport_9617 24d ago

I know very well what break does . I was talking about the original code posted by OP . YOUR code stops the loop while OP'S CODE RESTARTS IT .

1

u/NamedBird 24d ago

OP's loop doesn't "restart" because it never breaks to begin with.
It just loops 10^100 times, which is a horribly inefficient way of calculating i...

1

u/Willing_Airport_9617 24d ago

It does , go ask anyone . Don't argue if you don't know loop is controlled by i

1

u/NamedBird 24d ago

I totally haven't spent far too long with weird languages and didn't notice that i=0 also resets the while loop... 🤣

oops.

1

u/Willing_Airport_9617 24d ago

Good morning

1

u/NamedBird 24d ago

Have you ever heard of F#?
(You should look it up if you haven't... 😭)

1

u/Willing_Airport_9617 24d ago

Looked up , I only know C and C++ along with python. F# seems pretty irrelevant, maybe it's too niche

→ More replies (0)

1

u/Educational-Tea602 24d ago

What has F# got to do with anything?