Skip to content

Instantly share code, notes, and snippets.

View marcusmonteiro's full-sized avatar

Marcus Vinicius Monteiro de Souza marcusmonteiro

View GitHub Profile
def sentenceAnagrams(sentence: Sentence): List[Sentence] = {
def subSentence(occ: Occurrences): List[Sentence] = {
if (occ.isEmpty) List(List())
else
for {
x <- combinations(occ)
y <- dictionaryByOccurrences(x)
z <- subSentence(subtract(occ, x))
} yield y :: z
@supki
supki / pemis.scala
Created October 23, 2012 22:13
Functional programming course at Coursera week 6.
package forcomp
import common._
object Anagrams {
type Word = String
type Sentence = List[Word]
def countChange(money: Int, coins: List[Int]): Int =
if (money < 0 || coins.isEmpty)
0
else if (money == 0)
1
else
countChange(money - coins.head, coins) + countChange(money, coins.tail)
@DTrejo
DTrejo / .gitignore
Created April 4, 2011 03:32
How to Readline - an example and the beginnings of the docs
node_modules/