function shuffle(arr){ var len = arr.length; for(var i = 0;i<len -1;i++) { var idx = Math.floor(Math.random() * (len - 1)); console.log("idx",idx); var temp = arr[idx]; console.log("temp",temp); arr[idx] = arr[len - i - 1]; console.…
18.2 Write a method to shuffle a deck of cards. It must be a perfect shuffle—in other words, each of the 52! permutations of the deck has to be equally likely. Assume that you are given a random number generator which is perfect. 这道题让我们实现一个洗牌的算法,实际上洗…