Skip to content

Instantly share code, notes, and snippets.

@stsatlantis
Last active December 5, 2015 11:22
Show Gist options
  • Save stsatlantis/e1c5653e0c565d4c78d4 to your computer and use it in GitHub Desktop.
Save stsatlantis/e1c5653e0c565d4c78d4 to your computer and use it in GitHub Desktop.
def task1(str: String): Boolean = {
val vowelR = """[a,e,i,o,u]"""
@tailrec
def processTask1(arr: List[String], prevChar: String, vowelCount: Int, hasDouble: Boolean): Boolean = {
arr match {
case Nil => vowelCount >= 3 && hasDouble;
case "a" :: "b" :: xs => false
case "c" :: "d" :: xs => false
case "p" :: "q" :: xs => false
case "x" :: "y" :: xs => false
case c :: xs => processTask1(xs, c, vowelCount + (if (c.matches(vowelR)) 1 else 0), hasDouble || c == prevChar)
}
}
processTask1(str.split("").toList, "", 0, hasDouble = false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment