Ad
  • Custom User Avatar

    Approved

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    thank you bro, don't get description of this kata at all) Can you add this link to kata's details?

  • Custom User Avatar

    approved

  • Custom User Avatar

    It's ok in the current version.

  • Custom User Avatar

    COBOL translation (author is inactive).

  • Custom User Avatar

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

  • Custom User Avatar

    In c++ they forget to put a ";" at the end of the class initialization. It must be:

    #include <string>
    
    class Negabinary{
    public:
      static std::string ToNegabinary(int i);
      static int ToInt(std::string s); 
    };
    

    This is the only case that I cannot understand and tried to recognize which forgotten ";" there in class initialization. :joy: So please fix it.

  • Custom User Avatar

    Giving examples doesn't mean there is no need to define what a negabinary system is.

    https://en.wikipedia.org/wiki/Negative_base

  • Custom User Avatar

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

  • Default User Avatar

    Unfortunately -2,863,311,530 is not in the Integer range, so you would truncate it by casting to 1,431,655,766. Also there was no requirement in the description that it should work for the whole possible input range. I just translated test cases from the JavaScript version.

  • Custom User Avatar

    How about adding the following tests?

      @Test
      public void negabinaryMinMaxTest() {
        // 1,431,655,765 is the maximum value that can be represented with 32 bits
        assertEquals("1010101010101010101010101010101", Kata.intToNegabinary(1431655765));
        // -2,863,311,530 is the minimum value that can be represented with 32 bits
        assertEquals("10101010101010101010101010101010", Kata.intToNegabinary((int) -2863311530L));
      }
    
      @Test
      public void nativeMinMaxReversibilityTest() {
        assertEquals(Integer.MAX_VALUE, Kata.negabinaryToInt(Kata.intToNegabinary(Integer.MAX_VALUE)));
        assertEquals(Integer.MIN_VALUE, Kata.negabinaryToInt(Kata.intToNegabinary(Integer.MIN_VALUE)));
      }
    
  • Custom User Avatar

    Thanks, enjoyed a lot. =)

  • Loading more items...