this post was submitted on 15 Jul 2025
442 points (94.9% liked)

Programmer Humor

37270 readers
36 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
(page 2) 50 comments
sorted by: hot top controversial new old
[–] thann@lemmy.dbzer0.com 9 points 5 days ago

You could use a loop to subtract 2 from the number until it equals one or zero

[–] voodooattack@lemmy.world 7 points 5 days ago* (last edited 5 days ago)
bool isEven(int value) {
  return (int)(((double)value / 2.0) % 1.0) * 100) != 50;
} 
[–] TankieTanuki@hexbear.net 9 points 5 days ago

No need to reinvent the wheel. Use the isEven API!

[–] elvith@feddit.org 9 points 5 days ago* (last edited 5 days ago)
assert IsEven(-2);
[–] RustyNova@lemmy.world 8 points 5 days ago (2 children)
load more comments (2 replies)
[–] xorollo@leminal.space 5 points 5 days ago

This joke was not written by the dude pictured. The author wrote a book of funny code jokes.

[–] AlyxMS@hexbear.net 7 points 5 days ago (2 children)

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

load more comments (2 replies)
[–] keepcarrot@hexbear.net 3 points 4 days ago

I want to assess coders by lines written! The more the better!

[–] ClathrateG@hexbear.net 7 points 5 days ago* (last edited 5 days ago) (1 children)

apart from everything else, have they never heard of a switch statement

[–] roux@hexbear.net 8 points 5 days ago

Switch statements is the next lesson in this bootcamp.

[–] helvetpuli@sopuli.xyz 2 points 4 days ago

Oh. I thought that was Elixir until I zoomed in.

[–] FireIced@lemmy.super.ynh.fr 5 points 5 days ago

that's some good code right there

[–] last_philosopher@lemmy.world 4 points 5 days ago (1 children)

To be fair, the question is "Write a function that simultaneously determines if the number is even and works as a timer"

[–] JackbyDev@programming.dev 3 points 5 days ago

sleepSort meets sleepIsEven

[–] ferric_carcinization@lemmy.ml 4 points 5 days ago (2 children)

I hope that the language's ints are at most 32 bits. For 8 bits it could even be written by hand & the source code for a 32 bit version would only take up avg_line_len * 4GiB space for the source code of the function. But it might take a bit of time to compile a version that supports the full range of 64 or 128 bit ints.

[–] Patches@ttrpg.network 6 points 5 days ago* (last edited 5 days ago)

My mate, Paul, says all numbers after 700 repeat so we can stop there.

We just give them different names so you think they're going up.

[–] segfault11@hexbear.net 6 points 5 days ago

all you have to to is throw an exception if the number is bigger than 100, who even needs numbers that big anyways?

[–] Midnitte@beehaw.org 5 points 5 days ago

When did Thor become the dev for Yandere Simulator?

load more comments
view more: ‹ prev next ›