Ad
  • 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

    Okay sounds fair! :) Thanks.

  • 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.

  • Default User Avatar

    Let's make something clear from start. CW is for fun and not for job.

    With that settled, This code is not meant to go in some beauty contest or anything. This is about getting the job done without wasting time on stuff that doesn't matter.

    What you can do in one line, why waste 20 on it.

    it usses various es6 features

    Well ES5 was released in 2009, currently it is 2k17, 8years ago making ES5 basically obselete.

    It doesn't give better time or memory complexity, I just wrote the code to get the job done.

  • Custom User Avatar

    Really? I could tone it down a little, if needed
    The reference solution runs in 7.5-10.5 sec

  • Custom User Avatar

    Ha ;)

    Hmm.. the performance requirements seem a lot steeper in Python than in JS or Ruby.

  • Custom User Avatar

    Feel free to use the test suite and/or the solver.

    Cheers

  • Custom User Avatar

    Too bad ;-)

  • Loading more items...