Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ParanoidUser committed Aug 27, 2024
1 parent d9f80d2 commit 0c283a4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# [Exclamation marks series #4: Remove all exclamation marks from sentence but ensure a exclamation mark at the end of string](https://www.codewars.com/kata/exclamation-marks-series-number-4-remove-all-exclamation-marks-from-sentence-but-ensure-a-exclamation-mark-at-the-end-of-string "https://www.codewars.com/kata/57faf12b21c84b5ba30001b0")
# [Exclamation marks series #4: Remove all exclamation marks from sentence but ensure an exclamation mark at the end of string](https://www.codewars.com/kata/exclamation-marks-series-number-4-remove-all-exclamation-marks-from-sentence-but-ensure-a-exclamation-mark-at-the-end-of-string "https://www.codewars.com/kata/57faf12b21c84b5ba30001b0")

## Description:

Remove all exclamation marks from sentence but ensure a exclamation mark at the end of string. For a beginner kata, you can assume that the input data is always a non empty string, no need to verify it.
Remove all exclamation marks from sentence but ensure an exclamation mark at the end of string. For a beginner kata, you
can assume that the input data is always a non-empty string, no need to verify it.

## Examples

Expand All @@ -13,4 +14,4 @@ Remove all exclamation marks from sentence but ensure a exclamation mark at the
"!Hi!" ---> "Hi!"
"Hi! Hi!" ---> "Hi Hi!"
"Hi" ---> "Hi!"
```
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface Kata {
static String remove(String s) {
return s.replace("!", "") + "!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class KataTest {
@ParameterizedTest
@CsvSource(textBlock = """
Hi!, Hi!
Hi!!!, Hi!
!Hi, Hi!
!Hi!, Hi!
Hi! Hi!, Hi Hi!
Hi, Hi!
""")
void sample(String s, String expected) {
assertEquals(expected, Kata.remove(s));
}
}
1 change: 1 addition & 0 deletions kata/8-kyu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- [Enumerable Magic #1 - True for All?](enumerable-magic-number-1-true-for-all)
- [Enumerable Magic #25 - Take the First N Elements](enumerable-magic-number-25-take-the-first-n-elements)
- [Even or Odd](even-or-odd)
- [Exclamation marks series #4: Remove all exclamation marks from sentence but ensure an exclamation mark at the end of string](exclamation-marks-series-number-4-remove-all-exclamation-marks-from-sentence-but-ensure-a-exclamation-mark-at-the-end-of-string)
- [Exclamation marks series #11: Replace all vowel to exclamation mark in the sentence](exclamation-marks-series-number-11-replace-all-vowel-to-exclamation-mark-in-the-sentence)
- [Exclamation marks series #6: Remove n exclamation marks in the sentence from left to right](exclamation-marks-series-number-6-remove-n-exclamation-marks-in-the-sentence-from-left-to-right)
- [Exclusive "or" (xor) Logical Operator](exclusive-or-xor-logical-operator)
Expand Down

0 comments on commit 0c283a4

Please sign in to comment.