Plotter

Report a typo

Scally wants to output a set of numeric data in a fancy way by printing it with bars made of hash # symbols. In this format, 5 will be printed as #####. She started the program: can you finish it?

Note that we can print non-negative numbers only.

Sample Input 1:

-1 1 2 3 5

Sample Output 1:

#
##
###
#####
Write a program in Scala 3
object Plotter extends App {

def buildLine(length: Int, line: String): String =
if (length == 0) ??? else ???

val input = scala.io.StdIn.readLine()
val digits: List[Int] = input.split(' ').map(s => s.toInt).filter(???)
val output: List[String] = digits.map { ??? }

println(output.mkString("\n"))
}
___

Create a free account to access the full topic