Distinguish Permit Requirement Outcomes
Distinguish Permit Requirement Outcomes
Your platform determines whether construction projects require permits in different municipalities. The current system records conditions under which a permit is required. If no required condition matches, it returns NotRequired, which is ambiguous. It could mean either that the team has confirmed no permit is required, or that the team has not yet researched the municipality/scope combination.
Modify the model so that is_permit_required_for_scopes(project_scopes) can distinguish between three outcomes:
- A permit is required.
- A permit is known not to be required.
- The permit requirement is unknown or not yet researched.
Starter code is provided for Scope, Condition, PermitRequiredStatus, and Municipality classes.
Requirements:
- Extend
PermitRequiredStatusto include anUnknownvalue. - Add a method to record conditions where a permit is known not to be required, such as
add_permit_not_required_condition. - A required condition matches when all scopes in that condition are present in the
project_scopes. If any required condition matches, returnRequired. - After checking required conditions, check known not-required conditions. A project returns
NotRequiredonly if allproject_scopesare covered by one researched not-required condition.- Example: If New York City has recorded that
[fence_installation]does not require a permit, then a project with onlyfence_installationreturnsNotRequired. - A project with
[fence_installation, hvac_replacement]should not returnNotRequiredunless that combined set of scopes, or a condition covering both scopes, has been researched as not requiring a permit.
- Example: If New York City has recorded that
- If no required condition matches and no known not-required condition covers the
project_scopes, returnUnknown. - If conflicting required and not-required data exists,
Requiredshould take precedence. - Add meaningful tests for required, known-not-required, unknown, mixed-scope, and conflict-precedence cases.
- Assume
Scopeobjects compare correctly by name, or implement equality by name if needed.
Similar LeetCode problem: Scope and Sequence Length Difference
AI interview prep
Core dilemma
Effectively representing and querying complex, multi-scope conditions for permit requirements while handling ambiguity and precedence.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Distinguish Permit Requirement Outcomes
Distinguish Permit Requirement Outcomes
Your platform determines whether construction projects require permits in different municipalities. The current system records conditions under which a permit is required. If no required condition matches, it returns NotRequired, which is ambiguous. It could mean either that the team has confirmed no permit is required, or that the team has not yet researched the municipality/scope combination.
Modify the model so that is_permit_required_for_scopes(project_scopes) can distinguish between three outcomes:
- A permit is required.
- A permit is known not to be required.
- The permit requirement is unknown or not yet researched.
Starter code is provided for Scope, Condition, PermitRequiredStatus, and Municipality classes.
Requirements:
- Extend
PermitRequiredStatusto include anUnknownvalue. - Add a method to record conditions where a permit is known not to be required, such as
add_permit_not_required_condition. - A required condition matches when all scopes in that condition are present in the
project_scopes. If any required condition matches, returnRequired. - After checking required conditions, check known not-required conditions. A project returns
NotRequiredonly if allproject_scopesare covered by one researched not-required condition.- Example: If New York City has recorded that
[fence_installation]does not require a permit, then a project with onlyfence_installationreturnsNotRequired. - A project with
[fence_installation, hvac_replacement]should not returnNotRequiredunless that combined set of scopes, or a condition covering both scopes, has been researched as not requiring a permit.
- Example: If New York City has recorded that
- If no required condition matches and no known not-required condition covers the
project_scopes, returnUnknown. - If conflicting required and not-required data exists,
Requiredshould take precedence. - Add meaningful tests for required, known-not-required, unknown, mixed-scope, and conflict-precedence cases.
- Assume
Scopeobjects compare correctly by name, or implement equality by name if needed.
Similar LeetCode problem: Scope and Sequence Length Difference