Ad
  • Custom User Avatar

    Very nice but limited, agree with first comment

  • Custom User Avatar

    not correct solution ,
    the gravity means that everything move down towards land ,
    but your solution just flip the list down ,
    for example if you try lst of any other characters your solution will not work,
    the right solution is to make the characters move down

  • Custom User Avatar

    I never would have thought to use the set like that. Very clever!

  • Custom User Avatar

    "terrible practice one-liner, but it's funny, so I'll vote it as clever."

  • Custom User Avatar

    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

  • Custom User Avatar

    This solution is nice and short, but it is O(^2).

  • Custom User Avatar

    Thank you very much,that was very helpful.Im beginner and i wouldnt consider this approach.

  • Custom User Avatar

    Your solution is too slow, especially for more difficult/larger inputs. The computational complexity of some problems grows rapidly with input size and sometimes trivial, naïve solutions pass for small inputs, but are not sufficiently performant for more challenging scenarios. You probably need to think of a better approach: some optimizations might help, but also might not. In the latter case, you probably need to think of a better algorithm.

    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)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Custom User Avatar
    • Description should be language-agnostic

    • Probably better to use KaTeX for the mathematical part of the code

  • Custom User Avatar

    Thanks for the nice kata!

  • Custom User Avatar
  • Custom User Avatar

    I still do not understand:
    [1, 3, 5, 7, 9, 11, 13, 15], N = 4

    • sequential - True
    • odd - True
    • equal to cube N - True

    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.

    added:
    I think I understand now! Thank you!

  • Custom User Avatar

    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:

    ... your task is to find n consecutive odd numbers whose sum is exactly the cube of n

    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.

    ... return an array of n consecutive odd numbers

  • Loading more items...