Merge pull request #80 from Weltenbummler397/exercism-sync/8bbb41f9ec460aed

[Sync Iteration] java/squeaky-clean/1
This commit is contained in:
Weltenbummler397 2026-05-04 09:57:13 +02:00 committed by GitHub
commit 04a6d08788
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,28 @@
class SqueakyClean {
static String clean(String identifier) {
StringBuilder result = new StringBuilder();
boolean toUpper = false;
String replace = identifier.replace(" ", "_")
.replace("4", "a")
.replace("3", "e")
.replace("0", "o")
.replace("1", "l")
.replace("7", "t");
for (char c : replace.toCharArray()){
if (!Character.isLetter(c) && c != '_' && c != '-') {
continue;
}
if (c == '-') {
toUpper = true;
} else {
if (toUpper) {
result.append(Character.toUpperCase(c));
toUpper = false;
} else {
result.append(c);
}
}
}
return result.toString();
}
}