Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Kolejne (y) solution in Clear category for Skew-symmetric Matrix by wolicki.mikolaj
def checkio(matrix):
a=len(matrix)
spr=True
for i in range(a):
for j in range(a):
if(i==j):
if(matrix[i][j]!=0):
spr=False
return False
else:
if(matrix[i][j]==(-1)*matrix[j][i]):
spr=True
else:
spr=False
return False
return spr
#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"
Nov. 15, 2016