Last active
May 14, 2022 08:22
-
-
Save nikonov91-dev/1f09d23a0b87a025a5771451ee7bb1ba to your computer and use it in GitHub Desktop.
vocabulary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translate(speech: string, vocabulary: string[]): string { | |
const candidates = speech.matchAll(/[\*|\w]+/g); | |
for (let c of candidates) { | |
} | |
const sortedByAsteriskAmmount = [...candidates].sort((p,n) => { | |
const pAstr = [...p[0].matchAll(/\*/g)].length; | |
const nAstr = [...n[0].matchAll(/\*/g)].length; | |
return pAstr === nAstr ? 0 : (pAstr > nAstr ? 1 : -1) | |
}) | |
console.log(sortedByAsteriskAmmount); | |
return '' | |
} | |
translate("ac*? *c*. **e, abcd***", ["ace","acd","abd","abcdabc"]) | |
https://www.codewars.com/kata/615b636c3f8bcf0038ae8e8b/train/typescript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment