11
votes
3answers
6k views

Generating a random alphanumeric string succinctly and efficiently

I want to generate a random alphanumeric string in ruby, as succinctly and efficiently as possible. The following solution works, but is obviously not very efficient. Please review the following ...
5
votes
2answers
46 views

Generate random 10% of file to be used in testing with ruby

I'm new to ruby, but not to programming. I just need a simple script that given a text file will pull out around 10% of the lines at random. Below is what I came up with based upon a python script I ...
2
votes
2answers
414 views

rand number generator with limits in ruby

I have an array of 1000 numbers, randomly generated. 10 of those numbers must be between 0-9 (including 0 and 9), and 10 of those numbers must be between 991 and 1000 (including 991 and 1000). This is ...
3
votes
3answers
1k views

Most efficient way to iterate through arrays/can I use .times method in place of while method?

I created a quick program to test the precision of randomness generated by the .rand method. The primary question is whether I can use the ...