Ad
  • Custom User Avatar

    Hi, thank you for the kata. I got fooled for the same reason as examples were not updated in C#.

  • Custom User Avatar

    @nUG48YpaiHBG you mean in terms of performace?

  • Default User Avatar

    @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!

  • Custom User Avatar
  • Custom User Avatar

    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.

  • Default User Avatar

    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.

  • Custom User Avatar

    I can't think of anything that prints nothing at all. Even (println "" []) would print at least [].

  • Default User Avatar

    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)?

  • Custom User Avatar

    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 :\

  • Custom User Avatar
  • Default User Avatar

    You're right, and also as you noted it, defining two_count as c 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.

  • Custom User Avatar

    It works just fine in this form two_count=lambda n:~n&1and-~two_count(n/2), no?

  • Default User Avatar

    Recursive function

  • Custom User Avatar

    what c is for? to make c(n/2) shorter?

  • Default User Avatar

    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...