[Sync Iteration] java/squeaky-clean/1

This commit is contained in:
exercism-solutions-syncer[bot] 2026-04-17 07:02:35 +00:00 committed by GitHub
parent f80fbca12e
commit fe09c7d626
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();
}
}