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.
This comment is hidden because it contains spoiler information about the solution
That´s good point.
You can always use isqrt
Yes - most katas allow you to import anything you want, unless it is explicitly banned (this will be stated in the kata description if so).
You can even also use some advanced packages, like NumPy for more advanced mathematics katas.
For Python you can read the list of available packages here:
Python - importable packages
didn't know you can import stuff here
[].index(nil)
returns nil.nil || 0
would give you 0.[].delete_at(0)
is a no-op where as[].delete_at(nil)
throws an exception.You need to return an integer, not a string.
An articulated and helpful comment, even if it were criticism, is always welcome, thanks! :)
parseInt isn't required here, (Integer. str) (with a space after the ., for some reason the space is getting removed in my comment) gets the job done. parseInt would avoid errors if there are any letters in the middle of the string, but knowing that the inputs will always be numerical makes this unneccessary. Not a criticism, just a comment
Depending on how you want to tackle it, one word to help you out: memoize
Basically, you take an array [1] and add the results of 2x+1 and 3x+1 to it. Then you have an array with 3 values [1,3,4]. Then you go through and add the results of 2x+1 and 3x+1 for each of the new numbers. Since you add two numbers each for each number, the amount of calculations you do on each pass increases exponentially. Then you return the nth element of the array. The issue here is that getting to large numbers, just having an array that goes past "n" indices will not guarantee a correct answer, since so many new values are added and some of the lower ones will have 2x+1 and 3x+1 results that are NOT YET part of the array. So you need to overshoot the size of the array in terms of "n" by quite a bit.
Wow! What great code!
This comment is hidden because it contains spoiler information about the solution
Thanks mate! Im a noob and didn't know that. Will keep it in mind!
✘ Got 34 from gift #1, expected 34.
✘ Got 22 from gift #2, expected 22.
✘ Got 94 from gift #3, expected 94.
✘ Got 59 from gift #4, expected 59.
✘ Got 87 from gift #5, expected 87.
✘ Got 28 from gift #6, expected 28.
✘ Got 62 from gift #7, expected 62.
✘ Got 71 from gift #8, expected 71.
✘ Got 5 from gift #9, expected 5.
✘ Got 47 from gift #10, expected 47.
What's this about? Why is this failing?
Loading more items...