Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Elegant. Well done.
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.
My solution can be made to run slightly faster by eliminating the "puts n" statement, which was intended only for dev/debugging.
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
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.
Much respect to whoever submits a more performant solution to this challenge.
I'd love to see how you did it.
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.
Runtime crash on get_middle("").
Brevity is nice. But no runtime error on get_middle("") is nicer.
Munto, your method fails the following obvious test case:
test(['n', 'n', 'n', 'n', 'e', 'e', 'n', 's', 'e', 'w'], false)
This comment is hidden because it contains spoiler information about the solution