Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Excellent kata, I enjoyed learning about determinants and solving this. Took me too long to realise I wasn't multiplying the sub determinant by the anchor for 4x4 + matrices.
You can technically do what you're trying to do without division; your intention is to cancel out numbers, and you can either do that by division as you're doing, or by multiplication (hint: maybe
std::lcm
can help?). Haven't tried it out, but you should probably be able to find an approach that works without float division.Don't think that way. You'll get quicker the more higher rank Katas you solve. The fact that you solved it now means you'll solve similar Katas much quicker. That's how it works for everyone; people program quickly when they've seen enough problems of that sort.
How long should it take to solve this Kata?
It took me 5 hours, is it too long?
When using a faster approach that requires working with floating point numbers, the results on large matrices are either off by 1, or miss completely. How can I fix that?
alternatively you could mod by 1e9 + 7. https://www.geeksforgeeks.org/modulo-1097-1000000007/
This comment is hidden because it contains spoiler information about the solution
Fun kata! But I have a question why in C# all kata seems to uses jagged arrays instead of multidimensional? (int[][] this instead of int[,]). I am genuinely curious because it seems to me more appropriate a multidimensional array in this case and in many others that I found... am I wrong?
Answered, closing.
I don't think so, except if my code and the tests are bugged the same way :)
this comment made my day
Thanks, you are right, my solution was incorrectly finding submatrix <3
Your main function is recursive, so what you print is not what tests pass to you - you print also intermediate matrices of your calculations, and the intermediate matrices become invalid at some point.
The bug is somewhere in your solution, I checked the tests and they do not create inputs with "holes". These come from your solution.
In JS after 8 normal tests I'm getting matrices like:
[ <1 empty item>, [ 4, -2, 5 ], [ 2, 8, 7 ] ] (expected result - 0)
[ [ 6, 1, 1 ], <1 empty item>, [ 2, 8, 7 ] ] (also 0)
[ [ 6, 1, 1 ], [ 4, -2, 5 ] ] (here expected result is.. -306)
Is it supposed to be so? In instructions: "Write a function that accepts a square matrix (N x N 2D array)"
Should probably make it clear that the matrix is being represented by row vectors (alternative would be column vector). One can assume that and infer that from the examples but it really is the kind of info that should be in the instructions.
Loading more items...