Ad
  • Custom User Avatar

    Very nice kata and very original. Is there a real life application, though? (python hobbyist, here, not an engineer)

  • Default User Avatar

    As I understand it, it's just how BitConverter works. It seems that whatever architecture CodeWars uses to run our code happens to be little-endian, and thus GetBytes() acts accordingly. See the documentation:

    The order of bytes in the array returned by the GetBytes method depends on whether the computer architecture is little-endian or big-endian.

    Do note that the Kata does implicitly describe the first octet being the left-most one (and, correspondingly, the most significant one).

  • Custom User Avatar

    Definitelly to easy for 5kyu

  • Custom User Avatar

    Approved!

  • Default User Avatar
  • Custom User Avatar

    WhAT Should i do when length < 30?

  • Custom User Avatar

    Heh :) somehow it slipped out of my view. It makes perfect sense now. Thank you for pointing that out!

  • Default User Avatar

    but it's explained in the initial code:

    Java doesn't have uint32, so here we use long to represent int32

    Java has no unsigned, so you have to use a long to keep everything positive

  • Custom User Avatar

    Especially in Java translation, it's confusing to see the method String longToIP(long ip) when the kata name clearly states that the IP address is represented as a 32-bit integer. From my point of view it would be more appropriate to have String numToIP(int ip).

  • Default User Avatar

    My code passes all basic tests but this one where expected is 106.205.145.98 and my output is 213.155.34.98.
    I found out when using .toString(2) on this particular case where the 32bit number is 1791856994 the 2bit number will have an extra 0 at the start.
    I've no god damn idea what's wrong with this and why only this particular case.
    Shouldn't .toString(2) be accurate?

  • Default User Avatar

    Because input length maybe <32, we should convert binary to decimal started from end not from start. Maybe someone can say why, we should start from end?

  • Custom User Avatar

    i'm new to ruby can someone explain how does that %s work?

  • Default User Avatar

    that remains seperately as a different problem with your code because it doesn't handle every case properly

  • Default User Avatar

    But if it I don't allocate the memory, it causes a memory access error

  • Default User Avatar

    In your code, you attempt to allocate memory for the provided char *IPv4 within the function, but it has already been pre-allocated prior to being passed to the function.

  • Loading more items...