Skip to content

Commit 725c4b8

Browse files
authored
squeaky-clean: add task to keep only letters (exercism#2130)
1 parent 1419cf8 commit 725c4b8

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

exercises/concept/squeaky-clean/.docs/hints.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
- See [this method][toupper] to convert a character to upper case.
1919

20-
## 4. Omit Greek lower case letters
20+
## 4. Omit characters that are not letters
21+
22+
- See [this method][isLetter] to check if a character is a letter.
23+
24+
## 5. Omit Greek lower case letters
2125

2226
- `char`s support the default equality and comparison operators.
2327

@@ -28,3 +32,4 @@
2832
[iswhitespace]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isWhitespace(char)
2933
[iscontrol]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isISOControl(char)
3034
[toupper]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#toUpperCase(char)
35+
[isLetter]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isLetter(char)

exercises/concept/squeaky-clean/.docs/instructions.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ SqueakyClean.clean("à-ḃç");
3535
// => "àḂç"
3636
```
3737

38-
## 4. Omit Greek lower case letters
38+
## 4. Omit characters that are not letters
39+
40+
Modify the (_static_) `SqueakyClean.clean()` method to omit any characters that are not letters.
41+
42+
```java
43+
SqueakyClean.clean("a1😀2😀3😀b");
44+
// => "ab"
45+
```
46+
47+
## 5. Omit Greek lower case letters
3948

4049
Modify the (_static_) `SqueakyClean.clean()` method to omit any Greek letters in the range 'α' to 'ω'.
4150

exercises/concept/squeaky-clean/src/test/java/SqueakyCleanTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public void string_with_no_letters() {
3939
assertThat(SqueakyClean.clean("\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00")).isEmpty();
4040
}
4141

42+
@Test
43+
public void keep_only_letters() {
44+
assertThat(SqueakyClean.clean("a1\uD83D\uDE002\uD83D\uDE003\uD83D\uDE00b")).isEqualTo("ab");
45+
}
46+
4247
@Test
4348
public void kebab_to_camel_case() {
4449
assertThat(SqueakyClean.clean("à-ḃç")).isEqualTo("àḂç");

0 commit comments

Comments
 (0)