Advertisement
MiroJoseph

Count the smiley faces!

Apr 22nd, 2020
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.26 KB | None | 0 0
  1. My:
  2. object Kata {
  3.   def countSmileys(l: Vector[String]):Int={
  4.   l.map(x => x.replaceAll("[;:][~-]?[)D]", "T")).count(x => x == "T")
  5.   }
  6. }
  7.  
  8. Other:
  9. object Kata {
  10.   def countSmileys(strings: Vector[String]): Int =
  11.     strings.count(_.matches("[:;][-~]?[)D]"))
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement