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.
You need to give n sequential numbers the sum of which will equal to the cube of the given number. For example if n =4, you will have to find 4 odd numbers the sum of which will equal to 4^3. If n=6 you have to find 6 odd numbers the sum of which will equal to 6^3. Also, you have to follow the mathematical formula according to which a1, a2=a1+2, a3 = a2 +2 etc. Hope this helps
Thank you very much,that was very helpful.Im beginner and i wouldnt consider this approach.
Tl;dr, you need a faster code. Most passed solutions can solve this kata within 1000ms.
Troubleshooting Your Solution
(Hint: try to look for pattern instead of brute-forcing)
This comment is hidden because it contains spoiler information about the solution
Resolved in this fork
Description should be language-agnostic
Probably better to use KaTeX for the mathematical part of the code
Thanks for the nice kata!
I still do not understand:
[1, 3, 5, 7, 9, 11, 13, 15]
,N = 4
True
True
True
added:
I think I understand now! Thank you!
It is in the description, you need to take a closer look (Admittedly, it's easy to overlook that single character
n
).The description states:
findSummands(3) = [7,9,11] // because 7 + 9 + 11 = 27, the cube of 3. Note that there are only n = 3 elements in the array.
Misleading description! (python lang)
From the description: "you need to find consecutive, odd numbers whose sum is equal to the cube of a given number."
Using the example
N = 4
, as a result, all tests pass, except for the length test:sum([1, 3, 5, 7, 9, 11, 13, 15]) == 4 ** 3
Incorrect length for n = 4: 8 should equal 4
sum([31, 33]) == 4 ** 3
Incorrect length for n = 4: 2 should equal 4
There is still 1 option left for
N = 4
:[13, 15, 17, 19]
. Judging by the tests, this is exactly what is needed, how should I guess about it?Looks good. Thanks!
Fixed
This comment is hidden because it contains spoiler information about the solution
Should be fixed, could you please verify.
Loading more items...