409
submitted 2 months ago by sirico@feddit.uk to c/programmerhumor@lemmy.ml
(page 2) 50 comments
sorted by: hot top controversial new old
[-] 4am@lemmy.zip 6 points 2 months ago

Fucking rent free. Jesus Christ you clowns, I almost want them to take away all your video games now

load more comments (3 replies)
[-] Treczoks@lemmy.world 6 points 2 months ago

Good if you are rated by an AI that pays for LOCs.

[-] FireIced@lemmy.super.ynh.fr 5 points 2 months ago

that's some good code right there

[-] Midnitte@beehaw.org 5 points 2 months ago

When did Thor become the dev for Yandere Simulator?

[-] ICastFist@programming.dev 5 points 2 months ago

Oh shit, gotta check the negative numbers as well!

load more comments (1 replies)
[-] last_philosopher@lemmy.world 4 points 2 months ago

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 2 months ago

sleepSort meets sleepIsEven

[-] tulliandar@lemmy.world 4 points 2 months ago

Why is it all in italics?! I’d reject the PR just for that. Otherwise LGTM

[-] RustyNova@lemmy.world 4 points 2 months ago
load more comments (2 replies)
[-] ferric_carcinization@lemmy.ml 4 points 2 months ago

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 2 months ago* (last edited 2 months 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.

[-] Randomgal@lemmy.ca 3 points 2 months ago

Yeah but did you know he worked for Blizzard tho

[-] dsilverz@calckey.world 3 points 2 months ago

@sirico@feddit.uk

private bool isEven(int number){
    	bool result = true;
    	while (number > 0){
    		number = number - 1;
    		if (result == true)
    			result = false;
    		else
    			result = true;
    	}
    	return result;
    }

(P.S.: Only works for positive numbers)

[-] jaupsinluggies@feddit.uk 3 points 2 months ago

This works for both positive and negative numbers:

private static bool isEven(int number)
{
	bool result = true;

	while (number < 0)
	{
		number = number - 1;
		if (result == true)
			result = false;
		else
			result = true;
	}
	while (number > 0)
	{
		number = number - 1;
		if (result == true)
			result = false;
		else
			result = true;
	}
	return result;
}

Output:

isEven(4) = True
isEven(5) = False
isEven(-4) = True
isEven(-5) = False
load more comments
view more: ‹ prev next ›
this post was submitted on 15 Jul 2025
409 points (100.0% liked)

Programmer Humor

38657 readers
213 users here now

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

Rules:

founded 6 years ago
MODERATORS