Question
###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.
###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) % widthStep 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