January 12 - Build a Pseudo Random Number Generator that Follows a Specific Sequence
In this coding exercise you'll learn how to build a pseudo random number generator in Ruby that dynamically creates a set of random numbers based on a pre-defined sequence.
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
Build a program that outputs a specific set of random numbers.
Exercise Description
The program should take in an integer as an argument and each time it's called should generate the next number in an identical sequence.
Sample Use
Called the first time
i = pseudo_random 5 i.resume # 37 i.resume # 12 i.resume # 72 i.resume # 9 i.resume # 75
Called a second time
i = pseudo_random 5 i.resume # 37 i.resume # 12 i.resume # 72 i.resume # 9 i.resume # 75
Real World Usage
This exercise allows you to practice on a number of important development practices:
- Working with random numbers and overriding default randomness, this is key to building automated tests for processes that rely on random numbers.
- Implementing the ability for a program to maintain its state.