To check if all rows of a matrix are circular rotations of each other, you can perform the following steps:
Here's a Python program implementing the above logic:
def are_rows_circular_rotations(matrix): # Convert the first row to string and double it doubled_row = ''.join(map(str, matrix[0])) * 2 # Check if all other rows are substrings of the doubled first row for row in matrix[1:]: row_str = ''.join(map(str, row)) if row_str not in doubled_row: return False return True # Example usage: matrix1 = [ [1, 2, 3], [3, 1, 2], [2, 3, 1] ] matrix2 = [ [1, 2, 3], [3, 1, 2], [2, 3, 4] ] print(are_rows_circular_rotations(matrix1)) # True print(are_rows_circular_rotations(matrix2)) # False
In the example above, matrix1 contains rows that are circular rotations of each other, so the function returns True. However, matrix2 has rows that aren't circular rotations of each other, so the function returns False.
src gradle-task nest jscript iso8583 cakephp-2.1 perl xdebug onedrive gulp-sass