Ad
  • Custom User Avatar

    It seems to be timeout

  • Default User Avatar
  • Custom User Avatar

    Thank you for your reply. I changed 2 lines of my code and it works now. I don't know if it is because of the difference between c++14 and c++11.

    code failed:

    bool operator<(const std::string &lhs, const std::string &rhs) {...}
    ...
    if (str1 < str2) {...}
    

    code that is accepted:

    bool less_than(const std::string &lhs, const std::string &rhs) {...}
    ...
    if (less_than(str1, str2)) {...}
    
  • Default User Avatar

    287 guys passed the C++ kata so I don't think there can be an error:-) If there was one, somebody else should have had a problem. Nevertheless It would be better if you gave the input.
    For the string
    "311161 123053 192411 242336 292316 90806 237453 224791 281085 39016 124526 226219 133683 109529 311686 245429 426860 285474 487608 497517" the result given by my solution is:
    "311161 123053 192411 39016 124526 242336 226219 292316 90806 133683 237453 281085 224791 311686 109529 245429 426860 285474 487608 497517" which is correct.
    I am afraid you could have mutated the input.

  • Custom User Avatar

    Lang: c++ 11/14

    Expect : 311161 123053 192411 _242336 292316 90806 237453 224791 281085 39016_ 124526 226219 133683 109529 311686 245429 426860 285474 487608 497517
    Actual : 311161 123053 192411 _39016 124526 242336_ 226219 292316 90806 133683 237453 281085 224791 311686 109529 245429 426860 285474 487608 497517
    

    Look at the result above.

    • weight(242336) is 20
    • weight(39016) is 19

    So, how could 242336(20) comes before 39016(19)??

    And:

    • weight(124526) is 20
    • weight(242336) is 20

    The two numbers are equal, but how could 242336 comes before 124526?

  • Custom User Avatar

    Using a primes cache accelerates the iteration.

  • Custom User Avatar

    Isn't the isPrime function suspectable?

  • Custom User Avatar

    Hi, I use the same thought with you. But I think the result should plus one.