Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey all - I am in desperate need of help for solving the following prompt below and would really appreciate it if anyone has answers

Hey all - I am in desperate need of help for solving the following prompt below and would really appreciate it if anyone has answers to the question. I will make sure to reward anyone with insights!

A mining company conducts a survey of an n-by-n square grid of land. Each row of land is numbered from 0 to n-1 where 0 is the top and n-1 is the bottom, and each column is also numbered from 0 to n-1 where 0 is the left and n-1 is the right. The company wishes to record which squares of this grid contain mineral deposits.

The company decides to use a list of tuples to store the location of each deposit. The first item in each tuple is the row of the deposit. The second item is the column. The third item is a non-negative number representing the size of the deposit, in tons. For example, the following code defines a sample representation of a set of deposits in an 8-by-8 grid.

deposits = [(0, 4, .3), (6, 2, 3), (3, 7, 2.2), (5, 5, .5), (3, 5, .8), (7, 7, .3)]

6.1. Given a list of deposits like the one above, write a function to create a string representation for a rectangular sub-region of the land. Your function should take a list of deposits, then a set of parameters denoting the top, bottom, left, and right edges of the sub-grid. It should **return** (do not print in the function) a multi-line string in which grid squares without deposits are represented by "-" and grid squares with a deposit are represented by "X".

def display(deposits, top, bottom, left, right): """display a subgrid of the land, with rows starting at top and up to but not including bottom, and columns starting at left and up to but not including right."""

ans = #May replace ans with any code

return ans #Same thing with this statement. You may replace with whatever code

For example, your function should replicate the following behavior for the example grid:

print(display(deposits, 0, 8, 0, 8)) ----X--- -------- -------- -----X-X -------- -----X-- --X----- -------X print(display(deposits, 5, 8, 5, 8)) X-- --- --X

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Explore ways to correct or remove the major causes.

Answered: 1 week ago