Ad
  • Default User Avatar

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

  • Default User Avatar

    They are functionally the same. This answer was made when template literals weren't widespread yet, but today they'd be preferred since they help with readability.

  • Custom User Avatar

    Hey, @AncientGeek.

    There are no global variables in this solution (apart from the functions). The only symbols added to the global scope are the functions plus, minus, times, dividedBy, and zero throught nine. These are required to exist in order to pass the kata. :)

  • Custom User Avatar

    I'm not sure what you mean. Whatever it is, it was a coincidence, as ES2015 wasn't really a thing back when I did this (2013)!

  • Custom User Avatar

    Someone asked me to expand on my submission! Hope it's clearer.

  • Custom User Avatar

    The global scope. We're defining name ('zero', 'one', etc) on the same scope as the outer operations (plus, minus, times and dividedBy).

    In a browser, this would be equal to window.

  • Custom User Avatar

    Thanks!

  • Custom User Avatar

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

  • Custom User Avatar

    Ah! Need to be sneakier! :)

    ps. I just submitted a less obvious albeit somewhat longer solution.

  • Custom User Avatar

    This was pretty interesting, thanks for the challenge!

    That being said, I couldn't personally rank it at 1 kyu. It was quite difficult, but I come from Javascript and have only dealt with Ruby in a few very simple katas. If I hadn't to Google every bit of syntax, I wonder how much easier it'd be.. :P

    I find it odd, given Ruby's reputation of insane magic tricks, that a JS background could help so much.

    Am I'm just misguided, and they are actually very similar languages?

  • Custom User Avatar
    • I replaced it with {kata_id} because it happens in multiple katas. As far as I could tell (not an exhaustive test!), in any kata that I've already solved.

    • Yes.

      The first error is upon loading the {kata_id}/train/javascript page. That is a POST request that returns 200 OK, but with that error in the JSON. Result: the description loads, but the preloaded solution and test cases don't.

      The second one happens when I try to submit a solution in this state. The attempt goes to the undefined route, which succeeds. Later, the WebSocket connection receives the defer_response error.

    Also, I forgot to mention: resetting the solution does nothing.

  • Custom User Avatar

    That's related to the problem I mentioned in my comment.

    Date.now should never return 0. At least not until year 285,428,751, when javascript's 53-bit integers overflow.

  • Custom User Avatar

    "Train Again" stopped working for me some hours ago. I can no longer re-train katas.

    The request for {kata_id}/javascript/session yields the following error:

    Problem:
      Validation of UserCodeChallengeProject failed.
    Summary:
      The following errors were found: Languages is invalid
    Resolution:
      Try persisting the document with valid data or remove the validations.
    

    And any code submission goes to {kata_id}/undefined/attempt (yes, undefined), throwing this error:

    Problem:
      Calling Document.find with nil is invalid.
    Summary:
      Document.find expects the parameters to be 1 or more ids, and will return a single document if 1 id is provided, otherwise an array of documents if multiple ids are provided.
    Resolution:
      Most likely this is caused by passing parameters directly through to the find, and the parameter either is not present or the key from which it is accessed is incorrect."
    
  • Custom User Avatar

    That broke solutions that depend on certain Date properties, such as Date.now() returning a unix timestamp.

    Starting your mocked singleton at Date.now() instead of 0 should fix things.

  • Default User Avatar

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

  • Loading more items...