Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Define a function count _ type ( map _ data, map _ type ) : map _ data: A list of lists representing the data
Define a function counttypemapdata, maptype:
mapdata: A list of lists representing the data for a given map.
maptype: A string representing a map type TARCW or U
Return: An integer representing the number of times maptype occurs in mapdata.
Define a function classifymapmapdata:
mapdata: A list of lists representing the data for a given map.
Return: A map classification according to the following rules:
The string Suburban if the number of R cells is greater than of all cells.
The string Farmland if the number of A cells is greater than of all cells.
The string Conservation if the number of U cells plus the number of W cells is greater than of all cells.
The string City if the number of C cells is greater than of all cells and the number of U cells plus the number of A cells is between and of all cells inclusive
The string Mixed if none of the above criteria are met.
Hint use your counttype function coupled with the fact that the total cells in mapdata is given by mn
Define a function isolatetypemapdata, maptype:
mapdata: A list of lists representing the data for a given map.
maptype: A string representing a map type TARCW or U
Return: A new list of lists that represent mapdata as a matrix but all entries that are not equal to maptype are replaced with a string containing only a space
Hint review the InLab Notebook Nested Loops to Process Lists of Lists demo on how to process D lists
Define a function commerciallybuildablemapdata, i j:
mapdata: A list of lists representing the data for a given map.
i: An integer representing a given row in mapdata.
j: An integer representing a given column in mapdata.
Return: True if mapdataij Aij is commercially buildable, otherwise False, according to the following rules from our background information:
First, ensure that the entry Aij is not at the edge of the map the first and last rows and columns If it is return False. Hint you will need to find the amount of rows and columns in the map for this step
Ensure that the entry Aij has map type U otherwise return False.
Ensure the entry Aij is not adjacent with an entry of map type R or map type A Note that adjacent entries are entries to the top, bottom, left, and right of the current cell. Hint review the additional information section for this step
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started