毎日除雪で腕がぱんぱん、そして頭が回らず、だめだぁ〜こりゃ

http://oshiete.goo.ne.jp/qa/7954137.html

<!DOCTYPE html>
<title></title>
<meta charset="UTF-8">
<body>

<p id="result"></p>

<script type="application/javascript; version=1.8">

function fisherYates (a, b, c, d) a.concat (d.splice (Math.random () * (c + 1) |0, 1));
function fisherYates2 (a, b, c, d) { let r = Math.random () * (c + 1) | 0; [d[r], d[c]] = [d[c], d[r]]; return d; }


function random (a) a.slice (0).reduceRight (fisherYates, []);
function random2 (a) a.reduceRight (fisherYates, []);


function range (a, b) { while (a <= b) yield a++ };


document.querySelector ('#result').textContent =
  random ([x for each (x in range (1, 100))]).slice (0, 9).join ('/');

</script>
</body>

10%のデータのために、全体を並び替えするとか、効率悪いだろ。



その2

<!DOCTYPE html>
<title></title>
<meta charset="UTF-8">
<body>

<p id="result"></p>

<script type="application/javascript; version=1.8">

function range (a, b) { while (a <= b) yield a++ };
function loop (n) { while (n) yield n-- }


function randomGenerator (range) {
  var fisherYates =
    (function (a, b, c, d)
      a.concat (d.splice (Math.random () * (c + 1) |0, 1)));
  
  var random =
    (function (a)
      a.slice (0).reduceRight (fisherYates, []));
  
  var copy = [];
  
  while (true)
    if (copy.length)
      yield copy.shift ();
    else
      copy = random (range);
}

var num = randomGenerator ([x for each (x in range (1, 100))]);
var ary = [num.next () for each (x in loop (10))];

document.querySelector ('#result').textContent = ary.join ('/');

</script>
</body>


</script>
</body>


その3

<!DOCTYPE html>
<title></title>
<meta charset="UTF-8">
<body>

<p id="result"></p>

<script type="application/javascript; version=1.8">

function range (a, b) { while (a <= b) yield a++ };
function loop (n) { while (n) yield n-- }


function randomGenerator (range) {
  var copy = [];
  var len;
  
  while (true)
    if (len = copy.length)
      yield copy.splice (Math.random () * len |0, 1);
    else
      copy = range.slice (0);
}

var num = randomGenerator ([x for each (x in range (1, 100))]);
var ary = [num.next () for each (x in loop (10))];

document.querySelector ('#result').textContent = ary.join ('/');

</script>
</body>