107 points
*

They call me a StackOverflow expert:

private bool isEven(int num) {
if (num == 0) return true;
if (num == 1) return false;
if (num < 0) return isEven(-1 * num);
return isEven(num - 2);
}
permalink
report
reply
35 points
bool isEven(int num) {
 return num == 0 || !isEven(num - (num > 0 ? 1 : -1));
}
permalink
report
parent
reply
8 points

Damn that’s some solid optimization.

permalink
report
parent
reply
17 points
*

StackoverflowException.

What do I do now?

Nvm. Got it.

  if(num % 2 == 0){
       int num1 = num/2
       int num2 = num/2
       return isEven(num1) && isEven(num2)   
  } 

if(num % 3 == 0){
      int num1 = num/3
      int num2 = num/3
      int num3 = num/3
      return isEven(num1) && isEven(num2) && isEven(num3) 
}

Obviously we need to check each part of the division to make sure if they are even or not. /s

permalink
report
parent
reply
5 points

Man I love how horrible this is!

permalink
report
parent
reply
3 points

…a recursive is-even

wow

permalink
report
parent
reply
87 points
*

I shit you not but one coworker I had dared call himself a data scientist and did something really similar to this but in Python and in production code. He should never have been hired. Coding in python was a requirement. I spent a good year sorting out through his spaghetti code and eventually rebuilt everything he had been working on because it was so bad that it only worked on his computer and he always pip freezes all requirements, and since he never used a virtual environment that meant we got a list of ALL packages he had installed on pip for a project. Out of those 100, only about 20 were relevant to the project.

permalink
report
reply
48 points

In prod??

Listen up folks. This is why we do code reviews. This right here.

permalink
report
parent
reply
16 points
*

Code reviews mean fuck all when the “senior” developer doing the review is someone who implements an entire API endpoint group in one single thousand-something lines magic function that is impossible to decipher for mere humans.

permalink
report
parent
reply
9 points
*

A few members of my team were reviewing codes but lots of PRs could be merged without tests or checks passing and only about 2 people before I joined understood what cicd is, no one else believed in its importance. They thought doing otherwise would “slow down the work precess and waste time, we know what we’re doing anyway!”.

I learned a lot from having to implement best practices and introduce tests in teams that don’t give a fuck or were never required to do it. I’m amazed at the industry standards and fully understand why job ads keep listing git as a requirement.

permalink
report
parent
reply
1 point

That’s something I would do

permalink
report
parent
reply
80 points
*

Just print True all the time. Half the time it will be correct and the client will be happy, and the other half the time, they will open a ticket that will be marked as duplicate and closed.

permalink
report
reply
24 points

Reminds me of the fake thermometers being sold during the peak of COVID that weren’t actually thermometers but just displayed numbers to make people think they were.

permalink
report
parent
reply
2 points

I definitely have one of these.

permalink
report
parent
reply
69 points
*

Wow. Amateur hour over here. There’s a much easier way to write this.

A case select:

select(number){
    case 1:
        return false;
    case 2:
        return true;
}

And so on.

permalink
report
reply
13 points
*

Don’t forget that you can have fall-through cases, so you can simplify it even further:

switch (number) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 9:
      ...
permalink
report
parent
reply

Teach me

permalink
report
parent
reply
46 points

Just do a while loop and subtract 2 if it’s positive or plus 2 is it’s negative until it reaches 1 or 0 and that’s how you know, easy! /s

permalink
report
reply
48 points

God, it’s so obvious, you can do it in only two lines of code.

if (number == 1 || number == 3 || number == 5 || number == 7 || number == 9...) return false;
else return true;
permalink
report
parent
reply
5 points

Obviously you couldn’t account for every number with only two lines.

permalink
report
parent
reply
8 points

Only if your line is not long enough…

permalink
report
parent
reply
8 points

Maybe you couldn’t

permalink
report
parent
reply

Lemmy Shitpost

!lemmyshitpost@lemmy.world

Create post

Welcome to Lemmy Shitpost. Here you can shitpost to your hearts content.

Anything and everything goes. Memes, Jokes, Vents and Banter. Though we still have to comply with lemmy.world instance rules. So behave!


Rules:

1. Be Respectful

Refrain from using harmful language pertaining to a protected characteristic: e.g. race, gender, sexuality, disability or religion.

Refrain from being argumentative when responding or commenting to posts/replies. Personal attacks are not welcome here.


2. No Illegal Content

Content that violates the law. Any post/comment found to be in breach of common law will be removed and given to the authorities if required.

That means:

-No promoting violence/threats against any individuals

-No CSA content or Revenge Porn

-No sharing private/personal information (Doxxing)


3. No Spam

Posting the same post, no matter the intent is against the rules.

-If you have posted content, please refrain from re-posting said content within this community.

-Do not spam posts with intent to harass, annoy, bully, advertise, scam or harm this community.

-No posting Scams/Advertisements/Phishing Links/IP Grabbers

-No Bots, Bots will be banned from the community.


4. No Porn/Explicit

Content


-Do not post explicit content. Lemmy.World is not the instance for NSFW content.

-Do not post Gore or Shock Content.


5. No Enciting Harassment,

Brigading, Doxxing or Witch Hunts


-Do not Brigade other Communities

-No calls to action against other communities/users within Lemmy or outside of Lemmy.

-No Witch Hunts against users/communities.

-No content that harasses members within or outside of the community.


6. NSFW should be behind NSFW tags.

-Content that is NSFW should be behind NSFW tags.

-Content that might be distressing should be kept behind NSFW tags.

If you see content that is a breach of the rules, please flag and report the comment and a moderator will take action where they can.


Also check out:

Partnered Communities:

1.Memes

2.Lemmy Review

3.Mildly Infuriating

4.Lemmy Be Wholesome

5.No Stupid Questions

6.You Should Know

7.Comedy Heaven

8.Credible Defense

9.Ten Forward

10.LinuxMemes (Linux themed memes)


Reach out to

All communities included on the sidebar are to be made in compliance with the instance rules. Striker

Community stats

  • 14K

    Monthly active users

  • 11K

    Posts

  • 256K

    Comments