6 kyu
Exclamation marks series #15: Replace the pair of exclamation marks and question marks to spaces
82 of 153myjinxin2015
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Nice kata.
Nice one of the series, congratulations.
Minus for the fact that the kata does not provide for checking other answer options, subject to the input conditions. For example '! ?? 'wrong, eh'!?? ' right. We have to guess by what scheme the author decided.
This comment has been hidden.
because each consecutive
!
and?
respectively are seen as a group, so the group above for1!
and2?
do not match.Confused by this one. From the hardcoded tests:
Why wouldn't the last two ?? pairs also be removed?
There are 5 runs of question marks with a length of two, as demonstrated by the marks in your example:
To remove a run of question marks of a given length, there needs to be a corresponding run of exclamation marks with the same length. Here are all runs of exclamation marks with length 2. As you can see, there are 3 of them.
I hope this helps. I found this one difficult to follow also.
This comment has been hidden.
OP solved it, closing
Two people asked this question and I also had trouble figuring this out. You should probably state that "pairs" don't need to be adjacent. Calling it a pair implies (at least to me) that it's one contiguous substring of the input so it would be worth pointing out.
I am confused about one of the tests,
replace("!????!!!?") === " ????!!! "
, why are the first and last being paired when they should still be grouped up???because you cannot split a sequence of
!
or?
Yeah, that's how it should be, but there are spaces for the solution... which confuses me about the nature of the challenge! The solution should be
"!????!!!?"
Forget it, there was someone else with the same question, which I should've checked first, that reply on the top was not helpful nor on topic to the question, please understand the question before "resolving" the issue please =-=!
missing fixed tests:
replace("!!?!!?!!?!!?!!!??!!!??!!!??") => " ? ? ?!!?!!! !!! !!! "
replace("??!??!??!??!???!!???!!???!!") => " ! ! !??!??? ??? ??? "
?
replace("?!!?!!?!!?!!!??!!!??!!!??!!!??!!!??") => "? ? ? ?!!! !!! !!! !!!??!!!??"
edit: the note at the end of the description should be removed too
You just couldn't insert these tests as code block to preserve formatting, right?
Added.
Funtastic kata;-)
Python translation. Please, review and approve.
Should
"!?!"
become" !"
or"! "
? (edit: that's two spaces each, codewars just sucks there)The result should be
" !"
. Added(from the left to the right)
to the description. AddedTest.assertSimilar(replace("!?!") , " !")
to the basic teses. Thanks for your feedback ;-)The instructions need to be more clear. Why wouldn't the result be this: replace("!!!????") === " ?"
because ! has 3 but ? has 4. they are not equal.
Yes, but ! has 3 and ! has 3 (with one left over). So it would be helpful if the instructions explained that you can not separate the groups.
now I am using a cellphone. It's hardly to modify the description. I'll do it later. Thanks ;-)
Added some comments in the example part:
There's typo in tag: funcdamentals instead of fundamentals.
OK, fixed, Thanks ;-)
Why is replace("!????!!!?") === " ????!!! " (left and right with space), there are no valid pairs?
the first "!" and the last "?" is a pair, replace them to spaces. isn't it?
ah ok, thought only direct neighbors;-)
just forgot to mark it as resolved...