Ad
  • Custom User Avatar

    Yeah, recursion is rarely optimal. But it is fun.

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks, I didn't know you could use count() for substrings in Python. :)

  • Custom User Avatar

    Look closely, the expected result is indeed smaller.

  • Custom User Avatar

    In regard to your question, Moagli, it sounds like you removed the "static" keyword from the race method.

    The tests call the "race" method from the Tortoise class itself rather than from any instance, so the method needs to remain static.

    e.g.

    static std::vector<int> race(int v1, int v2, int g)
    
  • Custom User Avatar

    Well done copying my solution verbatim, and just removing the whitespace and braces.

  • Custom User Avatar
    Test.assertEquals(position(4, 14, 3), 5);
    Test.assertEquals(position(2, 25, 0), 12);
    Test.assertEquals(position(7, 749, 5), 109);
    Test.assertEquals(position(3, -9, 1), -3);
    Test.assertEquals(position(5, 0, 0), -2);
    
  • Custom User Avatar

    Sure, no problem. Made the generator readable. Let me know if you'd rather I removed it altogether.

  • Custom User Avatar

    Glad to hear you overcame it, and learned something in the process, well done. :)

  • Custom User Avatar

    The console is finicky about consecutive spaces in strings, so these problems can be a real pain to troubleshoot. If you use this workaround to wrap your result: return "x" + result + "x", perhaps you'll see more spaces than intended.

    As to determining why it's happening, I think adding System.out.println("[" + s + "]"); to your for loop might shed some light.

    Good luck.

  • Custom User Avatar

    That issue is already raised lower in the discourse: Some languages don't test whether 0 is a perfect square. This should get addressed as soon as one can edit +500 solution katas.

    Test cases become locked after 500 users have completed the kata.

  • Custom User Avatar

    Yep, I think that should be fine. Mentioning it should help minimize future misunderstandings. :)

  • Custom User Avatar

    I think you're doing Python? Just checked the kata. Tests seem to work, the messages are just a little convoluted. The right-hand value of '######3700' should equal '#######7##' is what your solution returned for the input: '3656013700'.

  • Custom User Avatar

    Are you sure? It does when I do it.

    I don't see any reason why it should be any different.

    public class SumSquaredDivisors {
      public static String listSquared(long m, long n) {
        System.out.println("testing123");
        return "";
      }
    }
    

    outputs

    test1(SumSquaredDivisorsTest)
    testing123
      expected:<[[[1, 1], [42, 2500], [246, 84100]]]> but was:<[]>
      
    test2(SumSquaredDivisorsTest)
    testing123
      expected:<[[[42, 2500], [246, 84100]]]> but was:<[]>
      
    test3(SumSquaredDivisorsTest)
    testing123
      expected:<[[[287, 84100]]]> but was:<[]>
    

    Maybe the problem isn't in the println itself.

  • Custom User Avatar

    System.out.print("hello"); and System.out.println("hello"); should work in Java without importing.

  • Loading more items...