题解 | #求最小公倍数#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
var line=readline() line=line.split(';') //console.log(line) var reg=/^[ASWD]{1}[0-9]{1,}$/ var arr=[] var left=0 var right=0 for(let i=0;i<line.length;i++){ if(reg.test(line[i])){ // console.log(line[i]) arr.push(line[i]) } } for(let i=0;i<arr.length;i++){ if(/A/.test(arr[i])){ left-=parseInt(arr[i].match(/[0-9]{1,}/)) }else if(/D/.test(arr[i])){ left+=parseInt(arr[i].match(/[0-9]{1,}/)) }else if(/W/.test(arr[i])){ right+=parseInt(arr[i].match(/[0-9]{1,}/)) }else{ right-=parseInt(arr[i].match(/[0-9]{1,}/)) } } console.log(left+','+right)