What algorithm did Windows XP use to choose your initial user picture?
91–100 of 165 posts
Re: What algorithm did Windows XP use to choose your initial user picture?
#92Re: What algorithm did Windows XP use to choose your initial user picture?
#93Earlier quoted context omitted.
exactly. There is something wrong with the code snippet.
No there is not. First element is defacto winner, but you still have to loop through the rest with 1/n chance of being selected to fully give each element a chance of winner selection
pics[Math.random() * len(pics)]
... assuming that random() gives you a number from 0..1 - but that's why it feels "wrong".Re: What algorithm did Windows XP use to choose your initial user picture?
#94Re: What algorithm did Windows XP use to choose your initial user picture?
#95Why doesn't it return on the first match?
Because it would always return the first match in that case. You still need to see all of the items once. Imagine you have 2 items. First one has 100% chance to be selected. So it does. Then the second has 50% chance to be selected. If it isn’t you effectively chosen the first one and have 50/50 chance to return either. Now you add a third item. There is 50/50 chance of having either selected. And 1/3 chance of repla…
Re: What algorithm did Windows XP use to choose your initial user picture?
#96Re: What algorithm did Windows XP use to choose your initial user picture?
#97Re: What algorithm did Windows XP use to choose your initial user picture?
#98Honestly, I don't understand Microsoft. These guys solve the most mundane problems with most elegant solutions and with sound edge-case handling scenarios, then they destroy all the effort with subpar programming where it matters and with user hostile behavior where they can't botch it.
> // Assume everything in the dir is a vaild image file Yep.. And image files were, and continue to be, a huge exploit attack vector
However, I still remember Wine laughing at Windows for WMF exploit and end up being affected from the same exploit. Now, that was a good laugh.
Re: What algorithm did Windows XP use to choose your initial user picture?
#99Earlier quoted context omitted.
No there is not. First element is defacto winner, but you still have to loop through the rest with 1/n chance of being selected to fully give each element a chance of winner selection
Yeah I think the "wrong feeling" is just that this could, in theory, be O(1) with something like: pics[Math.random() * len(pics)] ... assuming that random() gives you a number from 0..1 - but that's why it feels "wrong".
Re: What algorithm did Windows XP use to choose your initial user picture?
#100Earlier quoted context omitted.
No there is not. First element is defacto winner, but you still have to loop through the rest with 1/n chance of being selected to fully give each element a chance of winner selection
Yeah I think the "wrong feeling" is just that this could, in theory, be O(1) with something like: pics[Math.random() * len(pics)] ... assuming that random() gives you a number from 0..1 - but that's why it feels "wrong".
The picture selection algorithm's kind of single-pass iterator usage might have been more performant back in the XP days, as it avoids possibly expensive operations.
Modern CPU/other optimizations might make a multi-pass approach more performant due to better memory locality or other factors.