Advertisement
MiroJoseph

Meeting

Apr 5th, 2020
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.86 KB | None | 0 0
  1. My:
  2. import scala.collection.mutable.ListBuffer
  3. object Meeting {
  4.  
  5. def meeting(s: String): String = {
  6.   var splited = s.split(';').toList
  7.   var l:ListBuffer[String]=new ListBuffer[String]
  8.  
  9.   def splitting(NS: List[String]): List[String] = {
  10.     if (NS.nonEmpty) {
  11.       l.append(("("+NS.head.split(':')(1)+", "+NS.head.split(':')(0)+")").toUpperCase())
  12.       splitting(NS.tail)
  13.       }
  14.     else l.sorted.toList
  15.   }
  16.   def print(d:List[String], str:String):String={
  17.     if (d.nonEmpty)  print(d.tail, str+d.head)
  18.     else str
  19.   }
  20.   print(splitting(splited), "")
  21. }
  22. }
  23.  
  24. Other:
  25. object Meeting {
  26.  
  27.   def meeting(s: String): String = {
  28.     val u: Array[String] = s.toUpperCase().split(";")
  29.     val v = u.map((x) => x.split(":")).map { case Array(f1,f2) => (f2,f1) }
  30.     v.sortBy(r => (r._1, r._2)).map(r => "(" + r._1 + ", " + r._2 + ")").mkString("")
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement