Skip to content

Instantly share code, notes, and snippets.

@syntacticsugar
Created March 11, 2020 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syntacticsugar/ea8e9e794f1c56a7ddc80da6cf8ceabd to your computer and use it in GitHub Desktop.
Save syntacticsugar/ea8e9e794f1c56a7ddc80da6cf8ceabd to your computer and use it in GitHub Desktop.
Codewars Javascript
/*
Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alpahabet except "aeiou".
We shall assign the following values: a = 1, b = 2, c = 3, .... z = 26.
For example, for the word "zodiacs", let's cross out the vowels. We get: "z o d ia cs"
-- The consonant substrings are: "z", "d" and "cs" and the values are z = 26, d = 4 and cs = 3 + 19 = 22. The highest is 26.
solve("zodiacs") = 26
For the word "strength", solve("strength") = 57
-- The consonant substrings are: "str" and "ngth" with values "str" = 19 + 20 + 18 = 57 and "ngth" = 14 + 7 + 20 + 8 = 49. The highest is 57.
For C: do not mutate input.
More examples in test cases. Good luck!
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment