@@ -111,27 +111,43 @@ def parse_data(self, data: List[str]) -> Tuple[List[str], List[str]]:
111111 return towels .split (", " ), [row for row in seq .split ("\n " ) if row ]
112112
113113 def part1 (self , data : List [str ]) -> int :
114- """Solve part 1: Count possible sequences.
114+ """Count possible towel pattern sequences.
115+
116+ This method determines how many of the target sequences can be created using
117+ the available towel patterns. A sequence is possible if it can be formed by
118+ combining one or more of the available towel patterns in any order. The method
119+ uses a TowelSorter helper class to analyze each sequence and count those that
120+ are possible to create.
115121
116122 Args:
117- data (List[str]): Input data lines
123+ data (List[str]): Input data containing towel patterns and target sequences.
124+ First line has comma-separated patterns, followed by a blank line, then
125+ target sequences.
118126
119127 Returns:
120- int: Number of sequences that can be created with available patterns
128+ int: Number of sequences that can be created using the available towel patterns.
121129 """
122130 towels , seq = self .parse_data (data )
123131 towel_sorter = TowelSorter (towels , seq )
124132 return towel_sorter .part1 ()
125133
126134 def part2 (self , data : List [str ]) -> int :
127- """Solve part 2: Count total possible arrangements.
135+ """Sum all possible arrangement combinations across sequences.
136+
137+ This method calculates the total number of unique ways to arrange towels to match
138+ each target sequence. For each sequence, it counts how many different combinations
139+ of the available towel patterns can create that sequence. The final result is the
140+ sum of possible arrangements across all sequences, using dynamic programming to
141+ handle overlapping subproblems efficiently.
128142
129143 Args:
130- data (List[str]): Input data lines
144+ data (List[str]): Input data containing towel patterns and target sequences.
145+ First line has comma-separated patterns, followed by a blank line, then
146+ target sequences.
131147
132148 Returns:
133- int: Sum of possible arrangements for all sequences
149+ int: Total sum of possible arrangement combinations for all sequences.
134150 """
135151 towels , seq = self .parse_data (data )
136152 towel_sorter = TowelSorter (towels , seq )
137- return towel_sorter .part2 ()
153+ return towel_sorter .part2 ()
0 commit comments