fork download
  1. class WallPart(object):
  2. def __init__(self, x, y):
  3. self.x = x
  4. self.y = y
  5.  
  6. def returnMethod(self, other):
  7. if self.x <= other.y and self.x >= other.x and self.y > other.y:
  8. return 0 # "merge to back of other"
  9. elif self.y >= other.x and self.x < other.x and self.y <= other.y:
  10. return 1 # "merge to front of other"
  11. elif self.x <= other.y and self.y <= other.y:
  12. return 2 # "discard self"
  13. else:
  14. return 3 # do nothing, just insert
  15.  
  16. class Wall(object):
  17. def __init__(self, name='Main'):
  18. self.name = name
  19. self.parts = []
  20.  
  21. def addPart(self, part):
  22. self.parts.append(part)
  23.  
  24. # def methodAction(self, opcode):
  25.  
  26. def removePart(self, part):
  27. self.parts.remove(part)
  28.  
  29. def merge0(self, p1, p2):
  30. addPart(WallPart(p2.x, p1.y))
  31. removePart(p1)
  32. removePart(p2)
  33.  
  34. def merge1(self, p1, p2):
  35. addPart(WallPart(p1.x, p2.y))
  36. removePart(p1)
  37. removePart(p2)
  38.  
  39. def discard(self, p1, p2):
  40. removePart(p1)
  41.  
  42.  
  43. def checkio(required, operations):
  44. wall = Wall()
  45. wall.addPart(WallPart(operations[0][0], operations[0][1]))
  46. # for op in operations:
  47.  
  48.  
  49. return 1
  50.  
  51.  
  52. checkio(16, [[1, 5], [11, 15], [2, 14], [21, 25]])
  53.  
Success #stdin #stdout 0.02s 27704KB
stdin
Standard input is empty
stdout
Standard output is empty