The kata's testing code incorrectly assumes that there is only 1 possible row/column/diagonal sum for every magic square of a certain size. In fact this is already untrue for 4x4 magic squares.
Its calculation is also flawed: adding a constant to all numbers will result in the "expected sum" to change by a different amount. Any minimum value other than 0 will cause the sum test to fail.
thanks
It can be worked around by adding
global.Test = require('@codewars/test-compat');
to user code.The kata's testing code incorrectly assumes that there is only 1 possible row/column/diagonal sum for every magic square of a certain size. In fact this is already untrue for
4x4
magic squares.Its calculation is also flawed: adding a constant to all numbers will result in the "expected sum" to change by a different amount. Any minimum value other than
0
will cause the sum test to fail.This kata cannot be solved:
Seems like it does not work... at least.. for valid 3x3 square i got response:
The sum in row 0 is incorrect.: expected 15 to equal 13.5
And also, please check your
verify
function, is it worked correctly? (it seems like it works when min number starts with zero)It might be:
var expectedSum = size*(minFound+(size*size-1)/2);
instead of:
var expectedSum = size*(minFound+(size*size-1))/2;
This comment is hidden because it contains spoiler information about the solution
0 is a debated natural number and can be a member of the natural number set depending on which set you are using. See here http://oeis.org/A000027.
However, I agree with you on the fact it should state that it is including 0 as a natural number.
This comment is hidden because it contains spoiler information about the solution