2 points

Those companies that judge output by lines of code are asking for this

permalink
report
reply
2 points
*

Good solution! I think you should show the last 3 lines that makes it work tho. FIFY:

private bool IsEven(int number){
    if (number == 1) return false;
    else if (number == 2) return true;
    else if (number == 0) return true;
    else if (number == -1) return false;
    else return !IsEven(abs(number) - 1);
}
permalink
report
reply
2 points

Not sure why people still implement this themselves when there are APIs that will do it for you, like https://isevenapi.xyz/

permalink
report
reply
1 point
*
Deleted by creator
permalink
report
reply
1 point

I’ve actually seen this type of code produced by a human-being who was trying to write good code. It was one of the students in my introduction to programming class in university, we had to write a function that squared a number or something, and he had written hundreds of lines of if-statements. Sometimes you just use what you know to complete an assignment I guess 🤷

permalink
report
reply
1 point

Though I want to add this case for interview questions: “Write code that outputs every prime number smaller than 10.”

And if the candidate doesn’t do ‘print “2,3,5,7”;’, I will deduct points.

permalink
report
parent
reply
1 point

I did something similar for a programming competition once because I couldn’t remember the c64 basic function to return string length.

Once I got home I rewrote it properly because it bugged me so badly. LEN(string variable) was the command. Stupid!

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 3.3K

    Monthly active users

  • 1K

    Posts

  • 37K

    Comments