Soluzione Febbraio 2003 di Kirash
Vedi tutte le pagine e le modifiche recenti o scarica i sorgenti nella pagina
= Soluzione Febbraio 2003 di Kirash
def histogram(*arg)
j = 0
height = arg.max
str = Array.new(arg.max, "")
while height.nonzero?
arg.each_index {|i|
(arg[i] >= height)? str[j]="#" : str[j]="\s"
}
str[j] += "\n"
j += 1
height -= 1
end
return str
end
test
bar_chart = histogram(2,4,5,8,4,3) print bar_chart
# # # ## #### ##### ###### ######