the OP was talking about Go. the only Go version on Codewars as of writing this is 1.20, so this is no longer relevant; and it was not a kata suggestion but a hint to begin with
your code assumes that the input string at most 14 characters long. it returns false positives for leading/trailing whitespace and + signs. it crashes for "..." as strtok("...", ".") returns NULL.
I completely overhauled the C test suite. I replaced the reference solution, as it was wrong for several kinds of invalid inputs, e.g. ".1.2.3.4", "1.2.3.4.", etc.
I don't think the description means that these IP addresses are invalid across the board. I think it means to consider them invalid for this task, which is perfectly fine. Typically when IP addresses are displayed in any system, they are displayed without leading zeroes. This task is likely trying to recreate that, even if the leading zeros aren't "wrong".
The question seems to misunderstand some IP address concepts. For example, 12.34.56.00 is a valid IP, leading 0s are absolutely fine (although unnecessary), and a few other things. Because of this, I don't think there is any "best practice" for this question and it could be teaching bad practices in terms of IP address validation.
as of now the initial code in C# compiles and runs, so it seems this suggestion is no longer relevant
the OP was talking about Go. the only Go version on Codewars as of writing this is
1.20
, so this is no longer relevant; and it was not a kata suggestion but a hint to begin withReference solution was wrong for trailing dots. Added some more test cases and approved.
Added some more tests and approved.
your code assumes that the input string at most
14
characters long. it returns false positives for leading/trailing whitespace and+
signs. it crashes for"..."
asstrtok("...", ".")
returnsNULL
.I completely overhauled the C test suite. I replaced the reference solution, as it was wrong for several kinds of invalid inputs, e.g.
".1.2.3.4"
,"1.2.3.4."
, etc.approved (note: i can't mark this as resolved by myself)
You can try again, I added failure messages for users who did not buy the paid subscription.
No, everyone can see failed test cases for free. Usually tests show them, but if they don't, everyone can use
print
to see them.No, codewars red people don't get anything like that. You can always just print the input to see what it is.
Time: 487ms Passed: 336Failed: 2Exit Code: 1
Let me guess. I only see the failed cases if i have a paid subscription?
Closing as this isn't an issue.
I don't think the description means that these IP addresses are invalid across the board. I think it means to consider them invalid for this task, which is perfectly fine. Typically when IP addresses are displayed in any system, they are displayed without leading zeroes. This task is likely trying to recreate that, even if the leading zeros aren't "wrong".
The question seems to misunderstand some IP address concepts. For example, 12.34.56.00 is a valid IP, leading 0s are absolutely fine (although unnecessary), and a few other things. Because of this, I don't think there is any "best practice" for this question and it could be teaching bad practices in terms of IP address validation.
Haskell translation
Loading more items...