あみだくじ
Posted feedbacks - JavaScript
例によって replace をイテレータ代わりに。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | function doukaku103(amida){
var a = amida.replace(/\|/g, '').split('\n'), o = a.shift().split(' ');
var x = /-/g, f = function(t, i){ t = o[i], o[i] = o[i+1], o[i+1] = t };
for(var j = 0, l; l = a[j++];) l.replace(x, f);
return amida +'\n'+ o.join(' ');
}
(typeof confirm != 'undefined' ? confirm : typeof print != 'undefined' ? print :
function($){ typeof WSH == 'object' && WSH.echo($) })(doukaku103('\
A B C D E\n\
| | |-| |\n\
|-| | |-|\n\
| |-| |-|\n\
|-| |-| |\n\
|-| | | |'));
|

greentea #4476() Rating4/6=0.67
[ reply ]