File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed
Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,14 @@ export default function solve(input: string) {
55 const designs = bottom . split ( "\n" ) ;
66 let possibleCount = 0 ;
77 const isPossibleRegExp = new RegExp ( `^(?:${ patterns . join ( "|" ) } )+$` ) ;
8+ const patternsSet = new Set ( patterns ) ;
89 for ( const design of designs ) {
910 if ( ! isPossibleRegExp . test ( design ) ) continue ;
1011 const counts = Array . from ( { length : design . length + 1 } , ( ) => 0 ) ;
1112 counts [ 0 ] = 1 ;
1213 for ( let j = 1 ; j <= design . length ; j ++ ) {
1314 for ( let i = Math . max ( 0 , j - maxPatternLength ) ; i < j ; i ++ ) {
14- if ( patterns . includes ( design . slice ( i , j ) ) ) counts [ j ] += counts [ i ] ;
15+ if ( patternsSet . has ( design . slice ( i , j ) ) ) counts [ j ] += counts [ i ] ;
1516 }
1617 }
1718 possibleCount += counts . at ( - 1 ) ! ;
You can’t perform that action at this time.
0 commit comments