pythonlistrandom

Python List of random number with difference of 2 between them


list of random numbers between 0 to 100, with every succeeding number having a difference of 2 between them.


Solution

  • You have an Explanation here: Create random sequence of integers within a range and with a minimum distance between them

    Just modify these parameters to match your case:

    n = 5
    limit = 20
    mingap = 3
    slack = 20 - mingap * (n - 1)