Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First Skew-symmetric Matrix solution in 3rd party category for Skew-symmetric Matrix by Takafumi_Yamanobe
import numpy as np
def checkio(matrix):
matrix_n = np.array(matrix)
tr = matrix_n.T
#print(tr)
delta_tr = tr + matrix_n
#print(delta_tr)
sum_tr = np.count_nonzero(delta_tr)
#print(sum_tr)
if sum_tr == 0:
return True
else:
return False
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio([
[0, 1, 2],
[-1, 0, 1],
[-2, -1, 0]]) == True, "1st example"
assert checkio([
[0, 1, 2],
[-1, 1, 1],
[-2, -1, 0]]) == False, "2nd example"
assert checkio([
[0, 1, 2],
[-1, 0, 1],
[-3, -1, 0]]) == False, "3rd example"
assert checkio([
[-8, 5, -1, 7, 0],
[-5, -5, -7, -6, 8],
[1, 7, 1, 3, 4],
[-7, 6, -3, 5, -4],
[0, -8, -4, 4, 7]]) == False, "4th example"
print("Coding complete? Let's try tests!")
Dec. 11, 2018
Comments: