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.
what's thrown me off was unbalance parentheses, eg high_and_low("4 5 29 54 4 0 -214 542 -64 1 -3 6 -6"), "542 -214") ... there are two closing parentheses. Why do all the asserts have this pattern?
empty string can not get -1, you can use
return "" if s ==""
in front of other code.This comment is hidden because it contains spoiler information about the solution
Whatever. I'm just imagining some SQL kata without any tests with quotes inside so that beginners don't get confused when their solutions fail. And the they make sites...
I hope I can keep the status quo...
My original title is "...from the end of sentence", not "... end of string".
You said that "Hi! Hi!" is two sentence, OK, I modify kata's title to "...from the end of string"
Now, you said that "" is a valid string, OK, I can add "please note input can be a empty string"
@cbira353(7 kyu) and @MatthewStevens(7 kyu) said:"hmmm. all test cases pass but when i submit, i get an error", but they don't know why. OK, I can told them: "Your code failed on s=''"(see comment above)...
Oh, no. I do not want to use more strange test to increase the user's confusion.
I hope my 8kyu kata is simple enough. Please let me keep the status quo ;-))))))
An empty string is a case or an arbitrary string not ending with '!'. If an empty string is not a valid input then I think it should be explicitly stated so.
It's not about removing the exclamation mark from
Hello!\n
, it's about keeping it. The answer definitely isHello!\n
, the point is that some Python regexp solutions do remove the exclamation mark in this case.for this kata, the question is:
can you remove a exclamation mark from the end of string?
since suic add empty string as input, question became to:
is this a empty string? + can you remove a exclamation mark from the end of string?
if we add 'Hello!\n' to the tests, question became to:
is this a empty string? + where is the end of string? + can you remove a exclamation mark from the end of string?
if we add other data type(number, array, etc..) to the tests, question became to:
is this a string? + is this a empty string? + where is the end of string? + can you remove a exclamation mark from the end of string?
Their diffculty are diffrent ;-)
Do you think it's better for a beginner to think their wrong solution is right? The right solution with regexps isn't more complicated but just different.
@suic,
Don't add more corner case, this is a beginner kata, no needed more complex situation ;-)
Aha, I see :-) Thank you very much again! This really helps!
your code failed at
s=""
;-)You can paste your code here, let me see ;-)
(please Mark it as having spoiler content)
Could your exercise possibly at least show what input causes user's code to crash?
I am not really sure how difficult would it be but for I beginner as myself it would be really appreciated :)
Frankly, my code passes the basic tests but I am getting same error as cbira353.
perhaps your code sometimes generate some invalid index, such as -1, null..
hmmm. all test cases pass but when i submit, i get an error
Time: 68ms Passed: 6 Failed: 0
Test Results:
Basic Tests (6 Passed, 0 Failed)
STDERR:
Traceback:
in
in remove
IndexError: string index out of range
Loading more items...