this post was submitted on 31 Oct 2024
385 points (99.0% liked)

196

16774 readers
2311 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 83 points 2 months ago (2 children)

return true

is correct around half of the time

[–] [email protected] 19 points 2 months ago (1 children)
return Math.random() > 0.5

would also be correct about half the time

[–] [email protected] 1 points 2 months ago (1 children)

Wouldn't that only be correct about 25% of the time?

[–] [email protected] 0 points 2 months ago

for even, 50% chance of correctness, same for odd.

[–] [email protected] 42 points 2 months ago
assert IsEven(2) == True
assert IsEven(4) == True
assert IsEven(6) == True

All checks pass. LGTM