Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

###I've been staring and manipulating this code too many times. Please assist me in fixing the code to use nested if statements or if-elif statements.

image text in transcribed

###I've been staring and manipulating this code too many times. Please assist me in fixing the code to use nested if statements or if-elif statements.

def getCorner(width, height, tile):

width = width

height = height

row = (tile1 -1) // width

result = '1'

if (row == 0):

if (column == 0) or (column == 1) or (column == width -2) or (column == width -1):

result = result + ', ' + ''

if (row == 1):

if (column == 0) or ( column == width -1):

result = result + ', ' + ''

if (row == h - 2):

if (column == 0) or (column == width -1):

result = result + ', ' + ''

else:

if (row == h -1):

if (column == 0) or (column == 1) or (column == width -2) or (column == width -1):

result = result + ', ' + ''

return result

return "fixme"

#END YOUR CODE

failed = False

ctr = 0

while ctr + 1

pieces = contents[ctr].split(" ")

if pieces[0] == "getCorners":

result = getCorner(int(pieces[1]), int(pieces[2]))

expected = contents[ctr+1].rstrip()

if (expected == str(result.rstrip())):

print "passed test"

else:

print "For input " + contents[ctr] + ", we expected '" + expected + "', but you got '" + str(result) + "'"

failed = True

ctr = ctr + 2

if not failed:

print "You passed all tests! Great work!"

result = subprocess.check_output

else:

print "At least one test case did not pass yet."

result = subprocess.check_output

Imagine that the user specifies with width and height of a grid. You will rea string that represents all ordered tiles that make up the corners of the grid, with thre tiles to a corner. You will retu after it (this will simplity your algorithm). For example, on a 7x10 grid, assming the tile numbers (starting at the top-left corner) are 1, 2, 3. . 70 a string where each tile has a space 57 63 64 65 69 70 you would retur the string" 2678 14 57 63 64 65 69 70" If the board doesn't have a width or height of at least four. you should retu the tiles of all the edges. Under such cases, you want to avoid putting duplicate tiles in you Strings You may use the following formulas in your algorithm as needed: row- (tile width col (tile - 1) % width

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Eric Redmond ,Jim Wilson

1st Edition

1934356921, 978-1934356920

More Books

Students also viewed these Databases questions

Question

3. An initial value (anchoring).

Answered: 1 week ago

Question

A list of biometric devices used in point of care technology

Answered: 1 week ago