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.
The general form ended up working for me, I did have to mess with the ordering though
This comment is hidden because it contains spoiler information about the solution
Loved the Kata, interpereters are always fun, but I was able to brute force the random tests with a bit of good RNG.
Now I gotta find something else to do......
Okay, done. Thanks for the fix.
Fix applied. Thanks @RileyHunter
Just apply the fix I think - I'm not attached to the fork in any way and the change is literally two characters.
can't approve the fork yet, but I can directly apply the fix. I don't know what to do here... x_x
Bugfixing fork to address cases in which the JS reference solution breaks down:
https://www.codewars.com/kumite/65383e33e681c41613bcb605?sel=65383e33e681c41613bcb605
Details on bugfix here:
https://www.codewars.com/kata/63c05c1aeffe877458a15994/discuss/javascript#6536cc0c49d3ef23dade29b1
Waiting on approval.
Confirming this is a bug in the reference solution. When the first polynomial string ends with the variable and the second starts with it the variable is incorrectly detected as being multiple characters, e.g.
Testing: -1+4a and a-9a^3: expected '-36a^4+9a^3+4a^2-a' to equal '-NaN'
This is because it's scanning the concatenated string
-1+4aa-9a^3
and finding the "variable"aa
, then parsing breaks down from there. I've fixed this in a fork here:https://www.codewars.com/kumite/65383e33e681c41613bcb605?sel=65383e33e681c41613bcb605
Just waiting for approval
There are libraries for this, but I don't think they can be used on Codewars.
If you're running node locally, you can find libraries on https://www.npmjs.com/
Complexity
Since you have to multiply every term of one polynomial with each term of the other polynomial,
the best you can do is O(m*n) where m and n are the number of terms in the two polynomials.
You can only get O(n^2) if both polynomials have the same number of terms.
Are there any Javascript libraries that could be helpful for this? I haven't worked with JS imports before and have no idea if there are any math based one.
If not, is there a way I can get my code from O(n^2) to O(nlogn)?
Also I'm trying to learn complexity so am I right in that assement above?
Unfortunately, your kata got already retired. You could try again, just make sure to adhere to certain quality requirements when authoring a kata. Good luck :)
Fixed
same lol
Random tests requried