I have a code like this:
function luckyTickets(value: string): boolean {
let num = [...value+''];
let opr = ['*','+','/','-'];
for(let i = 0 ; i < 32 ; i ++ ){
let part = i . toString ( 2 )
. padStart ( 5 , '0')
. split ('')
. reduce (( s , v , i , a , j = ++ i )=>{
return + v ? \`${ s }${ num [ j ]}\`
: \`${ s }λ${ num [ j ]}\`;
}, num [ 0 ])
. replace (/(\D|^)0*(\d)/,'$1$2');
for(let i = 0 ; i < Math . pow ( 4 , part . split (/\D/). length - 1 ) ; i ++ ){
let mask = i . toString ( 4 ). padStart ( 5 ,'0');
let math = part
. replace ('λ', opr [ mask [ 4 ]])
. replace ('λ', opr [ mask [ 3 ]])
. replace ('λ', opr [ mask [ 2 ]])
. replace ('λ', opr [ mask [ 1 ]])
. replace ('λ', opr [ mask [ 0 ]])
let result = eval (\`(function(){return ${ math }})()\`);
if( result === 100 ){
return false
}
}
}
return true
}
It works in browser, BUT not work here.
Why???
HELP ME PLEASE
Created at: 2020/05/27 19:20; Updated at: 2020/07/08 17:18