This code would run a lot faster as a hash table look up.
Programmer Humor
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
I agree. Just need a table of even numbers. Oh and a table of odd numbers, of course, else you cant return the false.. duh.
In a Juliana tree, or a dictionary tree if you want. For speed.
You could use a loop to subtract 2 from the number until it equals one or zero
Or literally just look at its binary representation. If the least significant digit is a "1", it's odd, if "0", it's even. Or you can divide by 2 and check for a remainder.
Your method is just spending time grinding away CPU cycles for no reason.
No need to reinvent the wheel. Use the isEven API!
Can you imagine being a TA and having to grade somebody's hw and you get this first thing? lmao
no unit tests huh.
/s
bool isEven(int value) {
return (int)(((double)value / 2.0) % 1.0) * 100) != 50;
}
apart from everything else, have they never heard of a switch statement
Switch statements is the next lesson in this bootcamp.
What you do is use a for loop to generate a million lines for you, then paste it in. Writing it manually is moronic. You can easily make it support numbers above 1,000,000 too this way, talking about scalable
I am more amazed that he didn't stop at 10 and think "damn this is tiresome isn't there a one liner i could do?". I want to know how far he went. His stubbornness is amazing but also scary. I haven't seen this kind of code since back in school lol lol lol
Good if you are rated by an AI that pays for LOCs.
that's some good code right there
When did Thor become the dev for Yandere Simulator?
This joke was not written by the dude pictured. The author wrote a book of funny code jokes.