Created
November 7, 2016 21:35
-
-
Save naughty-code/ed5f3ecb7daec4bf679ea0c1a32d331f to your computer and use it in GitHub Desktop.
This file contains 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
/** Converts the word into its character occurrence list. | |
* | |
* Note: the uppercase and lowercase version of the character are treated as the | |
* same character, and are represented as a lowercase character in the occurrence list. | |
* | |
* Note: you must use `groupBy` to implement this method! | |
*/ | |
def wordOccurrences(w: Word): Occurrences = w.toLowerCase.groupBy(char => char).map{ | |
case (char, repetitions) => (char, repetitions.length) | |
}.toList.sortBy{ case (char, _) => char} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment