-
-
Save Lysander6/6554121 to your computer and use it in GitHub Desktop.
Challenge #137 [Easy] String Transposition (http://redd.it/1m1jam)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment