Skip to content

Instantly share code, notes, and snippets.

@suryapandian
Forked from Brunya/rust.md
Created March 18, 2021 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suryapandian/6f98a30d1f24a8b62e2ae1b914579c96 to your computer and use it in GitHub Desktop.
Save suryapandian/6f98a30d1f24a8b62e2ae1b914579c96 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