#!/usr/local/bin/node function twoval(use,e){ arr=[]; check=[]; val=[]; for(twovali of use){ for(twovalj of use){ for(twovalk of e){ arr.push(twovali+twovalk+twovalj); check.push(twovalk); val.push(eval(twovali+twovalk+twovalj)) } } } return arr; } /*----------------------*/ function maxcreate(maxuse,n){ return (maxuse==1) ? (n%2===0) ? Math.pow(2,n/2) : Math.pow(2,(n-3)/2)*3: Math.pow(maxuse,n) } /*----------------------*/ function numpos(str){ function isNumber(x){ if( typeof(x) != 'number' && typeof(x) != 'string' ) return false; else return (x == parseFloat(x) && isFinite(x)); } numposarr=[] numposarri=0 while(numposarri<=str.length){ if(isNumber(str.charAt(numposarri))){ numposa=i; while(isNumber(str.charAt(numposarri))){ numposarri++; } numposarr.push([numposa,numposarri-1]); } numposarri++; } return numposarr; } /*----------------------*/ function numpos(str){ function isNumber(x){ if( typeof(x) != 'number' && typeof(x) != 'string' ) return false; else return (x == parseFloat(x) && isFinite(x)); } numposarr=[] numposi=0 while(numposi<=str.length){ if(isNumber(str.charAt(numposi))){ numposa=numposi while(isNumber(str.charAt(numposi))){ numposi++ } numposarr.push([numposa,numposi-1]) } numposi++ } return numposarr } /*----------------------*/ function change(a,b,start,end){ return a.slice(0,start)+b+a.slice(end+1,a.length) } /*----------------------*/ function In(arr,x){ return arr.indexOf(x)!=-1 } /*----------------------*/ function bracketdelete(mathtext){ function change(a,b,n){ return a.slice(0, n-1)+b+a.slice(n, a.length); } function mojime(mathtext3,l){ return mathtext3.slice(l-1,l); } function hantaibracket(mathtext2,m){ var pos=m; var leftbracket=0; var rightbracket=0; while(leftbracket!=rightbracket||pos==m){ if(mojime(mathtext2,pos)=="("){ leftbracket+=1; } if(mojime(mathtext2,pos)==")"){ rightbracket+=1; } pos++; } return pos-1; } var Flag=1; while(Flag==1){ Flag=0; for(var i=1;i<=mathtext.length;i++){ if(mojime(mathtext,i)=="("){ hantai=hantaibracket(mathtext,i); if(mojime(mathtext,hantai+1)!="×" && mojime(mathtext,hantai+1)!="/" && mojime(mathtext,hantai+1)!="*" && mojime(mathtext,hantai+1)!="÷"){ if((mojime(mathtext,i-1)==" "||mojime(mathtext,i-1)=="+")){ mathtext=change(mathtext,"@",i); mathtext=change(mathtext,"@",hantai); Flag=1; } if((mojime(mathtext,i-1)=="-")){ for(var j=i+1;j<=hantai-1;j++){ if(mojime(mathtext,j)=="+"){ mathtext=change(mathtext,"-",j); continue; }else if(mojime(mathtext,j)=="-"){ mathtext=change(mathtext,"+",j); continue; }else if(mojime(mathtext,j)=="("){ j=hantaibracket(mathtext,j); } } mathtext=change(mathtext,"@",i); mathtext=change(mathtext,"@",hantai); Flag=1; } } } } mathtext=mathtext.replace( /@/g ,""); } return mathtext; } /*----------------------*/ function index(arr,n,key){ for(indexi of arr){ if(indexi[n]==key){ return indexi } } return -1; } /*----------------------*/ function indexpos(arr,n,key){ for(posi in arr){ if(arr[posi][n]==key){ return posi } } return -1; } /*----------------------*/ function numpos2(str){ pos2arr=[] pos2arr2=[] pos2pos=numpos(str) for (numpos2_i=0;numpos2_i Math.abs(target), ]; if(In(haijo,true)){ return 0; } for(Ei=1;Ei