3 ms·
The "perfectly valid" assumption is also definitely invalid, even within the U.S. A few counterexamples in NYC: "Broadway," "The Bowery," "Avenue of the Americ
by timbre 13y ago
The "perfectly valid" assumption is also definitely invalid, even within the U.S. A few counterexamples in NYC: "Broadway," "The Bowery," "Avenue of the Americas." Boston has "The Fenway." Many rural addresses are in the style of "300 State Route 20."
- gumby 13y agoI don't know why carmel-by-the-sea's addressing is considered odd. It was a very common system until recently (well, within the last century) and is still common in many countries. My grandmother never gave up her name for her house even when the town assigned a street number in the 1970s, and mail came just fine. More importantly: street addressing was added to support the crude technology of the time (paper maps & phone books) -- with computers we should become MORE amenable to the vagaries and desires of humans rather than changing humans to fit the machines.
- Jemaclus 13y agoSo, I guess I should specify that the addresses in question are United States addresses. My company operates entirely within the US and does not deal with international addresses. In this regard, Carmel is very unusual within the US. But yes, you're right. :)
- Jemaclus 13y agoSure, there are always edge cases. There are cities with no street addresses (check out Carmel-by-the-sea for some craziness: http://en.wikipedia.org/wiki/Carmel-by-the-sea http://en.wikipedia.org/wiki/Carmel-by-the-sea). How do you parse an address when the address is "10th and Lincoln"? Or when you wind up with something like in rural Wisconsin where the address is "N323 W77532 County Road 120, Wherever, WI"? Or when you wind up with two cities that are different but the USPS, the residents, and Google/Bing consider them the same place, like Rockville and Potomac, MD? Don't even get me started on the Virgin Islands or Puerto Rico... But for the purposes of the interview question, there are "perfectly valid" assumptions that you can make to solve the task before you. I'm not asking you to solve the entire scope of the problem -- I've been working on this for over a year with varying degrees of commitment, and I assure you I have not solved the entire scope of the problem. I don't expect you to figure it out in 15 minutes. You can assume that there are 50 states (but that leaves out the Virgin Islands and Puerto Rico). You can assume that ZIP codes have 5 digits (but maybe someone provided all 9 digits, or maybe they left it off completely). You can assume that all streets end in a reasonable suffix (but that ignores post-directional suffixes or the examples you provided). However, by making assumptions, you can more quickly solve the problem in an interview context. As long as I understand the assumptions you're making, I can judge the quality of your output. It won't solve everything, but maybe it's better to parse 99% of addresses using one simpler algorithm and then handle the edge cases using a second (or third, or fourth, or fifth) algorithm.