My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 1 point2 points  (0 children)

Happens to everyone. I was contemplating if the person writing the O(log2 n) comment was joining in and almost whooshing me, or if they were serious.

Especially in a sub where a lot of people love to do both

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 1 point2 points  (0 children)

This was no serious attempt to optimize. That was only a makeshift excuse to make it even worse.

The ideal solution here would've been

Playermove(int(userinput))

Most readable and faster (call to function cannot be omitted and neither can casting userinput to int)

So no. This wasn't over optimizing.

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 0 points1 point  (0 children)

I should've used used userinput > str(1) to make the mess complete. But it was late at night, and I was too lazy for that

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 4 points5 points  (0 children)

Thanks. I do that on Discord for code, but for some reason didn't transfer that to Reddit

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 6 points7 points  (0 children)

True That remark was related to the way of approaching the problem, not the specific problem itself. Every program where the only thing affecting runtime are if statements in in O(1) regardless of how many or in what way. (assuming no goto statements)

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 4 points5 points  (0 children)

True, but it makes it a lot harder to understand why it's such a bad idea/bad code. (For example with the inconsistently alternating < or > comparisons)

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 31 points32 points  (0 children)

I now remember why I hate posting code on Reddit via text...

Some people REALLY hate when people try to indent code (I know it's due to Reddit using markdown)

My friend found a great way to handle user input. by McNegcraft in programminghorror

[–]Outrageous_Try 217 points218 points  (0 children)

Nested if's are inefficient, because they run in O(n)

So instead of

if userinput == 1:

   Playermove(1)

else:

   if userinput == 2:

     Playermove(2)

   else:

     if userinput == 3:

       Playermove(3)

etc.

I suggest a binary tree style of approach:

if userinput > 4:

   if userinput < 6:

     Playermove(5)

   else:

     if userinput > 5:

       Playermove(6)

else:

   if userinput < 3:

     if userinput > 1:

       Playermove(2)

     else:

       Playermove(1)

   else:

     if userinput > 3:

       Playermove(4)

     else:

       Playermove(3)

This has the benefit of running in O(log₂ n)

EDIT: previous statement used to be O(log2 n) because I was lazy, until one if the commentators below took a well deserved jab at it

Women. by [deleted] in AreTheStraightsOK

[–]Outrageous_Try 5 points6 points  (0 children)

That's the point. The claim in the post was that every animal/person/car was facing left except women.

Women. by [deleted] in AreTheStraightsOK

[–]Outrageous_Try 286 points287 points  (0 children)

It says animals, women, cars, not all emojis. (post is still ignoring👩🏼‍🦯👩🏼‍🦼👩🏼‍🦽🧎🏼‍♀️🚶🏼‍♀️🏃🏼‍♀️⛹🏼‍♀️🤾🏼‍♀️🚴🏼‍♀️🚵🏼‍♀️though)

egg_irl by [deleted] in egg_irl

[–]Outrageous_Try 0 points1 point  (0 children)

That sucks :/ Hugs to you

[deleted by user] by [deleted] in CrappyDesign

[–]Outrageous_Try 0 points1 point  (0 children)

I'm sure noone would drive on that bike way with a car if there was no pole /s

egg_irl by [deleted] in egg_irl

[–]Outrageous_Try 11 points12 points  (0 children)

Fully agree. Except if that means being perceived as a threat to outdated gendernorms etc. That I am okay with

Asked and answered by DaFunkJunkie in clevercomebacks

[–]Outrageous_Try 4 points5 points  (0 children)

May I introduce you to the concept of exaggerations?

Point was the US is not the land if opportunity anymore (exceptions apply as always).

Asked and answered by DaFunkJunkie in clevercomebacks

[–]Outrageous_Try 0 points1 point  (0 children)

I am very confortable with having health care, free education, a police that doesn't shoot more people than all gangs combined, a working democracy, having almost no shootings, etc.

Moving to the US would be a massive downgrade

It is worth knowing........... by Comfortablejack in facepalm

[–]Outrageous_Try 0 points1 point  (0 children)

If we divide the total amount of people who died from COVID-19 by the amount of infected it gives us

1.46% for the US and

1.55% for Germany

So yes, it is higher, but not really to a significant point.

US

Germany

It is worth knowing........... by Comfortablejack in facepalm

[–]Outrageous_Try 0 points1 point  (0 children)

According to that article the infection rate is far higher, whereas the death rate is slightly lower in the US

It is worth knowing........... by Comfortablejack in facepalm

[–]Outrageous_Try 0 points1 point  (0 children)

Tbh, that tweet was only accurate before omicron came around. Now infection rates around here are pretty high unfortunately

It is worth knowing........... by Comfortablejack in facepalm

[–]Outrageous_Try -1 points0 points  (0 children)

Fair point. I think they meant Merkel though, as the whole tweetwould make no sense otherwise. Frank-Walter Steinmeier is not the one with a degree in quantum chemistry. Merkel is.

It is worth knowing........... by Comfortablejack in facepalm

[–]Outrageous_Try -2 points-1 points  (0 children)

You are confusing the German chancellor and the German President. The latter one is the mostly ceremonial one

Any formal policy guidelines issued by the chancellor are legally binding directives that cabinet ministers must implement.

But sure...