https://github.com/mtlh/censored-strings
https://edabit.com/challenge/Wv9ZeXyC32EMfRWGB My solution in various languages to this problem.
https://github.com/mtlh/censored-strings
censored-words coding-challenge language-processing
Last synced: 3 months ago
JSON representation
https://edabit.com/challenge/Wv9ZeXyC32EMfRWGB My solution in various languages to this problem.
- Host: GitHub
- URL: https://github.com/mtlh/censored-strings
- Owner: mtlh
- Created: 2020-08-24T08:22:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T10:45:03.000Z (over 4 years ago)
- Last Synced: 2025-01-03T04:47:03.831Z (5 months ago)
- Topics: censored-words, coding-challenge, language-processing
- Homepage: https://edabit.com/challenge/Wv9ZeXyC32EMfRWGB
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Censored Strings Challenge
https://edabit.com/challenge/Wv9ZeXyC32EMfRWGB My solution in various languages to this problem.## C++:
std::string uncensor(std::string str, std::string vowels) {
std::string res = "";
int cur = 0;
for(int i = 0; i < str.size(); i++) {
if(str[i] == '*') {
res += vowels[cur];
cur++;
}
else {
res+= str[i];
}
}
return res;
}## Python:
def uncensor(txt, vowels):
listTxt = list(txt)
listVowels = list(vowels)
vowelsCounter = 0
for x in range(len(listTxt)):
if listTxt[x] == "*":
listTxt[x] = listVowels[vowelsCounter]
vowelsCounter += 1result = ""
for x in listTxt:
result += x
return result## JavaScript:
function uncensor(str, vowels) {
var newString = ''
var vowelsCounter = 0
for(var i = 0; i < str.length; i ++){
if(str.charAt(i)==='*'){
newString += vowels[vowelsCounter]
vowelsCounter++
}
else{
newString += str.charAt(i)
}
}
return newString
}## Java:
public class Challenge {
public static String uncensor(String str, String vowels) {
String uncensored = "";
int vowelCounter = 0;
for (int i = 0; i < str.length(); i++) {
uncensored += (str.charAt(i) != '*' ? str.charAt(i) : vowels.charAt(vowelCounter++));
}
return uncensored;
}
}