@@ -33,54 +33,47 @@ function createZarr(concat) {
33
33
if ( i > right ) {
34
34
left = right = i ;
35
35
while ( right < N && concat [ right ] === concat [ right - left ] ) {
36
- concatTracer . patch ( right ) . delay ( ) ;
37
- concatTracer . select ( right - left ) . delay ( ) ;
38
- logger . print ( `${ concat [ right ] } ( at position ${ right } ) is equal to ${ concat [ right - left ] } (at position ${ right - left } )` ) ;
39
- concatTracer . depatch ( right ) . delay ( ) ;
40
- concatTracer . deselect ( right - left ) . delay ( ) ;
36
+ concatTracer . patch ( right ) . select ( right - left ) ;
37
+ logger . print ( `${ concat [ right ] } (at index ${ right } ) is equal to ${ concat [ right - left ] } (at index ${ right - left } )` ) . delay ( ) ;
38
+ concatTracer . depatch ( right ) . deselect ( right - left ) ;
41
39
right ++ ;
42
40
}
43
- concatTracer . patch ( right ) . delay ( ) ;
44
- concatTracer . select ( right - left ) . delay ( ) ;
45
- logger . print ( `${ concat [ right ] } ( at position ${ right } ) is NOT equal to ${ concat [ right - left ] } (at position ${ right - left } )` ) ;
46
- concatTracer . depatch ( right ) . delay ( ) ;
47
- concatTracer . deselect ( right - left ) . delay ( ) ;
41
+ if ( right < N ) {
42
+ concatTracer . patch ( right ) . select ( right - left ) ;
43
+ logger . print ( `${ concat [ right ] } (at index ${ right } ) is NOT equal to ${ concat [ right - left ] } (at index ${ right - left } )` ) . delay ( ) ;
44
+ concatTracer . depatch ( right ) . deselect ( right - left ) ;
45
+ }
48
46
z [ i ] = ( right - left ) ;
49
47
logger . print ( '--------------------------------' ) ;
50
48
logger . print ( `Value of z[${ i } ] = the length of the substring starting from ${ i } which is also the prefix of the concatinated string(=${ right - left } )` ) ;
51
49
logger . print ( '--------------------------------' ) ;
52
50
right -- ;
53
51
} else if ( z [ i - left ] < ( right - i + 1 ) ) {
54
52
logger . print ( `The substring from index ${ i - left } will not cross the right end.` ) ;
55
- concatTracer . select ( i - left ) . delay ( ) ;
56
- concatTracer . patch ( right - i + 1 ) . delay ( ) ;
53
+ concatTracer . patch ( right - i + 1 ) . select ( i - left ) . delay ( ) ;
57
54
z [ i ] = z [ i - left ] ;
58
- concatTracer . deselect ( i - left ) . delay ( ) ;
59
- concatTracer . depatch ( right - i + 1 ) . delay ( ) ;
55
+ concatTracer . depatch ( right - i + 1 ) . deselect ( i - left ) ;
60
56
} else {
61
57
logger . print ( `The substring from index ${ i - left } will cross the right end.` ) ;
62
58
left = i ;
63
59
while ( right < N && concat [ right ] === concat [ right - left ] ) {
64
- concatTracer . patch ( right ) . delay ( ) ;
65
- concatTracer . select ( right - left ) . delay ( ) ;
66
- logger . print ( `${ concat [ right ] } ( at position ${ right } ) is equal to ${ concat [ right - left ] } (at position ${ right - left } )` ) ;
67
- concatTracer . depatch ( right ) . delay ( ) ;
68
- concatTracer . deselect ( right - left ) . delay ( ) ;
60
+ concatTracer . patch ( right ) . select ( right - left ) ;
61
+ logger . print ( `${ concat [ right ] } (at index ${ right } ) is equal to ${ concat [ right - left ] } (at index ${ right - left } )` ) . delay ( ) ;
62
+ concatTracer . depatch ( right ) . deselect ( right - left ) ;
69
63
right ++ ;
70
64
}
71
- concatTracer . patch ( right ) . delay ( ) ;
72
- concatTracer . select ( right - left ) . delay ( ) ;
73
- logger . print ( `${ concat [ right ] } ( at position ${ right } ) is NOT equal to ${ concat [ right - left ] } (at position ${ right - left } )` ) ;
74
- concatTracer . depatch ( right ) . delay ( ) ;
75
- concatTracer . deselect ( right - left ) . delay ( ) ;
65
+ if ( right < N ) {
66
+ concatTracer . patch ( right ) . select ( right - left ) ;
67
+ logger . print ( `${ concat [ right ] } (at index ${ right } ) is NOT equal to ${ concat [ right - left ] } (at index ${ right - left } )` ) . delay ( ) ;
68
+ concatTracer . depatch ( right ) . deselect ( right - left ) ;
69
+ }
76
70
z [ i ] = ( right - left ) ;
77
71
right -- ;
78
72
logger . print ( '--------------------------------' ) ;
79
73
logger . print ( `Value of z[${ i } ] = the length of the substring starting from ${ i } which is also the prefix of the concatinated string(=${ right - left } )` ) ;
80
74
logger . print ( '--------------------------------' ) ;
81
75
}
82
- tracer . deselect ( i ) . delay ( ) ;
83
- tracer . set ( z ) ;
76
+ tracer . deselect ( i ) . set ( z ) ;
84
77
}
85
78
}
86
79
0 commit comments