Ad
  • Default User Avatar

    The reason I do codewars is to see other people's answers after I complete a challenge as it helps me learn. Clearly have a lot to learn!

  • Default User Avatar

    Me too, I'm very confused. Did you figure it out?

  • Custom User Avatar

    Yes, you need to reuse the input conserving its format.

  • Default User Avatar

    In the test, sometimes the expected isbn is in this format 000-0-00000-000-0 and sometimes it is in this format: 000-0-00-000000-0 and sometimes in this format: 000-000-00-0000-0

    all of my isbns are returned in the first format so I'm failing th tests. HOw do I know which format to use for which ISBNs?

    Oh I think I answered the question, because the dashes need to be in the same place as they are in the original? I was confused because I thought that ISBNs are always in the format of the first example in the tests above. I will have another go.

  • Custom User Avatar

    The description gives an exact algorithm to calculate the output from the input, what's the problem, concretely?

  • Default User Avatar

    why are the test output ISBNs in different formats - with dashes at different places? It doesn't mention this in the output instructions.

    describe "Sample tests" do
      it "Some examples" do
        expect(isbn_converter("1-85326-158-0")).to eq("978-1-85326-158-9")
        expect(isbn_converter("0-14-143951-3")).to eq("978-0-14-143951-8")
        expect(isbn_converter("0-02-346450-X")).to eq("978-0-02-346450-8")
        expect(isbn_converter("963-14-2164-3")).to eq("978-963-14-2164-4")
        expect(isbn_converter("1-7982-0894-6")).to eq("978-1-7982-0894-6")
      end
    end
    
  • Default User Avatar

    Ok, I figured it out on the other one. It's because I was trying to add 1 to an index that didn't exist. So I guess in the above I am trying to do something similar. I will work it out...

  • Default User Avatar

    Thanks for this, if I put a return in place of the puts, I get this error message: ./lib/solution.rb:8:in sum_of_differences': undefined method -' for nil:NilClass (NoMethodError)

    Any ideas? It is working in vs code.

    Actually I am getting the same error on a different kata. On this one it is because I am doing +1 on an array index, like I am in the code above. I think this is the problem. Do you know how to do this differently? Ta

  • Custom User Avatar

    You need to return the answer, not print it.

  • Default User Avatar

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

  • Default User Avatar

    congrats, you're welcome, happy coding

  • Default User Avatar

    Eventually I have passed! Thanks for your help :)

  • Default User Avatar

    Right, got it. Thanks!

  • Default User Avatar

    consider this feedback using console.log(n = ${n}); at the beginning of your code:

    n = 725635
    Expected: 1, instead got: 10
    
    • the input passed to your function was 725635
    • your function returned 10
    • the correct expected value for this test is 1
  • Default User Avatar

    Thanks, I see what you mean about the while part. Sorry I don't understand what you mean about 10 and 11 being outputs not inputs. This is what I input into the function call.

    Can you give me any clues about how to approach this?

  • Loading more items...