6 kyu
Exclamation marks series #12: Remove odd number continuous exclamation marks and question marks
193 of 353myjinxin2015
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.
The description is ambiguous as to where you should continue after removing one sequence. You could either start again at the beginning (removing everything strictly left to right) or you could continue from where you left off.
Examples:
"??!!!???"
could result in either""
or"??"
."?!!!???"
could result in either"????"
or"?"
.The kata requires the latter results.
Please update the description to include instructions of how to handle situations such as this or change the random tests that these ambiguous strings can't be generated.
python new test framework is required. updated in this fork
Approved
this does not belong in the description
Removed
It was some kind of horror, I thought for three days and created a huge monster function. I need to learn regular expressions 😅
If we're supposed to remove from left to right, then why is '!!!!!!!????!!!!!!!??????!?????????!!!!!!!!!???' expected to return '??????????!' ? Does "Remove odd number continuous exclamation marks and question marks(from the left to the right), until no continuous exclamation marks and question marks exist" mean continue down the entire string a full pass before starting over to check for any new odd runs of exclamation or question marks?
Nice Kata !
Ruby 3.0 should be enabled.
Enabled in this fork
Why is this wrong?
"!!!!!!!!!!??!!?????????!?????????!!!!!!!!!!"
→"!!!!!!!!!!??!!!?????????!!!!!!!!!!"
→"!!!!!!!!!!???????????!!!!!!!!!!"
→"!!!!!!!!!!!!!!!!!!!!"
It expects"!!!!!!!!!!??"
instead.I think it is :
!!!!!!!!!!??!!?????????!?????????!!!!!!!!!!
→!!!!!!!!!!??!!!!!!!!!!!!!
(because there are 9?
two times)!!!!!!!!!!??!!!!!!!!!!!!!
→!!!!!!!!!!??
(because there are 13!
)Why is
sol("!!!!")
not"!"
? I can remove"!!!"
, which is an odd number of continuous exclamation marks.Also, it's unclear what to do with for example
sol("!!!???!!")
:"!!!???!!"
→"???!!"
→"!!"
"!!!???!!"
→"!!!!!"
→""
About the first question, because you can't choose to ignore some
!
or?
to make them odd. An example where that's shown would be nice. If the other example exists as a test, then that's certainly ambiguous.The result of
"!!!???!!"
should be"!!"
. Added(from the left to the right)
to the description. AddedTest.assertSimilar(remove("!!!???!!") , "!!")
to the basic teses. Thanks for your feedback ;-)Ruby and Crystal translations :)
Approved, thanks ;-) You always release the translation when I sleep, so I always lose the game ;-)
Oh, come on! Drop the act!
With your productivity, I am pretty sure nobody believes anymore you are human and much less that you need to sleep ;)!
Cheers!
my mean is I need charge my battery sometimes ;-)
A T-800 base model is said to last 100 years before needing a change of battery: don't be too lazy and show us the real power of made in China :+1:
This comment has been hidden.
Good challange, interesting solutions, including monster regex patterns (at least in python :-)
Ah, I did that in JS, then opted to play for the easy one I thought initially in Python; pardon me for not going the other way around ;)
simpler regex works too... ! ;)
I would add some notes about how to do that: if you want to remove first all continous exclamation, then question mark, the other way around or all at once: right now the order of the operations is not meaningless.
Yes, I wasted a lot of time doing it in separate steps because I thought the description implied I should remove just exclamation points or just question marks, in repeated passes, until no further removals could be made. But it turns out to be impossible to reach the same solutions from some randomly generated inputs this way, regardless of the order in which you do it. For anyone similarly stumped, I don't feel it's a spoiler to make the necessary procedure explicit. Anything else can result in different solutions. You must go from left to right, removing all eligible (i.e., odd and greater than one in length) runs of both question marks and exclamation points in a single pass, ignoring any newly eligible runs created to the left of your "replacement position" until you have reached the end of the string, then repeat the process until there are no further changes to make.
This comment has been hidden.
Approved. Thanks
^_^