Reverse

Report a typo

Scally is writing a program that outputs words in a sentence in the reverse order: it transforms high blue skies to skies blue high. It is expected that the words contain only letters and are separated by space. Help Scally finish the program!

Sample Input 1:

high blue skies

Sample Output 1:

skies blue high
Write a program in Scala 3
object WordsReverser extends App {
val input = scala.io.StdIn.readLine()
val result = input.reverse.split(???).map(w => w.reverse).mkString(???)
println(result)
}
___

Create a free account to access the full topic