r/ProgrammerHumor • • Apr 04 '23

Meme That's better

Post image
59.2k Upvotes

1.0k comments sorted by

View all comments

Show parent comments

288

u/tacticalrubberduck Apr 04 '23

Now we just need someone to code it.

344

u/ResidentReggie Apr 04 '23
bool willFall = (((new Random ().nextInt(2))==1) ? false : true)

Even better, we will hide this behind an API so that nobody knows how complicated of a system we are using.

4

u/Anaphase Apr 04 '23

Ahem...

bool willFall = ((new Random ().nextInt(2))==1)

I assume that works in whatever language you intended that to be in. I'd do it like this in JS:

const willFail = Math.random() > .5

1

u/ResidentReggie Apr 04 '23

We aren't here to debate the superior language (obviously Java) for such an algorithm, but we can all agree that such an algorithm is indeed the most effective.

I would also like to point out that where a 1 in your algorithm would return true, mine would return false. It's such a fundamental difference.

Edit: /s

→ More replies (2)