Modify the program below to output the statistics of the input text line: the number of characters, unique characters, and words.
Strings
Text statistics
Report a typo
Sample Input 1:
a b cSample Output 1:
characters: 5
unique characters: 4
words: 3Write a program in Scala 3
object TextReportPrinter extends App {
val textLine = scala.io.StdIn.readLine()
println {
s"""characters: ???
|unique characters: ${textLine.toSet???}
|words: ${if (???isEmpty) ??? else ???split("\\s")???}
|""".stripMargin
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.