Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
m[i, j] == - m[j, i] solution in Clear category for Skew-symmetric Matrix by Ilis
def checkio(matrix):
n = len(matrix)
return all(matrix[i][j] == -matrix[j][i]
for i in range(n)
for j in range(i, n))
# These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
print("Example:")
print(checkio([
[0, 1, 2],
[-1, 0, 1],
[-2, -1, 0]]))
# exit(0)
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"
print("Coding complete? Click 'Check' to earn cool rewards!")
May 8, 2019
Comments: