Ответсообщение недоступно
Задача G - WA на 3 тесте
class Rectangle:
def __init__(self, first, second):
self.x1 = min(first[0], second[0])
self.x2 = max(first[0], second[0])
self.y1 = max(first[1], second[1])
self.y2 = min(first[1], second[1])
def perimeter(self):
width, height = self.get_size()
return round(2 * (width + height), 2)
def area(self):
width, height = self.get_size()
return round(width * height, 2)
def get_pos(self):
return (round(self.x1, 2), round(self.y1, 2))
def get_size(self):
width = abs(self.x1 - self.x2)
height = abs(self.y1 - self.y2)
return (round(width, 2), round(height, 2))
def move(self, dx, dy):
self.x1 += dx
self.x2 += dx
self.y1 += dy
self.y2 += dy
def resize(self, width, height):
self.x2 = self.x1 + width
self.y2 = self.y1 - height
def turn(self):
width, height = self.get_size()
center_x = (self.x1 + self.x2) / 2
center_y = (self.y1 + self.y2) / 2
self.x1 = round(center_x - height / 2, 2)
self.y1 = round(center_y + width / 2, 2)
self.x2 = round(center_x + height / 2, 2)
self.y2 = round(center_y - width / 2, 2)
def scale(self, factor):
width, height = self.get_size()
center_x = (self.x1 + self.x2) / 2
center_y = (self.y1 + self.y2) / 2
self.x1 = round(center_x - (width / 2 * factor), 2)
self.y1 = round(center_y + (height / 2 * factor), 2)
self.x2 = round(center_x + (width / 2 * factor), 2)
self.y2 = round(center_y - (height / 2 * factor), 2)