# Untitled

unknown
python
a month ago
1.7 kB
2
Indexable
Never
```def RREF_Matrix(strArr):
rows = ",".join(strArr).split(",<>,")
matrix = []

for row in rows:
matrix.append([int(elem) for elem in row.split(",")])

def rref(matrix):
pivot = 0
for row_id in range(len(matrix)):
if pivot >= len(matrix[0]):
return
temp_row = row_id
while matrix[temp_row][pivot] == 0:
temp_row += 1
if temp_row == len(matrix):
temp_row = row_id
pivot += 1
if pivot == len(matrix[0]):
return
if temp_row != row_id:
matrix[temp_row], matrix[row_id] = matrix[row_id], matrix[temp_row]

divisor = matrix[row_id][pivot]
for elem_id in range(len(matrix[row_id])):
# Divide row matrix[row_id] by matrix[row_id][pivot]
matrix[row_id][elem_id] = matrix[row_id][elem_id] // divisor

for row_id_II in range(len(matrix)):
if row_id_II != row_id:
#  Subtract matrix[row_id_II][pivot] multiplied by row matrix[row_id] from row matrix[row_id_II]
factor = matrix[row_id_II][pivot]
for elem_id in range(len(matrix[row_id_II])):
matrix[row_id_II][elem_id] = matrix[row_id_II][elem_id] - \
matrix[row_id][elem_id]*factor
pivot += 1

rref(matrix)
return "".join("".join(map(str, elem)) for elem in matrix)

# Test the function
print(RREF_Matrix(["5", "7", "8", "<>", "1", "1", "2"]))  # Output should be "10301-1"
```