Ad
  • Default User Avatar

    Thanks for the hint. It was so slow. Optimized and passed the tests. Fun one, thanks for the tips.

  • Custom User Avatar

    Love this one. Thanks!!

  • Custom User Avatar

    Hint: to calculate the sum of all proper divisors of a number n, you don't need to test every number up until n / 2.

  • Custom User Avatar

    Ah probably, if the error you receive is a timeout after 12 seconds, then that means you have to optimize your code. Hint: to calculate the sum of all proper divisors of a number n, you don't need to test every number up until n / 2.

  • Custom User Avatar

    I've got the right solution for this in Javascript but I am getting "Execution Timed Out (12000 ms)". I refactored the code several times and still not working. The sample tests run fine but when I attempt it's always failing. Is it really possible? Could it be that the tests in that translation are provoking some issues?

  • Default User Avatar

    After doing more testing, I think my solution is just too slow. I put in the test cases and get the right answer, but the higher the numbers get, the longer it takes to spit out the solution. So I think I'm just timing out.

  • Default User Avatar

    OK.
    Small notes:
    the initial kata and most translations return strings but with the JS translation JohanWiltink introduced arrays which I didn't like much (mix of returns: array + string "Nothing" in the same function) but I approved it.
    Benchmarks don't seem to show that while loop are slower than blocks with each (the overhead of creating a function(the block), sending it to the each method, and calling it on every iteration of the for loop inside the each method's implementation) but who really knows:-(
    Thanks again for your good work at CW.

  • Default User Avatar

    I understand I shouldn't have a main, I was just using that for testing my functions. I was hoping to be able to post my functions into the skeleton and figure out how to get them to work. I just think I'm having a problem with the formatting because the sensei has created a namespace for the answer and I'm just not familiar with creating a namespace.
    I think I'll keep working on it before I post the code. I've just gotten lazy at this point. I'll try making my own namespace with the functions in the namespace.
    Thanks

  • Custom User Avatar

    If you post your code, make sure you mark your post as having spoiler content.

  • Custom User Avatar

    There shouldn't be a main in your code, and check if your function names are the same as in the base skeleton code (this is important because the unit tests are calling those function names).

  • Default User Avatar

    Trying to solve with C++. I've created functions that perform the smaller tasks and I can't seem to get them formatted correctly on the training page to test.
    I think it is the namespace that is throwing me off. Can I post my code for help?
    Code currently consists of:
    -includes
    -function prototypes
    -main with one line of code
    -four function definitions
    Thanks in advance.