Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
599 B
4
Indexable
Never
def get_hash(matrix):
    # Find a determiner of matrix 3x3
    det = matrix[0][0] * matrix[1][1] * matrix[2][2] + \
          matrix[0][1] * matrix[1][2] * matrix[2][0] + \
          matrix[0][2] * matrix[1][0] * matrix[2][1] - \
          matrix[0][2] * matrix[1][1] * matrix[2][0] - \
          matrix[0][1] * matrix[1][0] * matrix[2][2] - \
          matrix[0][0] * matrix[1][2] * matrix[2][1]
    h = det % 9
    return h

if __name__ == "__main__":
    matrix = []
    for i in range(3):
        row = list(map(int, input().split()))
        matrix.append(row)
    
    print(get_hash(matrix))
Leave a Comment