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.
Thanks, I'm glad you liked it and that it was a learning experience for you. I have been trying to come up with another networking kata but it's harder that one might think. But, comments like yours sure makes me want to try even harder, so thank you for that :) Have a happy new year.
For some unknown reason the source code has been changed for the solution of this kata (the indentation had been changed to tabs and a hex value checking for class C networks had been erroneously changed (making some tests fail).
Again, I have no idea as to why or how this has happened, but I have now fixed the issue.
If anyone knows how to see who changed source code (revision history for a translation), please let me know because I can't seem to find it.
Great work! So, you can have the honor of retiring the kata...
Very elegant solution! 😀
Thanks for noticing. I didn't see that prior to the translation approval, but have now updated the code so that it calls your function with strings as intended.
Thanks! Looks good as far as I can see with my non-C-sharp eyes 😜 Approved.
Great, now it works :) I made some final adjustments to the description and naming, but now it is approved and published.
Hm, not really. Try to add a
print(matches(*i))
in the end of the random tests and you'll see that all tests still evaluate toFalse
. Like this:Read my last post carefully and see if you can make 50% of the random tests evaluate to
True
.The way I do it is to randomize test data until I get variables that makes the
match()
function returntrue
, the next return value must befalse
, thentrue
and so on. If you randomize a wildcard mask that looks like this00000000.00001111.11111111.11111111
the likelyhood if getting variables that returntrue
is much greater.Have a look at my tests
Test(match, random) { }
under the C Kata Reference.I agree, this is a 6 kyu, for C at least.
Oh, and one more thing :)
In the random tests, the way
wc_mask
is randomized will make it hard to find a match that evaluates toTrue
due to the fact that it will randomize all of the bits in the variable:You will for example get wildcard masks like these:
10101110.10101001.00101110.11101010
00101101.10001011.11010101.00000101
It would be better to randomize masks that are more likely to find a match, like these:
00000000.00000000.00000111.11111111
00000000.00001111.11111111.11111111
Again, feel free to take a look at my random tests in the C version.
Looks great, but I have a few requests:
def match(net_addr, wc_mask, ipv4_addr)
.def match(net_addr: str, wc_mask: str, ipv4_addr: str) -> bool:
would be preferred IMO.False
due to the randomness of all parameters. If you take a look at my random tests in C you can see that 50% of the tests aretrue
and 50% arefalse
, which IMO is far better than tests that most likely are alwaysfalse
.Once these things have been fixed I would be happy to make it part of my Networking Series as well :)
Congratulations, glad to be of help 😜
This comment is hidden because it contains spoiler information about the solution
I'm a bit unsure if it should be translated into Python, but I have approved it. It sure is slightly harder in C though.
Thanks for catching those, I have now fixed the redundant call to
sort_array
, changed thevoid should_be()
funtion tostatic void should_be()
and also removed the cast toconst int*
in theatos()
calls.Loading more items...