Ad
  • Custom User Avatar

    How many words out there have 5000 letters?

  • Custom User Avatar

    Added _ and 5 as separators to java, js and python tests (c# would need more work)

    Many incorrect solutions were invalidated (at least in python). Sorry guys...

  • Custom User Avatar

    It's definitiely clever, but it's not clear.

  • Custom User Avatar

    From description: "A string consists of lowercase latin letters, digits and symbols."

  • Custom User Avatar

    Of course! That would work. Even though it's not as cool as recursion, it tends to be more optimal for large n.

  • Custom User Avatar

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

  • Default User Avatar

    The description says:

    ... (a substring is for example 2:nnnnn or 1:hhh; it contains the prefix) ...

  • Default User Avatar

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

  • Custom User Avatar

    I got that, and I even agreed with you that I wouldn't use this in production as is. You seemed to have ignored the potential benefits I mentioned of doing it this way, but okay.

    And I was just explaining why I did it the way I did it.

  • Default User Avatar

    Tests are the same in all languages and 1989 guys passed the kata as you can see at the top of the page. There are no error in the tests.

  • Custom User Avatar

    "Signature" is not a commonly applied term for Ruby, nor is it as relevant than it is for, say, Java where type of input is considered before any method is called.
    Considering that most high-level languages like Ruby accept any type of input for their methods (not to mention Javascript functions accept any number of arguments whether they’re explicitly defined or not), in order for methods to effectively have signatures, they would have to be “manually” handled inside the methods themselves.

    I could argue that the .count method for Arrays have 3 signatures that accepts: no input (which returns the length of the array), an object (which returns the number of elements that match it), and a block (which is ran for each element and returns the number of true results). Likewise, my method has 4: no input (which returns nil), 1 input (which returns the sum of that string), 2 inputs (which compares their sums), and 3+ inputs (which always returns false – not an error like I mistakenly said before).

    Admittedly, it handles 3+ inputs poorly, and no, I wouldn’t use this in production as is. I could’ve made it def compare (a,b) so Ruby would automatically throw an error for any different number of inputs, but it really depends on how I want to use this function. Like I said before, some of what it currently does, like returning the sum of 1 string, may be desired.

    I don’t complete these challenges for production code use. I still like being clear, but I care more about being concise in these challenges. Anything that I use in production from here, no matter how nice or “prepped” I make the code, I still have to adjust for my specific needs. No matter what, there’s something I have to change for production use, meaning there’s nothing on this site I would use for production as is.

  • Custom User Avatar

    I'm not sure what you mean by "signature", but it's not part of the challenge to error handle every possible scenario. The function will compare 2 strings, and throw an error on 3 or more strings. On 1 string passed, it will return the sum for that string. All that might even be desired.

  • Custom User Avatar

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

  • Custom User Avatar

    Not quite. The first 2 strings' sums will be turned into a boolean before .reduce compares that result to a 3rd sum.

  • Custom User Avatar

    True: it just happen when I take a solution from a language to the other :)

  • Loading more items...