13 ms·
If I got that question in an interview, I would write a program that asks the user what their first name is. That's the only correct solution to that problem.
by paledot 6y ago
If I got that question in an interview, I would write a program that asks the user what their first name is. That's the only correct solution to that problem.
- Alex3917 6y agoThe fact that it’s unsolvable is what makes it a good interview problem. Seeing someone solve a problem with a correct solution doesn’t really tell you anything about the person or their thought process.
- csours 6y agohttps://news.ycombinator.com/item?id=24447182 https://news.ycombinator.com/item?id=24447182
- JadeNB 6y agoThis sounds like the analogue of "I would offer the barometer to the building manager if he tells me how tall the building is."
- paledot 6y agoOkay, but - "programmatically determine the users name" is one of the classic foibles of inexperienced programmers. It's not that it's a hard problem, it's an impossible problem that people shouldn't be attempting, yet somehow still do, not unlike validating an email address with regex.
- Alex3917 6y ago> it's an impossible problem that people shouldn't be attempting, yet somehow still do You see exactly this kind of probabilistic algorithm being used every day in huge production apps. E.g. how do you think Gmail shows something like "me .. Vince, Tim" in the left column of your email inbox?
- paledot 6y agoCorrectly 100% of the time, as long as all of your contacts have names that match "Firstname Lastname". Google Contacts has separate fields, which enables "Vince" but at the expense of assuming that his full name is "Vince Sato" when he may write it "Sato Vince". The problem with probabilistic algorithms is that you trade predictability for getting it right more frequently (but not 100% of the time). Eg. I could match common Japanese family names or look for a .jp TLD, but neither of these are guarantees that the family name comes first, and even less does their absence imply that they lead with the first name. I imagine Google's algorithm is no more sophisticated than: 1. Are they in your contacts? Use their first name from your contacts. 2. Are they a Google user with a profile you can view? Use the first name they provided. 3. Use your locale to make a wild guess.
- Alex3917 6y agoRight exactly, and that's basically the correct approach. But imho that's a super interesting problem.