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?

  • 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.

  • 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

  • Default User Avatar

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

  • Default User Avatar

    Eventually I have passed! Thanks for your help :)

  • Default User Avatar

    Right, got it. Thanks!

  • 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?

  • Default User Avatar

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

  • Default User Avatar

    Thanks, yeah once I understood what I actually had to do, I got there quite quickly. I've spent ages on that so I'm glad I finally passed. Must remember to read the question properly in future!!!

  • Default User Avatar

    Help!!! I am so completely stuck on this but also, I cannot work out why this one has failed:

    25,25,50,100,25,50,25,100,25,50,25,100,25,50,25,100,50,50

    it says it expects NO but mine returns YES. Why isn't this yes?

    My indices:
    0: balance is 0, change required, 0, - YES + income 25
    1: balance is 25, change required, 0 - YES + income 25
    2: balance is 50, change required, 25 - YES + income 50
    3: balance is 75, change required, 75 - YES + income 100
    4: balance is 100, change required, 0 - YES + income 25
    5: balance is 125, change required, 25 - YES + income 50
    6: balance is 150, change required, 0 - YES + income 25
    7: balance is 175, change required, 75 - YES + income 100
    8: balance is 200 ($100 + $100), change required, 0 - YES + income 25
    9: balance is 225, change required, 25 - YES + income 50
    10: balance is 250, change required, 0 - YES + income 25
    11: balance is 275, change required, 75 - YES + income 100
    12: balance is 300, change required, 0 - YES + income 25
    13: balance is 325, change required, 25 - YES + income 50
    14: balance is 350, change required, 0 - YES + income 25
    15: balance is 375, change required, 75 - YES + income 100
    16: balance is 400, change required, 25 - YES + income 50
    17: balance is 425, change required, 25 - YES + income 50

    And from this point there is always enough change. Well, as I write this I realise I may have got the logic wrong. Am I right in thinking this is not just about total balance but the actual type of notes you have available in the till? In which case 16 would be a NO?

    Gaahhhh looks like I need to start again right?