How would I make a program generate x amount of integers from the range of 1 through 100 and than store those using arrays and/or hashes.
Histogram random number
Page 1 of 16 Replies - 892 Views - Last Post: 12 February 2013 - 03:45 AM
Replies To: Histogram random number
#2
Re: Histogram random number
Posted 01 February 2013 - 11:54 AM
What have you tried? Do you have any code? The box you typed that in asks you to show us what you've worked on so far because we won't do homework for you.
#3
Re: Histogram random number
Posted 01 February 2013 - 11:39 PM
Look into ranges, random, and the Enumerable module.
#4
Re: Histogram random number
Posted 04 February 2013 - 10:39 AM
This is what I have so far. But Is there a way I can order these in 1-10 all the way up to 91-100 doing an if statement?
Please and thanks for the understanding.
Please and thanks for the understanding.
histogram = array.new(10, 0) for i in 1..200 num = 1 + rand(100) histogram[(num/10).ceil-1]+= 1 end puts "Range # " + "Found " + "Chart"
#5
Re: Histogram random number
Posted 04 February 2013 - 07:22 PM
#6
Re: Histogram random number
Posted 12 February 2013 - 03:28 AM
Hello, I am not 100 percent what you want here but looking at previous answer maybe something like this?
histogram = [] for i in 1..200 num = 1 + rand(100) histogram << num end
#7
Re: Histogram random number
Posted 12 February 2013 - 03:45 AM
Sorry accidentally posted before I had finished typing:
That would create an list of 200 numbers between 1-100, I am not quite sure what you want to do though can you explain more?
group_by
Maybe this page will help?
That would create an list of 200 numbers between 1-100, I am not quite sure what you want to do though can you explain more?
group_by
Maybe this page will help?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|