Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Skew-symmetric Matrix by bryukh
def checkio(matr):
'return whether the specified square matrix is skew-symmetric or not'
for x in range(len(matr)):
for y in range(x, len(matr)):
if matr[x][y] != -matr[y][x]:
return False
return True
if __name__ == '__main__':
assert checkio([[0, 1,2],
[-1,0,1],
[-2,-1,0]]) == True, 'First'
assert checkio([[0, 1,2],
[-1,1,1],
[-2,-1,0]]) == False, 'Second'
assert checkio([[0, 1,2],
[-1,0,1],
[-3,-1,0]]) == False, 'Third'
print('All ok')
Nov. 3, 2012
Comments: