The constants are: COLUMN_ID = 0 COLUMN_NAME = 1 COLUMN_HIGHWAY = 2 COLUMN_LAT = 3 COLUMN_LON = 4 COLUMN_YEAR_BUILT = 5 COLUMN_LAST_MAJOR_REHAB = 6 COLUMN_LAST_MINOR_REHAB = 7 COLUMN_NUM_SPANS = 8 COLUMN_SPAN_DETAILS = 9 COLUMN_DECK_LENGTH = 10 COLUMN_LAST_INSPECTED = 11 COLUMN_BCI = 12 INDEX_BCI_YEARS = 0 INDEX_BCI_SCORES = 1 MISSING_BCI = -1.0 EARTH_RADIUS = 6371 This is an example of one of the bridges which is a list. def create_example_bridge_1() -> list: """Return a bridge in our list-format to use for doctest examples. This bridge is the same as the bridge from row three of the dataset. """ return [ 1, 'Highway 24 Underpass at Highway 403', '403', 43.167233, -80.275567, '1965', '2014', '2009', 4, [12.0, 19.0, 21.0, 12.0], 65.0, '04/13/2012', [['2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000'], [MISSING_BCI, 72.3, MISSING_BCI, 69.5, MISSING_BCI, 70.0, MISSING_BCI, 70.3, MISSING_BCI, 70.5, MISSING_BCI, 70.7, 72.9, MISSING_BCI]] ] def create_example_bridge_2() -> list: """Return a bridge in our list-format to use for doctest examples. This bridge is the same as the bridge from row four of the dataset. """ return [ 2, 'WEST STREET UNDERPASS', '403', 43.164531, -80.251582, '1963', '2014', '2007', 4, [12.2, 18.0, 18.0, 12.2], 61.0, '04/13/2012', [['2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000'], [MISSING_BCI, 71.5, MISSING_BCI, 68.1, MISSING_BCI, 69.0, MISSING_BCI, 69.4, MISSING_BCI, 69.4, MISSING_BCI, 70.3, 73.3, MISSING_BCI]] ] def create_example_bridge_3() -> list: """Return a bridge in our list-format to use for doctest examples. This bridge is the same as the bridge from row 33 of the dataset. """ return [ 3, 'STOKES RIVER BRIDGE', '6', 45.036739, -81.33579, '1958', '2013', '', 1, [16.0], 18.4, '08/28/2013', [['2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000'], [85.1, MISSING_BCI, 67.8, MISSING_BCI, 67.4, MISSING_BCI, 69.2, 70.0, 70.5, MISSING_BCI, 75.1, MISSING_BCI, 90.1, MISSING_BCI]] ] def create_example_bridges() -> List[list]: """Return a list containing three unique example bridges. The bridges contained in the list are from row 3, 4, and 33 of the dataset (in that order). """ return [ create_example_bridge_1(), create_example_bridge_2(), create_example_bridge_3() ] def find_worst_bci(bridges: List[list], bridge_ids: List[int]) -> int: """Return the bridge ID from bridge_ids of the bridge from bridges who has the lowest most recent BCI score. If there is a tie, return the bridge with the smaller bridge ID in the bridges. Precondition: - bridges contain the bridges with the ids in bridge_ids - every bridge in bridges has at least one BCI score - the IDs in bridge_ids appear in increasing order >>> example_bridges = create_example_bridges() >>> find_worst_bci(example_bridges, [1, 2]) 2 >>> find_worst_bci(example_bridges, [1, 3]) 1 """ def map_route(bridges: List[list], lat: float, lon: float, max_bridges: int, radius: int) -> List[int]: """Return the sequence of bridge IDs from bridges that must be visited by an inspector who initially starts at the location (lat, lon). The sequence must contain at most max_bridges IDs. Every ID in the sequence must be unique; an inspector cannot inspect the same bridge twice. The inspector visits the bridge within a radius of their location that has the lowest most recent BCI score. The next bridge inspected is the bridge with the lowest most recent BCI score within radius of the last bridge's location. This step repeats until max_bridges bridges have been inspected, or there are no bridges to inspect within radius. >>> example_bridges = create_example_bridges() >>> map_route(example_bridges, 43.10, -80.15, 3, 50) [2, 1] >>> map_route(example_bridges, 43.1, -80.5, 30, 10) [] """

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter11: Sql Server Databases
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question
100%

The constants are:

COLUMN_ID = 0
COLUMN_NAME = 1
COLUMN_HIGHWAY = 2
COLUMN_LAT = 3
COLUMN_LON = 4
COLUMN_YEAR_BUILT = 5
COLUMN_LAST_MAJOR_REHAB = 6
COLUMN_LAST_MINOR_REHAB = 7
COLUMN_NUM_SPANS = 8
COLUMN_SPAN_DETAILS = 9
COLUMN_DECK_LENGTH = 10
COLUMN_LAST_INSPECTED = 11
COLUMN_BCI = 12

INDEX_BCI_YEARS = 0
INDEX_BCI_SCORES = 1
MISSING_BCI = -1.0

EARTH_RADIUS = 6371

This is an example of one of the bridges which is a list.

def create_example_bridge_1() -> list:
"""Return a bridge in our list-format to use for doctest examples.

This bridge is the same as the bridge from row three of the dataset.
"""

return [
1, 'Highway 24 Underpass at Highway 403',
'403', 43.167233, -80.275567, '1965', '2014', '2009', 4,
[12.0, 19.0, 21.0, 12.0], 65.0, '04/13/2012',
[['2013', '2012', '2011', '2010', '2009', '2008', '2007',
'2006', '2005', '2004', '2003', '2002', '2001', '2000'],
[MISSING_BCI, 72.3, MISSING_BCI, 69.5, MISSING_BCI, 70.0, MISSING_BCI,
70.3, MISSING_BCI, 70.5, MISSING_BCI, 70.7, 72.9, MISSING_BCI]]
]


def create_example_bridge_2() -> list:
"""Return a bridge in our list-format to use for doctest examples.

This bridge is the same as the bridge from row four of the dataset.
"""

return [
2, 'WEST STREET UNDERPASS',
'403', 43.164531, -80.251582, '1963', '2014', '2007', 4,
[12.2, 18.0, 18.0, 12.2], 61.0, '04/13/2012',
[['2013', '2012', '2011', '2010', '2009', '2008', '2007',
'2006', '2005', '2004', '2003', '2002', '2001', '2000'],
[MISSING_BCI, 71.5, MISSING_BCI, 68.1, MISSING_BCI, 69.0, MISSING_BCI,
69.4, MISSING_BCI, 69.4, MISSING_BCI, 70.3, 73.3, MISSING_BCI]]
]


def create_example_bridge_3() -> list:
"""Return a bridge in our list-format to use for doctest examples.

This bridge is the same as the bridge from row 33 of the dataset.
"""

return [
3, 'STOKES RIVER BRIDGE', '6',
45.036739, -81.33579, '1958', '2013', '', 1,
[16.0], 18.4, '08/28/2013',
[['2013', '2012', '2011', '2010', '2009', '2008', '2007',
'2006', '2005', '2004', '2003', '2002', '2001', '2000'],
[85.1, MISSING_BCI, 67.8, MISSING_BCI, 67.4, MISSING_BCI, 69.2,
70.0, 70.5, MISSING_BCI, 75.1, MISSING_BCI, 90.1, MISSING_BCI]]
]


def create_example_bridges() -> List[list]:
"""Return a list containing three unique example bridges.

The bridges contained in the list are from row 3, 4, and 33 of the dataset
(in that order).
"""
return [
create_example_bridge_1(),
create_example_bridge_2(),
create_example_bridge_3()
]

def find_worst_bci(bridges: List[list], bridge_ids: List[int]) -> int:
"""Return the bridge ID from bridge_ids of the bridge from bridges who
has the lowest most recent BCI score.

If there is a tie, return the bridge with the smaller bridge ID in the bridges.

Precondition:
- bridges contain the bridges with the ids in bridge_ids
- every bridge in bridges has at least one BCI score
- the IDs in bridge_ids appear in increasing order

>>> example_bridges = create_example_bridges()
>>> find_worst_bci(example_bridges, [1, 2])
2
>>> find_worst_bci(example_bridges, [1, 3])
1
"""

def map_route(bridges: List[list], lat: float, lon: float,
max_bridges: int, radius: int) -> List[int]:
"""Return the sequence of bridge IDs from bridges that must be visited
by an inspector who initially starts at the location (lat, lon). The sequence
must contain at most max_bridges IDs. Every ID in the sequence must be
unique; an inspector cannot inspect the same bridge twice.

The inspector visits the bridge within a radius of their location that has
the lowest most recent BCI score. The next bridge inspected is the bridge
with the lowest most recent BCI score within radius of the last
bridge's location. This step repeats until max_bridges bridges have been
inspected, or there are no bridges to inspect within radius.

>>> example_bridges = create_example_bridges()
>>> map_route(example_bridges, 43.10, -80.15, 3, 50)
[2, 1]
>>> map_route(example_bridges, 43.1, -80.5, 30, 10)
[]
"""

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage