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.
Kata hint != kata suggestion. See https://docs.codewars.com/training/troubleshooting#post-discourse.
Also, this is a 5 kyu kata. Users should know how to efficiently compute fibonacci numbers at this level, and if they don't, they should be able to research how to by themselves.
This comment is hidden because it contains spoiler information about the solution
fixed. your solution fails both the random and fixed tests consistently now
your solution writes past the end of the
output
buffer: you are printing a trailing'.'
, and then erase it. this is not robust: the worst-case output size is16
i.e.strlen("100.100.100.100") + 1
, so the caller of the function can expect that16
bytes should be enough, but your solution needs more bytes than that. as a result of writing out-of-bounds, you corrupt the tests suiteit is your code that is wrong: you are adding trailing zeroes instead of leading zeroes to the binary string. please ask a
question
in the future instead of raising anissue
;-)no, the problem comes from your code. you are assuming that the binary string you create is always 32 chars long, this is not true.
Please ask a
question
(not anissue
) to ask for help in the future ;-)Is it possible to implement this in Kotlin? When attempting a logical AND operation, garbage is returned. When I look at the code that compiles in Java, there is a completely wrong idea.
UPD:Implemented via string. But the test fails. Error with ip: 89.118.64.172.
In 10th representation it is 1500922028.
In the 2nd representation - 10110010111011001000000101011000. The first 8 bits 10110010 = 178. Am I missing something or is there an error in the tests?
If you were able to write a “slow” version, look at the output of numbers and the operation of the algorithm, look for a pattern.