Hello there, yep, I did a code similar to yours, and I got the same results, I thought that I was right but in reality I didn't understand what the kata was asking for.
Instead of going this way:
Matrix[0][0], Matrix[0][1], Matrix[0][2] .... ....
Go with:
Matrix[1][0], Matrix[2][0] .... and so on💁🏽♂️
The
power++
logic in your code fails because it will only work for odd-length arrays (like 3x3 or 5x5 etc.)For the case of 3x3:
While, the case for even-sized arrays are (Using 4x4 as an example):
is obviously wrong!
Thanks for the help! I will try this :) Yes the image was pretty clear. Great.
Actually, I think that the image explain more than the example🤣🤣🤦🏽♂️
Hello there, yep, I did a code similar to yours, and I got the same results, I thought that I was right but in reality I didn't understand what the kata was asking for.
Here's a screenshot of both examples.
https://lh3.googleusercontent.com/pw/ACtC-3ctdthT9WTq7pcMe2LwcIeXdI1j3RoMyETVwqd4tXiCrGw62_wk8Tcds7MNYBFLFtuUi7DfPvIVbSuYoz4PJ5-To3eKKVtyXMxVRk0t2xKG_CFowZKtJWywiBNKqlcP8v3b-f196HvmTxThd8w2hmtj=w1264-h647-no?authuser=0
Use your calculator, and verify. Hope I helped you.
Read this, and also, If you're posting code like that, mark it as spoiler.
https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
Thanks for this suggestion. I'll try to learn about this new and useful tool for maths.
This comment is hidden because it contains spoiler information about the solution