Ad
  • Custom User Avatar

    Records can contain random errors, such as string corruption, misuse of specification format versions, and unspecified log levels

    Errors are arbitrary and the expected handling is undefined. It is only possible via repeatedly failing against the tests and guess what the author wanted.

  • Custom User Avatar

    There are no sample tests.

    There are no random tests either.

  • Custom User Avatar
  • Custom User Avatar

    That syntax... :O

  • Custom User Avatar

    Precomputations enabled by a small input domain are not cheats, they're optimisations.

    Newer JS versions have BigInt, which would allow for a larger input domain. That might actually solve this "problem". Scanning source code for patterns is a losing proposition.

  • Custom User Avatar

    IMO it depends. Javascript is a chimera. Maybe you want to mutate the object! But in a pure functional world this is a sin.

  • Custom User Avatar

    Nice one with the "pageItemCount". I've done with 3 ifs :-)

  • Default User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    man, i made my solution way extra longer. maybe i got intimidated by not knowing class/constructor Lol

  • Custom User Avatar

    Exactly what I thought. Multiplying by itself doesn't change number parity, so I think it might be a distraction.

  • Custom User Avatar

    wrapping all with a Math.abs() should do the trick

  • Custom User Avatar

    Alright, thanks, enjoyed that one! It was a nice practical programming challenge for a relative Clojure n00b—helped make me feel more like a real Clojure programmer! 😁

    The problems are that 1) It's a shame Clojurians don't have access to more advanced or interesting parsing libraries on CodeWars—Clojure has some fantastic options in this realm, so it's a real shame, and we don't even get the lovely spec library which starts from Clojure 1.9 😕, aaaand 2) It's quite hard honing in on the exact, specific interpretation of the data, as not only can you fail and parse less data than required, it's possible with regexes to rescue more correct data than is actually specified!

    Also, I'd like to submit some sample tests, but I think the idea for this kata is that you write them yourself, isn't it...? In that case, would you mind making that clear in the in-line comments?

    Thanks for the nice challenge!

  • Custom User Avatar

    I see that this kata is ideal for solving using clojure.spec, but unfortunately that core library isn't available in the Clojure 1.8 that Codewars supports! Hopefully there'll be an update soon. Nonetheless, I'm going to give this kata a fair go.

  • Custom User Avatar

    Isn't the pageIndex function wrong in case you ask for the last item at the end of the array (the item which equals to collection.length)?
    It's returning -1 instead of the page index that equals to the last page.
    This works because the test used in this kata doesn't check for the very last item of the array.

  • Loading more items...