Ad
  • Custom User Avatar

    I agree. It's a shame. I really liked this problem.

  • Default User Avatar

    Elegant. Well done.

  • Custom User Avatar

    I saw a random test like this:
    solution('apples, pears\ngrapes\nbananas !\nbananas', ['!']) should equal 'apples, pears\ngrapes\nbananas'

    but if the comment ends with \n ...

    "!\nbananas" should be an empty comment followed by a new line containing "bananas"

  • Default User Avatar

    @steffan153

    Crystal translation does not appear to rstrip lines:

    solution("! oranges cherries\ncherries cherries cherries lemons\nwatermelons cherries lemons cherries pears , \nbananas . oranges ! pears pears\n^ bananas cherries lemons avocados #", ["'", "^", "#"])
    Expected: "! oranges cherries\ncherries cherries cherries lemons\nwatermelons cherries lemons cherries pears , \nbananas . oranges ! pears pears\n"
         got: nil
                                                                                                              ^^^^^^^^^
    

    reproducing: default code -> attempt -> ctrl+f " \n" (space followed by line terminator, without the quotes)

  • Default User Avatar

    edit: nvm I have no idea what I'm talking about

  • Custom User Avatar

    Where do you read leading spaces must be removed?

    Any whitespace at the end of the line should also be stripped out.

    Use markdown formatting when posting code, otherwise spaces are collapsed and we can't see what you wanted to show:

    solution("'\n# watermelons ,  , \noranges watermelons watermelons watermelons bananas\npears bananas pears lemons # ?", ["'", "@", ".", "-", "^"])
    Expected: "\n# watermelons ,  , \noranges watermelons watermelons watermelons bananas\npears bananas pears lemons # ?"
         got: "\n# watermelons ,  ,\noranges watermelons watermelons watermelons bananas\npears bananas pears lemons # ?"
    

    Which language are you talking about?

  • Default User Avatar

    Test cases are inconsistent. The spec states to strip leading and trailing whitespace. And yet:

    solution("'\n# watermelons , , \noranges watermelons watermelons watermelons bananas\npears bananas pears lemons # ?", ["'", "@", ".", "-", "^"])
    Expected: "\n# watermelons , , \noranges watermelons watermelons watermelons bananas\npears bananas pears lemons # ?"
    got: "\n# watermelons , ,\noranges watermelons watermelons watermelons bananas\npears bananas pears lemons # ?"

    The test case expects a string with trailing whitespace preserved, not stripped.

  • Default User Avatar

    My solution can be made to run slightly faster by eliminating the "puts n" statement, which was intended only for dev/debugging.

  • Default User Avatar

    You should write tests !

  • Custom User Avatar

    Yes, the kata specifically mentions 0 < str length < 1000

  • Default User Avatar

    500_000_000.times do
    next_bigger(12345678987654321_i64)
    end

    10 iterations of your code: 53.169s
    500_000_000 iterations of my code: 47.289s

  • Default User Avatar

    Some test cases are bad for this challenge in that they require outright violations the problem spec. Others have noted these test cases in past comments, so I won't list them here. The technical writing of the challenge details is of very poor quality. But hey, this site is free and you get what you pay for. Perhaps it's time to look around for a better coding challenge website.

  • Default User Avatar

    Much respect to whoever submits a more performant solution to this challenge.
    I'd love to see how you did it.

  • Default User Avatar

    This specification for this challenge has some issues.
    In particular, "this percent of loss increases of 0.5 percent at the end of every two months" is quite literally incorrect. It should read "this percent of loss increases of 0.5 percent at the beginning of every second month".
    I originally coded my solution according to the literal meaning of the problem description, but then had to use trial and error to figure out what the author really expected.
    Another issue is that "of" in the context of "increase(s) of 0.5 percent" normally indicates multiplication, not addition. I originally interpreted this as "increases at a rate of 0.5 percent",
    which complicated my trial and error analysis of the author's intended meaning.
    The really nice thing about this challenge, as written, is that it exposes students to the quality of technical writing that they should expect to encounter in the real world.

  • Default User Avatar

    That's true. But the Kata description clearly specifies the argument would not be an empty string.

  • Loading more items...