diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-10-20 03:10:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-20 03:10:33 +0100 |
| commit | edba31dd7fe5da49a163b2cb45b549ca6d3dd40d (patch) | |
| tree | ba28cf55e98e15c6207ee1cc3b1c05f6287e8aa8 | |
| parent | ea1679a8089aee5428d436419689c48f7b0f9094 (diff) | |
| parent | 016c41bd4147ccda30131b0243197d10e6a50f5a (diff) | |
| download | perlweeklychallenge-club-edba31dd7fe5da49a163b2cb45b549ca6d3dd40d.tar.gz perlweeklychallenge-club-edba31dd7fe5da49a163b2cb45b549ca6d3dd40d.tar.bz2 perlweeklychallenge-club-edba31dd7fe5da49a163b2cb45b549ca6d3dd40d.zip | |
Merge pull request #2570 from frankivo/frankivo-challenge083
Challenge083 - Task #1
| -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 |
