Skip to content

Instantly share code, notes, and snippets.

@valtih1978
Forked from jkdeveyra/SentenceAnagram.scala
Last active August 29, 2015 14:03
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 valtih1978/5983b7620798beeda317 to your computer and use it in GitHub Desktop.
Save valtih1978/5983b7620798beeda317 to your computer and use it in GitHub Desktop.
small fix
//forked from https://gist.github.com/jkdeveyra/4030815
def sentenceAnagrams(sentence: Sentence): List[Sentence] = {
def subSentence(occ: Occurrences): List[Sentence] = {
if (occ.isEmpty) List(List())
else
for {
x <- combinations(occ)
y <- dictionaryByOccurrences.getOrElse(x, List())
z <- subSentence(subtract(occ, x))
} yield y :: z
}
subSentence(sentenceOccurrences(sentence))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment