Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
why is this solution hidden from the list?
@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...
I test your code in Python 3.5.2
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.
This comment is hidden because it contains spoiler information about the solution