Skip to content

Instantly share code, notes, and snippets.

@Brunya
Created February 22, 2021 08:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Brunya/bf624023b9310b016feaf26de31b516f to your computer and use it in GitHub Desktop.
Save Brunya/bf624023b9310b016feaf26de31b516f to your computer and use it in GitHub Desktop.
Rust coding test

Rust coding test

The motivation behind the coding test is the measurement of the qualification and testing the learning attitude of the candidate.

Task

Create a pseudorandom number generator based on Linear Congruential Generator algorithm. Pick one and use any of the following languages, and please do NOT use any library you can find on the internet.

  • C
  • C++
  • Rust

Requirements

This should be a sandalone library with a single public function. The function should be the following (Note: The function definition doesn't follow any language syntax):

Rand(min int, max int) int

This function accept two integer az input parameters and returns one output. This should determine the range I want to generate random number.

Test scenarios:

min=1; max=200 => should generate a number between 1 and 200
min=1000; max=9999 => should generate a number between 1000 and 9999

Validate when the max is smaller than min. Validate the possible integer overflow.

Links

Algorithm of LCG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment