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 astynax84
# migrated from python 2.7
def checkio(matr):
'return whether the specified square matrix is skew-symmetric or not'
return [[-n for n in x] for x in zip(*matr)] == matr
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')
April 28, 2011
Comments: