this post was submitted on 04 Nov 2025
420 points (99.3% liked)

Programmer Humor

27193 readers
996 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] lugal@lemmy.dbzer0.com 13 points 14 hours ago (2 children)

Would this lead to problems if there are multiple identical and close by values? Like for example you have 100 elements each between 1 and 5

[–] rbn@sopuli.xyz 32 points 12 hours ago (2 children)

To reduce the chance of errors, you can multiply all numbers by a factor of 10, 100, 1000, 10000, .... for the timeout. The higher the factor, the lower the chances of an incorrect result. And as no one asked about performance...

[–] BlueKey@fedia.io 2 points 3 hours ago

Maybe not peak performance but heigh CPU efficency, it's load ist mostly 0.

[–] filcuk@lemmy.zip 33 points 12 hours ago (1 children)

As added benefit, you can then opyimise the code by dividing the number by 2, making it twice as fast. Think of the savings!

[–] lugal@lemmy.dbzer0.com 4 points 6 hours ago

Better yet: take the square root and you get a sub-linear run time