Ad
  • Default User Avatar

    10 months ago and nobody fixed it yet? Wow!

  • Custom User Avatar

    I'd guess that the reason is you can't get much faster than just int * with a manually written algorithm for multiplication. The base conversion into binary (internal representation of int) was the slow part for add. Maybe should test it out.

  • Default User Avatar

    The similar (probably a little easier) kata "Sum strings as numbers" says

    Python: your solution need to work with huge numbers (about a milion digits), converting to int will not work.

    Can't we have a likewise test with huge numbers in this kata as well?

  • Custom User Avatar

    Because the kata was originally about writing algorithms which manually multiply very large numbers. In Python, numbers can get as big as you want, so solving this would be as simple as

    def multiply(a, b):
        return str(int(a) * int(b))
    

    Which is neither interesting, nor worthy of a 4kyu rank.

  • Custom User Avatar

    This kata doesn't make sense for languages with native BigInt support (even though there's translations for languages that do support BigInt, in the future, I think they will be removed).

  • Default User Avatar

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

  • Custom User Avatar

    Fixed C++ sample tests.

  • Custom User Avatar

    Actually, I agree...

  • Custom User Avatar
  • Custom User Avatar

    So this function should return the first pair of two prime numbers spaced with a gap of g between the limits m, n if these numbers exist otherwise `nil or null or None or Nothing (or ... depending on the language).

    That should return nil, null, None or Nothing

  • Default User Avatar

    Sorry: I don't see such a case (C++ ?).

  • Default User Avatar

    How about the following edge case?

    dotest(2, 100, 102, { 101, 103 });
    

    Should this test return an answer, because 101 is within the range, or should it not return an answer because 103 is out of range?
    It's not clear for me from the decription and examples.

  • Custom User Avatar

    How do you C++ people debug such things?

    Simple: we switch to Java or C#.

    I want to prepare myself for real-world C++ with Codewars. Any additional hints are welcome.

    Switch to Java or C# :trollface:

  • Default User Avatar

    it's difficult to find out what it actually is and where from.

    Yes, it was difficult. How do you C++ people debug such things?

    it's an error on your side

    Sure, it was. Yet, if I do similar mistake in other programming languages, I typically get a compiler error.
    I think this is a real disadvantage of C++. Code compiles (and for whatever reason even worked), so how should I find out I made a mistake?
    This time I was lucky, because Codewars uses a different compiler or whatever. If this were production code, it would have gone unnoticed.
    I want to prepare myself for real-world C++ with Codewars. Any additional hints are welcome.

  • Default User Avatar

    Question resolved.

  • Loading more items...