Ad
  • Custom User Avatar

    I tried looking over the code, and one problem I noticed right away is that your list has a bunch of duplicates, and it's also not sorted (expected result is sorted list). With those problems fixed, here's what your code generates for pin "9173" in each iteration:

    6,8,9
    61,82,94
    614,827,948
    6142,8273,9486
    

    As you can see, that is not correct. The 2nd row should be 61,62,64,81,82,84,91,92,94 (I think). It looks like you're missing one more loop somewhere.

    Also, if you read error messages, they tell you what elements are expected, and which ones are missing.

    BTW, recursion is definitely not needed, but it's possible both ways.

  • Custom User Avatar

    "There nust be something wrong with tests" is too vague and not a kata issue, rather a question. C# has 687 completions so far, and it's unlikely something is wrong (and you didn't bother to provide an example).

    Currently your code is not formatted and very difficult to follow. Please post your code with proper markdown and maybe someone will take a look at your code then.

    For general troubleshooting, please read this FAQ.

  • Custom User Avatar

    I did the recursion in correct way since it is working in Visual Studio.

    No, you didn't. See the line before return null; you should be returning that instead.

  • Custom User Avatar

    You can use recursion if problem allows it, but what Chrono meant here is that your recursive solution is probably not structured correctly. It's difficult to tell without seeing your code, but whenever similar problem pops up for some newbie, the most common reason is that they do not return the result of recursive call and ignore it, because they think that just calling the function recursively is enough and ignore the result of the inner call.

    We believe that your problem is similar, but as I said, it's just guessing.

  • Custom User Avatar

    So that means that in coedwars to pass the tests I cannot use recursion by returning another call to the same function?

    No, it means you have to return the call, not only call the function. I can't tell what the problem is without seeing your code, so I'm only guessing here.

  • Custom User Avatar

    Did you mean recursion?, and it is probably the problem, make sure you return the call, not only calling the function.

  • Custom User Avatar

    Is your function returning?

  • Custom User Avatar

    What is the error that you're getting?

  • Custom User Avatar

    If your algorithm were correct, it would pass tests ;) It's not.

    It returns invalid answer for, for example, 143.

    Not a kata issue.

  • Custom User Avatar

    Your algorithm isn't correct. 1194159317 is not a prime number and your code says it is.

  • Default User Avatar