Question: Using python, Imagine that the user specifies with width and height of a grid. You will return a string that represents all ordered tiles that
Using python, Imagine that the user specifies with width and height of a grid. You will return a string that represents all ordered tiles that make up the corners of the grid, with three tiles to a corner. You will return a string where each tile has a space after it (this will simplify your algorithm). For example, on a 7x10 grid,
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 14 | |||||
| 15 | ||||||
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | ||||||
| 36 | ||||||
| 43 | ||||||
| 50 | ||||||
| 57 | 63 | |||||
| 64 | 65 | 66 | 67 | 68 | 69 | 70 |
you would return the string "1 2 6 7 8 14 57 63 64 65 69 70 ". If the board doesn't have a width or height of at least four, you should return the tiles of all the edges. Under such cases, you want to avoid putting duplicate tiles in your strings; to do this, use the python in boolean expression: "12" in "11 12 13 " would return True, while "10" in "11 12 13 " would return False. You may use the following formulas in your solution as needed: row = (tile - 1) // width Remember that you can check if a string is not in another string with something like "2" not in "1 2 3 " (which would return False).
Template:
def getCorner(width, height): width = width height = height #YOUR CODE GOES HERE (indented) return "fixme" #END YOUR CODE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
