public
Last active

Challenge #137 [Easy] String Transposition (http://redd.it/1m1jam)

  • Download Gist
StringTransposition.scala
Scala
1 2 3 4 5 6 7 8 9 10 11
package dailyprogrammer
 
import scala.io.Source
 
object StringTransposition extends App {
val words = Source.fromFile("D:/file.txt").getLines.toList.tail
val longestWord = words.maxBy(_.size)
val wordsTransposed = words.map(_.padTo(longestWord.size, ' ').toList).transpose
 
println(wordsTransposed.map(_.mkString).mkString("\n"))
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.