Skip to content

Instantly share code, notes, and snippets.

@KoStard
Created April 11, 2018 09:53
Show Gist options
  • Save KoStard/0c0d2ec5f0a38b427e215bb51b508897 to your computer and use it in GitHub Desktop.
Save KoStard/0c0d2ec5f0a38b427e215bb51b508897 to your computer and use it in GitHub Desktop.
Task84 of UniLecs Telegram
function get_factorial(num){
res = 1;
for (i = 1; i <= num; i++){
res *= i;
}
return res;
}
function task84 (word){
res = get_factorial(word.length);
chars = {};
for (i = 0; i < word.length; i++){
if (chars[word[i]] == undefined){
chars[word[i]] = 1;
}else{
chars[word[i]] += 1;
}
}
for (i = 0; i < word.length; i++){
if (chars[word[i]]>1){
res/=get_factorial(chars[word[i]])
chars[word[i]] = 0
}
}
return res;
}
console.log(
task84(
"solo"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment