Ad
  • Custom User Avatar
    • your first line (inside the function) clearly isn't doing what you think it does (btw, bin_a has never been defined before so... => !??)
    • and reverse_inplace! isn't a function of the ruby String class, afaik (careful about the language version too: on CW, you're limited to ruby 2.5.0)

    edit: btw, you're not supposed to have an argument to that function (you need to learn a bit more about class/OOP design and how to declare methods in such a kind of situation)

  • Default User Avatar

    thanks for that

    the code is:

    class Integer
      def reverse(a)
       a.to_s(2) == bin_a #integer to binary
       bin_a.to_s.reverse_inplace!.to_i = bin_b #reverse order of binary
       return bin_b.to_int #new binary to integer
      end
    end
    
  • Custom User Avatar

    You can read about code formatting on CodeWars wiki.

  • Default User Avatar

    I could use some help with this one. I've worked out what I need to do, I just can't seem to make the code work for it for some reason. I keep coming up against the error: wrong number of arguments given, expected 1, received 0.

    Unfortunately I also can't work out how to post my code in the comment boxes either so if someone could also tell me how to do that I can add the code into this.

    Thanks in advance

  • Custom User Avatar

    You might want to try easier kata first, then. Try going through some more whites, 8 kyu and 7 kyu, and when you feel comfortable with these, go to more difficult ones (easy yellows), and so on.

  • Default User Avatar

    I managed to get the static tests to work but the random tests failed as my code didn't work for random names other than the ones in the instructions and sample tests.
    I'm very new to Ruby and coding in general (completed the codeacademy course only recently and not done any other katas yet!) and I'm not sure where to start with returning any names, let alone returning the first two names then the number of other people.

    Any chance someone could point me in the right direction?