Ad
  • Custom User Avatar

    The description claims ordMax will only go up to 500, but in the actual run it can go up way further.
    You may wanna change the description.

  • Custom User Avatar

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

  • Custom User Avatar

    Nice!
    Btw, foldl1 (and foldr1) do the same as foldl but without a starting value.
    So 1 + foldl1 (mod . (k +)) [2 .. n] is equivalent.

  • Custom User Avatar

    'If "This is not about coding skills", it should not be in "codewars".'
    I disagree. Programming isn't only about coding skills. Making assertions about what the return of a function can look like is an important part of it.
    This kata forces you to either do a lot of unnecessary work or make clever assertions and make your life easy.
    But I agree that it shouldn't be 8 kyu.

  • Custom User Avatar

    Programming is a very wide field. Yes, you can do alot of programming without much math knowledge, but that is only because you are using a lot of libraries that do the math for you. Somebody has to write all these libraries and they need to know all this "useless math crap". So, please don't be ignorant and recognize the actual usefullness of these katas.
    If you don't want to dive into this sort of programming just skip those katas.

  • Custom User Avatar

    Stop showing off pls (:

  • Custom User Avatar

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

  • Custom User Avatar

    I just want to add, that it is NOT necessary to find the primefactors of each factor in the factorial. That is just slow to do that and doesn't scale very well.
    If we have [2..n] as the representation of the factorial and p a prime, we know that there are n/p (rounded down) numbers that singaly divide into p, n/p^2 numbers that doubaly divide into p and so on.
    So we just add up: n/p + n/p^2 + n/p^3 + n/p^4 ... until p^k is bigger than n, since then every term will be equal to 0.
    We do this for every p <= n and that's it.

  • Custom User Avatar

    I learned a lot about types in this kata, because I was forced to think about it more than I usually have to. Thanks, loooking forward to the next in this series.

  • Custom User Avatar

    sure thing. actually i found a couple of amazing solutions that i didn't think of. this website is awsome

  • Custom User Avatar

    You're welcome, recursion is a bit tricky until you get the hang of it. Now that you solved it without it, see other solutions that use recursion and analyze how they work.

  • Custom User Avatar

    you are right. i fixed my code using a while loop instead of recursion. it worked fine. thanks again for your time.

  • Custom User Avatar

    No problem, the answer to your problem was there too btw:

    Check if your solution passes two successive calls with different inputs. It's sometimes the case that solution contains some global variables or static members and stale state is carried over from one invocation to another.

  • Custom User Avatar
  • Custom User Avatar

    Already answered below.

  • Loading more items...