| bio | website | |
|---|---|---|
| location | Moscow, Russia | |
| age | 33 | |
| visits | member for | 2 years, 4 months |
| seen | May 8 at 9:13 | |
| stats | profile views | 14 |
|
Jan 14 |
awarded | Yearling |
|
Oct 13 |
awarded | Nice Answer |
|
May 31 |
comment |
Return random `list` item by its `weight` @Benjamin Kloster Yes, but any other algorithm still has to calculate weight before "caching", so it doesn't improve efficiency at all. Except for binary search, I guess, when averaged over many picks from the same list... in this case, you have a point (-8 |
|
May 30 |
awarded | Commentator |
|
May 30 |
comment |
Return random `list` item by its `weight` @Benjamin Kloster The same would happen with any other code that doesn't cache weights. Except, I guess, a method that returns several random weighted elements in a single pass - which is perfectly possible. |
|
May 29 |
comment |
Return random `list` item by its `weight` @Benjamin Kloster My code only calls weight function once per element - you can't do any better than that. You're right about random numbers, though. |
|
May 29 |
comment |
Return random `list` item by its `weight` What you claim to be "more readable version" of my code is actually not. Your code needs to know total sum of weights, and cumulative sums, in advance; mine doesn't. |
|
May 29 |
answered | Return random `list` item by its `weight` |
|
Apr 4 |
comment |
Is there any practical trick to remember the difference between big-endian and little-endian? Funny coincidence - I only stumbled on this link today, and it's surprisingly relevant commandcenter.blogspot.com/2012/04/byte-order-fallacy.html |
|
Jan 14 |
awarded | Yearling |
|
Nov 28 |
answered | Developing a feature which sole purpose to be taken out? |
|
Jun 6 |
comment |
Why we should build with the highest warning level in .NET? Personally, I enable all warnings AND set "Treat warnings as errors" in VS. And I have Resharper too. Most of the time, warnings are actually errors or sloppy code that needs to be fixed. This setup doesn't allow me to skip fixing. |
|
May 10 |
comment |
isn't number localization just unnecessary? @JUST MY correct OPINION I hate this not as a programmer, but as a user. Some programs use l10n, some do not, and in the end the user is never sure whether to use comma or dot. |
|
May 10 |
comment |
isn't number localization just unnecessary? These examples are great, and I agree with you in principle... but in real life, I HATE HATE HATE number localization. Like when some overly smart program decides that I'm Russian and therefore should use commas as decimal separator, and I use dots (because I CAN'T use commas in programming, even in Russia), and then I have a bug that a spend a better part of a day fixing... I personally would rather prefer single standard, however non-intuitive it might seem to me at first. |
|
Apr 6 |
awarded | Scholar |
|
Apr 6 |
accepted | An event that raises itself - is it too complicated? |
|
Apr 6 |
awarded | Student |
|
Apr 6 |
asked | An event that raises itself - is it too complicated? |
|
Mar 6 |
answered | Why would one overload the && and & operator? |
|
Jan 29 |
awarded | Nice Answer |