Ad
  • Default User Avatar

    Yes, that is true. It should be j<=sqrt(i).

  • Custom User Avatar

    should be j <= sqrt(i)?

  • Custom User Avatar

    why would that make a diff, absolute size is meaningless. its about the geom of the input.
    time squaresums.sh 100000 -> 1, 2, 4, 13, 447, 99999 == real 0m0.028s
    time squaresums.sh 1000000000000 -> 5, 22, 1261, 1414213, 999999999999 == real 0m0.023s

  • Custom User Avatar

    This was a great kata, I actually spent a week on it (was much harder than most 5th kyu that I've done!). I had decided to use the C++ list type, because, oh I don't know, I guess I thought the sort() remove() and unique() functions would be useful. But while submitting I learned that the code was timing out before completing the tests. Turns out, list is too inefficient. I changed my type to vector and everything was gravy.

    This is another case where I strongly recommend adding one of the big test cases to the sample test case section...

  • Default User Avatar

    Agree, regarding the benefits of "figuring" it out. Sometimes it's more of a challenge than the kata itself and can be a real headache, but I've found I learn more about the C++ language as a whole (in terms of its quirks and intracacies) when I finally get through it

  • Custom User Avatar

    Nice Kata. My first attempt at a recursive solution passed the example tests but failed the first submission because it blew the stack for a large 'n'. (which was a flaw in my design).

    I think this kata could be improved by adding a test for large 'n' to the example tests. For C++, add:

          testequal(Decomp::decompose(100000), {1,2,4,13,447,99999});
    
  • Custom User Avatar

    This kata presents a wonderful training experience in extracting software requirements from poorly written guidelines. That may sound snarky, but this is a real skill that is worth exercising.

    However, the output format presented in the description does not match the inputs to the C++ unit tests. This really should be fixed.

    The C++ unit tests won't run, as they don't cite the 'std' namespace anywhere... but this is fine; if anything this will coerce users into modifying the unit tests (which we should be doing anyway).

  • Custom User Avatar

    Same problem in C++... but then I read the instructions more carefully. Check your inputs, folks.

  • Custom User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    Oh derp, 'while( 0 < n )' is a conditional expression