76
submitted 5 days ago by m_f@midwest.social to c/loops@midwest.social
you are viewing a single comment's thread
view the rest of the comments
[-] PhilipTheBucket@ponder.cat 7 points 5 days ago

It's really just not a good solution. It's more complex, it's way slower, it shows they're not familiar with stuff they really should be familiar with.

Anyone who struggles to write a function to determine evenness of a number, and has to throw in some crazy solution to be able to make it across the finish line, is going to really struggle with real production code. They're going to produce stuff that's going to make everyone's job a lot more difficult.

return (x % 2) == 0;
return (x & 1) == 0;
return (x / 2 * 2) == x;
return x/2 == (x+1) / 2;

You can come up with unusual solutions and it can be fine. You can't come up with cockamamie solutions, that's why you're doing the test.

this post was submitted on 21 Dec 2024
76 points (100.0% liked)

Fun Loops ▶️

308 readers
179 users here now

Posting interesting/cool/funny videos from Loops here

https://loops.video/

Thanks to @Bluefruit @lemmy.world for the icon and banner!

Discussion of and questions about Loops should go over in !loops@lemmy.world

If the loop you're posting isn't original content uploaded by the creator, prefix the title with [R] for "reposted". For example, [R] Cute dog.

Rules:

  1. Don't be a dick
  2. Don't make me add more rules

founded 1 month ago
MODERATORS