What algorithm did Windows XP use to choose your initial user picture?

soheilpro 345 points 173 comments September 10, 2026
devblogs.microsoft.com · View on Hacker News

Discussion Highlights (20 comments)

jasonvorhe

A couple of screenshots would've been useful for the post-millennial generations that never got to see the "beauty" (cough) of XP.

bhaney

100 seems like a very unnecessarily low limit, even for the time

moritzwarhier

Some say the Admin account defaulted to a chessboard. I think it's true, but not sure if I'm just falling victim to false memories... help?

cgio

The times when people spent an extra brain cycle to avoid billions of second passes.

bombcar

Does it also check existing users so you don't match one?

mawadev

That is a case I only become aware of when I read blogs like this. Technically I could solve it the same way, but these days you have so many tasks on your desk, you don't think about the problem and implications at all and that awareness/discipline is drowned in the noise/unlearned over time. If someone only gave me 2 minutes for this, because they think it is very simple (as always), I'd have done a count of files of a specific pattern in the directory and then picked a random index, very naive and quick and dirty programming, no sampling at all, just to avoid discussions why it takes so long with people who don't want to hear it. This reminds me of when I did a lot of C#, Java, JS, Python in my life, filling maps of strings and objects until I started with zig and noticed how expensive and complicated strings and data structure allocations can be. It kind of blew my mind how much memory and computation we waste when we try to get stuff done as fast as possible because of budget/time constraints.

lyorig

Man, every post from Raymond Chen regarding Windows internals is like a little Xmas. I wonder whether he has to ask someone for permission before publishing this knowledge, though.

KellyCriterion

Why they made it that complex? A simple rand/mod based on first character of username should be sufficient?

EMIRELADERO

For those interested, here's the actual code Chen talks about: https://github.com/tongzx/nt5src/blob/daad8a087a4e75422ec96b...

impoppy

>Raymond has been involved in the evolution of Windows for more than 30 years. He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

ape4

It's somewhat odd that filesystems don't have a call to tell you how many files are in a folder.

dsego

Why doesn't it return on the first match?

Aditya_0315

What is amazing is the amount of consideration given to an issue which would escape the majority of users. It is surprising how complex an apparently easy process turns out when considering certain special cases.

frou_dh

I'm disappointed that it is not influenced by the username ... "You sound like a skateboard kinda person"

bayindirh

Honestly, 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.

scrumper

This is a fun example of the cognitive switch you have to employ when first starting to program a computer. It's extremely easy for a human to pick at random one thing from a pile of things: you reach out your hand and grab it, maybe swirling them around on the table first to shuffle the order. For a computer, there's no direct analogy to that. They just can't do it. And the human process is nothing even slightly like the one the computer follows: we don't have to count the sets and iterate over them, or count the items and then generate a random number to pick the nth item, or risk picking a null item.

ulrikrasmussen

But the naive way of doing this also wouldn't really require two passes, right? It would just require more memory because you would first save all file names in an array (stopping at 100), then pick a random one in constant time.

wky

A mentally simpler, though slightly biased algorithm is for each item, randomly generate a uint64 (arbitrary bit size) and switch to the new item if and only if the number generated is greater than or equal to all previously seen numbers. The end result is equivalent to randomly generating a number for each item and picking the item with the largest associated number.

rietta

I love the understated "some time ago" linking to a 2004 blog post. Raymond has been at this a long time :-)

ang_cire

My eyes glazed over when I saw "recursively", and I had to re-read the last couple paragraphs again to grok it, and it's very cool.

Semantic search powered by Rivestack pgvector
6,164 stories · 56,060 chunks indexed