Advertisement
MiroJoseph

Replace With Alphabet Position

Apr 22nd, 2020
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.30 KB | None | 0 0
  1. My:
  2. object Kata {
  3.   def alphabetPosition(text: String): String = {
  4.     text.toLowerCase.replaceAll("[^a-z]", "").toList.map(x=>x.toInt-96).mkString(" ")
  5.   }
  6. }
  7.  
  8. Other:
  9. object Kata {
  10.   def alphabetPosition(text: String): String =
  11.     text.filter(_.isLetter).map(_.toLower - 'a' + 1).mkString(" ")
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement