Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Skew-symmetric Matrix by BartoszKowalski
def checkio(matrix):
a = 0
b = 0
for w in matrix:
a += 1
for k in w:
b += 1
if a==b:
if k!=0:
return False
x=0
b = 0
for w in range(len(matrix[0])):
for k in range(len(matrix[0])):
if matrix[w][k]!=(-matrix[k][w]):
return False
return True
#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. 26, 2018