May-09-2019, 09:12 AM
(This post was last modified: May-09-2019, 09:19 AM by Gribouillis.)
Add this method to the square class. Then normalize the produced squares and remove repetitions
def normalize(self): if self.mat[0][0] > self.mat[2][2]: self.mat = [row[::-1] for row in self.mat[::-1]] if self.mat[2][0] > self.mat[0][2]: self.mat = [list(row) for row in zip(*self.mat)] if self.mat[0][0] > self.mat[2][0]: self.mat = self.mat[::-1]alternately, you can use
def is_magic_and_cool(self): return (self.is_magic() and self.mat[0][0] < min(self.mat[2][0], self.mat[2][2]) and self.mat[2][0] < self.mat[0][2])and generate only magic and cool squares.