def solve(self, cipher):
        """
        main solution function
        :param cipher: the cipher
        """
        N, K, lst = cipher
        for i in xrange(len(lst)):
            if K <= 0:
                break
            maxa, idx = -1, 0
            for j in xrange(i, len(lst)):
                if lst[j] > maxa:
                    maxa = lst[j]
                    idx = j
            if idx != i:
                K -= 1
                lst[idx], lst[i] = lst[i], lst[idx]

        return " ".join(map(str, lst))
dataset/ETHPy150Open algorhythms/HackerRankAlgorithms/Largest Permutation.py/Solution.solve/original