Skip to content
Snippets Groups Projects
Select Git revision
  • 767916bc323915bb8a9aaf1f7a24075e64c94e2c
  • master default protected
2 results

find_duplicates_test.py

Blame
  • matrix_transpose.py 641 B
    class Matrix:
        """Interface of a matrix.
    
        This class provides only the matrix size N and a method for swapping
        two items. The actual storage of the matrix in memory is provided by
        subclasses in testing code.
        """
    
        def __init__(self, N):
            self.N = N
    
        def swap(self, i1, j1, i2, j2):
            """Swap elements (i1,j1) and (i2,j2)."""
    
            # Overridden in subclasses
            raise NotImplementedError
    
        def transpose(self):
            """Transpose the matrix."""
    
            # TODO: Implement more efficiently
            for i in range(self.N):
                for j in range(i):
                    self.swap(i, j, j, i)