Ad
  • Custom User Avatar

    You don't need to apply map here. Map will pass progressive values accross multiple lists, so long as the function accepts the requisite number of arguments.

    (map (fn [x y z] (apply + x y z))
         '(1 2 3)
         '(4 5 6)
         '(7 8 9))
    

    Contrived example, but should illustrate the point.

  • Custom User Avatar

    I'm a clojure newbie. So, in clojure it doesn't matter if the type is sequence or vector as long as they can be used the same, right?

  • Custom User Avatar
    (let [digitize (fn [n] (map #(Character/digit % 10) (str n))
          ...]
          ...)
    

    with this you can even stop it from being a function an just express it directly

    (let  [ns (map #(Character/digit % 10) (str n))
           sum (reduce + (map Math/pow ns ...))]
        ...)
    
  • Custom User Avatar

    Seeing same thing on Clojure side

  • Custom User Avatar

    Thanks for looking into this, Abbe. I'm no longer seeing this problem.

  • Custom User Avatar

    I looked through the test cases and I can't see how the combinations you list could appear.

    I guess you found them during the first batch of random test cases, but there the first parameter to is-merge is always either "Can we merge it? Yes, we can!" or "Can we merge it? No, we can't".

    I even ran through the test cases 10 times to see if I could recreate the problem, but it seems to work fine for me.

    Could it have been a temporary hiccup on the servers?

    Please try again and let me know if you still see the same problem.

  • Custom User Avatar

    It does look strange, indeed. I'll try to look into it later today.

    Thanks for pointing it out. :-)

  • Custom User Avatar

    I'm not sure if I'm missing something, or there's a problem with the generated test cases. Here are a few generated test case inputs that look to be expecting "true".

    (is-merge "mrg it? Ys, can!" "rei? Yes, a" "mg tcn!")
    (is-merge "it? Yes, wcn!" "t? s, cn" "iYewe !")

    I would expect these to return "false", but maybe I'm not understanding something...

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Maybe you are calculating a bunch of Fibonacci's numbers?

    Nah, he's calculating the number of kittens. Seriously, some of your comments are completely off :D. But for those, who're interested, g964 means "Do you memoize the whole Fibonacci tree? That takes too much memory. There's an approach that takes O(log n) operations to get the nth Fibonacci number, which should help you to finish in time."

  • Custom User Avatar

    Maybe you are calculating a bunch of Fibonacci's numbers?

  • Custom User Avatar

    If so, do the non-JVM versions of this kata have similar restrictions?

    Kind of. There's definitely a limit in Haskell, Python and Javascript, although I'm not certain of the actual numbers.

  • Custom User Avatar

    Speaking on the Clojure version of this kata, I'm having problems getting this test to pass for large n. Locally, my tests pass without running out of heap.

    I created a test for n=77911, and the test passes no problem locally, but I'm met with a "java.lang.OutOfMemoryError: Java heap space" when running on codewars.

    Could this have something to do with how the JVM is configured? If so, do the non-JVM versions of this kata have similar restrictions?

  • Custom User Avatar

    @g964: does it makes sense to update the Instructions with this information?

  • Custom User Avatar

    I don't see why you got "expected fractions" with denominator 136240, the "expected result" is with a denominator of 34060.
    Aren't you confused between "expected" and "actual"?
    Read the post from jacobono below. Seems you have lots of problems with my kata these days!:-)

  • Loading more items...