This comment is reply for 4382 shinh: それなりに速く終わるやつを。手元で1秒切...(正しい文(クイズ)). Go to thread root.
RC3 #5741(2008/02/12 00:48 GMT) [ JavaScript ] Rating0/0=0.00
#4382をprototype.jsを用いて写経しました。 ・申し訳ないんですが、IE6でしか動いてません。 FireFox2では、new Array(b).map・・・の動きがいまいちです。 ・かつ、ひじょ~に遅くなりました。 map、max、min、entries、anyがprototype.jsです。
see: prototype.js ver 1.6.0 リファレンス
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<html> <head> <script type="text/javascript" src="../../prototype-1.6.0.2.js"></script> <script type="text/javascript"> function x(b, a, n, e, z) { if(b == n) { if(a.toString() == e.toString()) document.write(new Array(b).map(function(v, i){return i.toString(b)+'*'+a[i].toString(b);})+'<br />'); } else { var m = b<5 ? 5 : [n>1 ? [4-n,0].max()+e[n] : 99, b+2-z+n].min(); for(var i = 1; i <= m; i++) { a[n] = i; f = e.entries(); i.toString(b).toArray().map(function(v){f[parseInt(v, b)]++;}); if(new Array(n).any(function(v, j){return f[j] > a[j];})) continue; x(b, a, n+1, f, z+i); } } } for(var b = 2; b <= 16; b++) { document.write(b + '<br />'); var a = new Array(b).map(function(v,i){return 0;}); // 要素数b・初期値0の配列 var e = new Array(b).map(function(v,i){return 1;}); // 要素数b・初期値1の配列 x(b, a, 0, e, 0); } </script> </head> <body> </body> </html>
Rating0/0=0.00-0+
[ reply ]
RC3
#5741()
[
JavaScript
]
Rating0/0=0.00
see: prototype.js ver 1.6.0 リファレンス
Rating0/0=0.00-0+