Skip to content

Instantly share code, notes, and snippets.

@kblake
Created September 19, 2010 04:25
Show Gist options
  • Save kblake/586381 to your computer and use it in GitHub Desktop.
Save kblake/586381 to your computer and use it in GitHub Desktop.
num_array = [0,0,0,0,0,0,0,0,0,0]
#populate array
100.times do
random_num = rand(100) + 1
correct_index = (random_num == 100) ? 9 : random_num/10
num_array[correct_index] += 1
end
#print histrogram
for index in 0..9
puts "#{(index*10) + 1}-#{(index+1)*10} \t| #{'*' * num_array[index]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment