File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -9,19 +9,19 @@ tracer.set(D).delay();
99logger . print ( `original array = [${ D . join ( ', ' ) } ]` ) ;
1010const N = D . length ;
1111function flip ( start ) {
12- tracer . select ( start , N ) . delay ( ) ;
12+ tracer . select ( start , N - 1 ) . delay ( ) ;
1313 let idx = 0 ;
1414 for ( let i = start ; i < ( start + N ) / 2 ; i ++ ) {
1515 tracer . select ( i ) . delay ( ) ;
1616 const temp = D [ i ] ;
1717 D [ i ] = D [ N - idx - 1 ] ;
1818 D [ N - idx - 1 ] = temp ;
19- idx ++ ;
20- tracer . patch ( i , D [ i ] ) . patch ( N - idx , D [ N - idx ] ) . delay ( ) ;
21- tracer . depatch ( i ) . depatch ( N - idx ) ;
19+ tracer . patch ( i , D [ i ] ) . patch ( N - idx - 1 , D [ N - idx - 1 ] ) . delay ( ) ;
20+ tracer . depatch ( i ) . depatch ( N - idx - 1 ) ;
2221 tracer . deselect ( i ) ;
22+ idx ++ ;
2323 }
24- tracer . deselect ( start , N ) ;
24+ tracer . deselect ( start , N - 1 ) ;
2525}
2626for ( let i = 0 ; i < N - 1 ; i ++ ) {
2727 logger . print ( `round ${ i + 1 } ` ) ;
You can’t perform that action at this time.
0 commit comments