Ad
  • Custom User Avatar

    why is this solution hidden from the list?

  • Custom User Avatar

    @Hourann, very interesting observation! This is the stuff of hacks...

    I traced the socket.inet_pton implementation to some c code in the standard library exported here. It appears to have two implementations: this one & this one. It may be an interesting exercise to see where this octal behaviour starts to appear. There's even a chance that the standard python library is inconsistent with itself between operating systems. That would be something worth reporting, or contributing.

    I was curious about whether a leading zero is even allowed in IP addresses which lead me to this superuser question. Looks like the spec never bothered to define it.

    This kata asks speciifically for "dot-decimal format", and according to the wikipedia page, "... where an IP address component is written with a leading zero digit may be interpreted differently by different programs: some will ignore the leading zero, some will interpret the number as octal." and mentions this citation.

    So it looks like there's just a pinch of ambiguity to the question, and my answer just does what python standard library implementers chose to do.

    Thanks for leading me on this interesting investigation! Hope you found this info interesting as well...

  • Custom User Avatar

    I test your code in Python 3.5.2

    is_valid_IP('0.0.0.077') returns true
    is_valid_IP('0.0.0.088') returns false
    

    I think it transfer number 0xx into Oct number

    So your sulution is clever but you just pass all test case by chance.The problem need to check a dot-decimal format ipv4 string.

  • Custom User Avatar

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