• Wrong "solution" which passed all current tests...

Question related to mission Skew-symmetric Matrix

 

Hi there,

The code for my current solution to this problem is posted at:

http://www.checkio.org/mission/skew-symmetric-matrix/publications/aotus/python-3/first/

I was reasonably happy with this, until I saw the even more elegant solution by PositronicLlama.

In any case, my program works with all of the test cases that are currently attached to the problem. But a correct program should fail when the diagonal of the matrix has any non-zero elements. Mine will allow non-zero elements on the diagonal, provided that the elements SUM to zero. This is a mistake. I have a simple one-line correction that I will post.

In the mean time, I suggest that a test case be added to this problem which is almost skew-symmetric, but which has elements on the diagonal that meet the following criteria:

  1. they are not all zeros,
  2. they SUM to zero.

I used the pre-defined matrix generator on the Solve It page to generate a suitable example.

[[-8, 5,-1, 7, 0], [-5,-5,-7,-6, 8], [ 1, 7, 1, 3, 4], [-7, 6,-3, 5,-4], [ 0,-8,-4, 4, 7]]

This matrix should return False. My program returns True.

14