def solve(self, cipher):
        """
        Greedy approach

        Fixed #6 - #11 Wrong Answer due to Cost class
        :param cipher: the cipher
        """
        M, N, Y, X = cipher

        y = list(Y)
        x = list(X)

        y.sort()
        x.sort()
        cost = Cost()
        while x and y:
            x_max = x[-1]
            y_max = y[-1]
            if x_max > y_max:
                cost += x.pop() * (M - len(y))
            elif y_max > x_max:
                cost += y.pop() * (N - len(x))
            else:
                if sum(x) > sum(y):
                    cost += x.pop() * (M - len(y))
                else:
                    cost += y.pop() * (N - len(x))
        while x:
            cost += x.pop() * (M - len(y))
        while y:
            cost += y.pop() * (N - len(x))
        return cost.cost
dataset/ETHPy150Open algorhythms/HackerRankAlgorithms/Cutting boards.py/Solution.solve/original