diff options
| -rw-r--r-- | challenge-083/frankivo/WordsLength.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-083/frankivo/WordsLength.scala b/challenge-083/frankivo/WordsLength.scala new file mode 100644 index 0000000000..4888ca1439 --- /dev/null +++ b/challenge-083/frankivo/WordsLength.scala @@ -0,0 +1,20 @@ +object WordsLength {
+ val examples: Seq[String] = Seq(
+ "The Weekly Challenge",
+ "The purpose of our lives is to be happy"
+ )
+
+ def main(args: Array[String]): Unit = {
+ examples
+ .map(e => (e, count(e)))
+ .foreach(println)
+ }
+
+ def count(line: String) : Int = {
+ line.split(" ")
+ .drop(1)
+ .dropRight(1)
+ .mkString
+ .length
+ }
+}
\ No newline at end of file |
