-1

I was recently sent a code test by a potential employer to complete on my own time. The first question has to do with identifying whether a given zoning code falls within a range of codes. I'm not looking for the actual solution (someone else already tried that on SO) and I already declined to take the test since I was frustrated by this question as well as another one that was about screen scraping where the site in question was down for maintenance.

My question is just whether the "ranges" described are ambiguous or not. Is there some standard that clearly defines what is meant by "M1-1/R5 – M1-6/R10"? There is a hint for the first range that seems to suggest that this could be a self-contained question that doesn't require any domain-specific knowledge, except many of the test inputs, like C4-4A (no letters mentioned in the range with C codes), seem like they wouldn't be in any of the ranges until you research the zoning codes in New York and discover that they are actually valid, as shown in this document. Here is the original question:

Question 1 Description: Write a method which accepts a list/array of codes and returns the code along with its description as JSON. Note that the range for R1-1 - R10H encompasses R1-1 to R10-10 and R1A to R10H.

Bonus: Write a unit test.

Description Data:
Codes               Descriptions
---------------------------------------------------------------
R1-1 - R10H         General Residence Districts
C1-6 - C8-4         Commercial Districts
M1-1 - M3-2         Manufacturing Districts
M1-1/R5 – M1-6/R10  Mixed Manufacturing & Residential Districts
BPC                 Battery Park City
PARK                New York City Parks
PARKNYS             New York State Parks
PARKUS              United States Parks
ZNA                 Zoning Not Applicable
ZR 11-151           Special Zoning District

Example output:
Given ['M3', 'R3-2', 'PARKNYS', 'M1-3/R9']
{
    "codes":[
        {"code":"M3", "description”:”Not found“},
        {"code":"R3-2", "description":"Residential Districts"},
        {"code":"PARKNYS", "description":"New York State Parks"},
        {"code":"M1-3/R9", "description":"Mixed Manufacturing & Residential Districts"}
    ]
}

Input:
The list is:
    R7A
    R8A
    C4-4A
    M3-2
    R8B
    C1-6A
    R7B
    R8X
    C1-7A
    PARK
    C1-9A
    R6
    C1-7
    C2-6
    R10
    C4-5
    C6-3X
    C1-6
    C6-2M
    C6-4M
    M2-4
    M1-5/R7X

UPDATE: The answer from MichaelT makes some good points, but I disagree that the hint in the first question gives you the complete list of zoning codes. It only does so for the first range.

closed as off-topic by durron597, GlenH7, Ixrec, enderland, user22815 Jun 19 '15 at 18:00

  • This question does not appear to be about software engineering within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • From the description in your doc C1-6 - C8-4 I agree that I wouldn't assume C4-4A to be "in that range". Maybe they put in this kind of unclear thing in the explanation to see how you handle this kind of issue. Do you ignore it; do you ask for clarification; do you search for random docs on the internet to try and find out if its valid!?? – Brandin Mar 15 '15 at 21:55
  • It seems to be just some greedy (prefix) string pattern matching. – rwong Mar 15 '15 at 22:03
  • 5
    I'm voting to close this question as off-topic because it is about zoning codes, not about programming. – durron597 Jun 18 '15 at 14:32
  • @durron597 I was not really asking about zoning codes but whether such ranges have an agreed-upon meaning regardless of the context or whether it is more of a domain-specific question. Ranges are definitely an important concept in programming for things like array indexes, IP addresses, and many other applications. That said, I'm OK with it being closed. Just wanted to clarify. – regularmike Jun 18 '15 at 18:26
5

The description of the range is poor. However, there is a clearly defined in the zoning codes.

From section 11-122 of Zoning Resolution (Web Version) (the linked pdf)

R1-1   Single-Family Detached Residence District
R1-2   Single-Family Detached Residence District
R1-2A   Single-Family Detached Residence District

R2     Single-Family Detached Residence District
R2A    Single-Family Detached Residence District
R2X    Single-Family Detached Residence District

...

R9     General Residence District
R9-1   General Residence District
R9A    General Residence District
R9D    General Residence District
R9X    General Residence District

R10    General Residence District
R10A   General Residence District
R10H   General Residence District
R10X   General Residence District

Thus, R1-1 - R10H is intended to convey this range.

Lets face it, often in the real world business logic is poorly defined. Summaries of the logic are even worse. It is the responsibility of the programmer to seek clarity on the poorly defined requirements. In this case, that is done by looking at the associated comment which gives you the complete list of the acceptable zoning codes.

At this point, you could stick every zoning code into a dictionary and not worry about ranges at all if you wanted to (I'd read the dictionary from an associated data file, but thats just me). Thats probably best as there isn't a range for these. Any regex to try to match just those described would be hopelessly complex.

It should be perfectly acceptable to return an error when someone passes the information R9-2 since that isn't a valid zoning code. But that's my take on the requirements.

When in doubt what the requirements are, clarify the requirements. Don't guess about requirements - you can often find yourself coding for a period of time just to find out you misunderstood them on day 1 and have been going down the wrong path.

Yes, this is apparently part of a job interview test. Remember that programming isn't just writing code, its also gathering requirements (and many other things).

  • I agree that in the context of the Zoning Resolution document, R1-1 - R10H is well-defined. However, the mixed range M1-1/R5 – M1-6/R10 might be open to interpretation. M1-1/R1 doesn't seem to belong, but what about M1-2/R1? In any case, if we're going by the document, which means regex is too complicated, then the alternative (dictionary lookup) just seems like a pointless exercise for a coding test. – regularmike Mar 15 '15 at 22:54
  • Also, I did tell the HR person who gave me the test that although I appreciated that the question involved their actual domain (they deal with real estate) I found the ranges in the first question confusing. I thought that might prompt her to invite me to ask questions, but she ignored my comment. – regularmike Mar 15 '15 at 23:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.