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.
Was copied from Ruby translation which doesn't have random tests, just going to unpublish
Done
Fixed it, but this is a very common problem
Still needs random tests
Forked
Forked
Fixed both
Assume we are working on the binary number 1101001.
The first bit is 1, and since
(0 << 1) + bit
is0 + bit
which is just the bit, the result is set to just this bit.The second bit is also 1, so we left shift the result by 1, making the result 10 in binary. Since the final bit is 0 and bits are numbers between 0 and 1, adding a bit here would be the same as setting the last bit to the new bit (same with OR operator). Adding the bit to the result, we get 11.
Third bit is 0, left shift result by 1, get 110, add 0, get 110.
Fourth bit is 1, left shift result by 1, get 1100, add 1, get 1101.
Hopefully this makes it more clear.
Done, see https://www.codewars.com/kumite/5e9c1678ae2b04001df4f5e5?sel=5fc768eb0ad5b1001302d54f
Yes, the kata specifically mentions
0 < str length < 1000
Yes, seems good, the sitewide fixes means every kata is absolved.
Fixed in fork
There was a merge conflict, forked with the fix
Yes, thank you, that works, it was stupid of me to not think of that. I've changed the kata tests and the sample tests to that, the sample tests because they add clarity.
I've changed it, is it fine? I would have liked to use
&&
instead of||
here but only||
evaluates both sides (since it returns nil). I've also changed it fromshould eq true
toshould be_true
for simplicity's sake, but I can revert ifeq true
sounds more natural.Loading more items...