slicesim icon indicating copy to clipboard operation
slicesim copied to clipboard

Code Review

Open task-master98 opened this issue 4 years ago • 0 comments

I am trying to understand the simulator code for a project. I am unable to figure out the logic for the get_random_slice_index() method in main.py. It contains the following piece of code:

def get_random_slice_index(vals):
    i = 0
    r = random.random()

    while vals[i] < r:
        i += 1
    return i  

I am unable to figure out the logic for the while loop condition. Kindly assist me in the same.

task-master98 avatar Feb 15 '21 10:02 task-master98