Created
July 1, 2014 20:01
-
-
Save irrationalistic/cb19eea1859c9079c12b to your computer and use it in GitHub Desktop.
Get the word with the highest character repetition
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
var getReps = function(str){ | |
return _.chain(str.split(' ')) | |
.map(function(w){ | |
return { | |
word: w, | |
reps: _.chain(w.toUpperCase().split('')) | |
.groupBy(_.identity) | |
.max(function(g){ | |
return g.length; | |
}) | |
.value() | |
.length; | |
}; | |
}) | |
.max(function(w){ | |
return w.reps; | |
}) | |
.value() | |
.word; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment