Last active
December 5, 2015 11:22
-
-
Save stsatlantis/e1c5653e0c565d4c78d4 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
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