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.
Hi, thank you for the kata. I got fooled for the same reason as examples were not updated in C#.
@nUG48YpaiHBG you mean in terms of performace?
@felyxjet thank you for this comment, I knew strings were immutable but didn't put together that it meant creating a new string every time.
Does this mean that using the str.join() method is like using the list.append() method?
TIA!
You're troll :)
Turned out output format is dumb af. Printed log inside a drop-down triangle is actually for following test. So, my code in fact fails on
12341234 [DIeF IeFD 12341234 41234123 34123412 23412341]
. Sorry for bothering.Which is the number of the test you don't pass? (1st, 2nd, 3rd... ?) Fixed tests or random tests?
I tried with an error and it seems that when a test fails the
(println strng arr)
doesn't work at CW.I can't think of anything that prints nothing at all. Even
(println "" [])
would print at least[]
.It is not an issue of the kata but of your code.
If when printing you don't see anything what could that be?-) Did you think of possible corner case(s)?
Clojure version, one test doesn't pass.
Trying to figure out why with
(defn contain-all-rots [strng arr] (println strng arr) ...
and get nothing but
expected: (= act exp) - actual: (not (= false true))
for it. The rest tests print out log as expected :\Just for lulz?
You're right, and also as you noted it, defining
two_count
asc
helps to shorten code size.Aiming to the smallest code is a recreational programming exercise called code golfing and codewars kumite is a good way to exchange tips about it and post shorter and shorter solutions by forking them.
It works just fine in this form
two_count=lambda n:~n&1and-~two_count(n/2)
, no?Recursive function
what
c
is for? to makec(n/2)
shorter?Hmm... black magic? :D
More seriously, it is a recursive solution that adds one to the result if the right bit of current
n
is equal to 0.Then n is divided by 2 and the next bit is checked.
I must also thank you for remembering me this solution because I was able to made a shorter one, feel free to have a look!
Loading more items...