File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,18 @@ export function compile (code: string): number {
10
10
ans += + ( outside ) * + ( instruction === '+' )
11
11
ans -= 1 * + ( outside ) * + ( instruction === '-' )
12
12
ans *= [ 1 , 2 ] [ + ( outside ) * + ( instruction === '*' ) ]
13
- last = [ last , index ] [ + ( outside ) * + ( instruction === '%' ) ]
13
+ if ( instruction === '%' ) {
14
+ last = [ last , index ] [ + ( inside === null || inside ) ]
15
+ } else if ( instruction === '<' ) {
16
+ instructions [ index ] = ' '
17
+ index = [ last - 1 , index - 1 ] [ + ( last === - 1 ) ]
18
+ }
14
19
const a = + ( instruction === '¿' )
15
20
const b = + ( ans > 0 )
16
21
const c = + ( instruction === '?' )
17
22
inside = [ inside , null , true , false ] [
18
23
2 * a + c + ( 1 - b ) * ( 1 - c ) * ( a + b )
19
24
]
20
- const prev = index
21
- index = [ index , last - 1 ] [ + ( last !== - 1 ) * + ( instructions [ index ] === '<' ) ]
22
- instructions [ prev ] = [ instructions [ index ] , ' ' ] [ + ( instruction === '<' ) ]
23
25
index ++
24
26
}
25
27
return ans
You can’t perform that action at this time.
0 commit comments