cm0002@lemmy.world to Programmer Humor@programming.dev · 18 hours agotimeoutSortlemmy.mlimagemessage-square26fedilinkarrow-up1375arrow-down12
arrow-up1373arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 18 hours agomessage-square26fedilink
minus-squarelugal@lemmy.dbzer0.comlinkfedilinkarrow-up12·9 hours agoWould 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
minus-squarerbn@sopuli.xyzlinkfedilinkarrow-up25·7 hours agoTo 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…
minus-squarefilcuk@lemmy.ziplinkfedilinkarrow-up25·7 hours agoAs added benefit, you can then opyimise the code by dividing the number by 2, making it twice as fast. Think of the savings!
minus-squarelugal@lemmy.dbzer0.comlinkfedilinkarrow-up2·57 minutes agoBetter yet: take the square root and you get a sub-linear run time
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
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…
As added benefit, you can then opyimise the code by dividing the number by 2, making it twice as fast. Think of the savings!
Better yet: take the square root and you get a sub-linear run time
Yes.