December 23 - How to Generate an Array of Random Numbers in Ruby
In this coding exercise I walk through a TDD process for implementing an Array generator that contains random numbers in a specific range.
Guide Tasks
- Read Tutorial
- Watch Guide Video
- Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license
Already a Bottega Student? Sign In
Summary
Generate an array of 20 random integers, with the integer values ranging from 1 to 1000.
Exercise Description
Write a program that automatically generates an array containing 20 random integers, ranging from 1 to 1000.
Sample Output
=> [695, 627, 849, 315, 203, 520, 433, 837, 923, 796, 6, 472, 964, 717, 549, 963, 787, 20, 589, 628]
Real World Usage
Being able to generate a set of random numbers is common in a number of different scenarios, including:
- Game development
- Creating test data
- Algorithm implementations