Advertisement
Charmander

corners

Sep 28th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. def getCorner(width, height):
  2.     width = width
  3.     height = height
  4.    
  5.     #YOUR CODE GOES HERE (indented)
  6.     #define corners
  7.     cor2 = 2
  8.     cor3 = width - 1
  9.     cor4 = width
  10.     cor5 = width + 1
  11.     cor6 = width * 2
  12.     cor7 = width * (height - 2) + 1
  13.     cor8 = width * (height - 1)
  14.     cor9 = width * (height - 1) + 1
  15.     cor10 = width * (height - 1) + 2
  16.     cor11 = width * height - 1
  17.     cor12 = width * height
  18.    
  19.     #compile string
  20.     corners = "1"
  21.     if width > 1:
  22.         corners = corners + " " + "2"
  23.     if width > 3:
  24.         corners = corners + " " + str(cor3)
  25.     if str(cor4) not in corners:
  26.         corners = corners + " " + str(cor4)
  27.     if height > 1:
  28.         corners = corners + " " + str(cor5)
  29.     if height > 2:
  30.         if str(cor6) not in corners:
  31.             corners = corners + " " + str(cor6)
  32.     if height > 2:
  33.         if str(cor7) not in corners:
  34.             corners = corners + " " + str(cor7)
  35.         if str(cor8) not in corners:
  36.             corners = corners + " " + str(cor8)
  37.     if str(cor9) not in corners:
  38.         corners = corners + " " + str(cor9)
  39.     if width > 1:
  40.         if str(cor10) not in corners:
  41.             corners = corners + " " + str(cor10)
  42.     if width > 2:
  43.         if str(cor11) not in corners:
  44.             corners = corners + " " + str(cor11)
  45.     if str(cor12) not in corners:
  46.         corners = corners + " " + str(cor12)
  47.     return corners
  48.     #END YOUR CODE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement