dachev / sudoku

Sudoku generator and solver for node.js
146 stars 44 forks source link

Modify shuffleArray() to provide uniform sampling. (Related to #10) #11

Closed Radcliffe closed 4 years ago

Radcliffe commented 4 years ago

The original shuffleArray function was not uniform. This can be proved by noting that there are n-1 choices at each of the n positions of the array, but (n-1)^n is not divisible by n! (n factorial). The new proposed function should produce every permutation with equal probability.

dachev commented 4 years ago

@Radcliffe Thank you for your contribution! Much appreciated. I'll take you to the Happy Gnome for a few beers when I come back to Minnesota one day.