util.c
void shuffle(int* array, int length)
{
    int i=0;
    int r =0;
    for(i=0;i<length;i++)
    {
        r = randomInRange(0,i);
        swap(array,i,r);
    }
}
/**
 * Knuth shuffle.
 * swaps element at array[i] with number at array[random->0-i)
 * Taking random over whole range is wrong.
 * For example for 3 cards.
 * total permutation is 3!
 * Using random for full range possibilities are 3^3 =27
 * which will result in skewed result since 27%6 !=0
 */
Knuth shuffle.
swaps element at array[i] with number at array[random->0-i)
Taking random over whole range is wrong.
For example for 3 cards.
total permutation is 3.
Using random for full range possibilities are 3^3 =27
which will result in skewed result since 27%6 !=0
Knuth shuffle . swaps element at array [ i ] with number at array [ random - > 0 - i ) Taking random over whole range is wrong . For example for 3 cards . total permutation is 3 . Using random for full range possibilities are 3^3 = 27 which will result in skewed result since 27%6 ! = 0
void shuffle(int* array, int length)
{
    int i=0;
    int r =0;
    for(i=0;i<length;i++)
    {
        r = randomInRange(0,i);
        swap(array,i,r);
    }
}
void shuffle ( int * array , int length ) { int i = 0 ; int r = 0 ; for ( i = 0 ; i < length ; i ++ ) { r = randomInRange ( 0 , i ) ; swap ( array , i , r ) ; } }
Knuth shuffle.
Knuth shuffle .