or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/us@3.2.x
tile.json

tessl/pypi-us

tessl install tessl/pypi-us@3.2.0

A package for easily working with US and state metadata

Agent Success

Agent success rate when using this tile

88%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.24x

Baseline

Agent success rate without this tile

71%

task.mdevals/scenario-2/

State Border Validator

Build a utility that validates whether two US states share a land border. The utility should provide both a validation function and a simple command-line interface.

Requirements

Create a Python module that implements the following functionality:

  1. Define a data structure that maps each US state to its bordering states (states that share a land border)

    • Use state postal abbreviations (e.g., "MD", "VA", "PA") as identifiers
    • Include all 50 US states in the mapping
    • Exclude territories and obsolete entities
  2. Implement a shares_border(state1, state2) function that:

    • Accepts two state abbreviations as input
    • Returns True if the states share a land border, False otherwise
    • Returns False if either state abbreviation is invalid
    • Is case-insensitive (handles both "md" and "MD")
  3. Create a simple command-line interface:

    • Accept two state abbreviations as command-line arguments
    • Print "Yes" if the states share a border
    • Print "No" if they don't share a border
    • Print an error message if invalid abbreviations are provided

Implementation Notes

  • Your border mapping should accurately reflect US geography
  • Consider edge cases like Alaska and Hawaii (island states with no land borders)
  • The solution should handle uppercase and lowercase abbreviations

Dependencies { .dependencies }

us { .dependency }

A Python library for working with US state and territory metadata.

Test Cases

Test: Adjacent states return True { .test_case @test }

File: test_border_validator.py

from border_validator import shares_border

def test_adjacent_states():
    assert shares_border("MD", "VA") == True
    assert shares_border("CA", "OR") == True
    assert shares_border("TX", "LA") == True

Test: Non-adjacent states return False { .test_case @test }

File: test_border_validator.py

from border_validator import shares_border

def test_non_adjacent_states():
    assert shares_border("FL", "CA") == False
    assert shares_border("ME", "WA") == False

Test: Island states have no land borders { .test_case @test }

File: test_border_validator.py

from border_validator import shares_border

def test_island_states():
    assert shares_border("HI", "CA") == False
    assert shares_border("AK", "WA") == False

Test: Case insensitive handling { .test_case @test }

File: test_border_validator.py

from border_validator import shares_border

def test_case_insensitive():
    assert shares_border("md", "va") == True
    assert shares_border("Md", "Va") == True

Test: Invalid state codes return False { .test_case @test }

File: test_border_validator.py

from border_validator import shares_border

def test_invalid_codes():
    assert shares_border("XX", "YY") == False
    assert shares_border("CA", "ZZ") == False