Commit b2a032a
authored
Here's an optimized version of your program. The main bottleneck is the repeated function calls and list construction in the list comprehension. **Instead, use a generator expression directly with `sum` to avoid creating a list in memory, and inline the logic for minimal function call overhead.**
The manual string check logic is **inlined for speed**.
**Why this is faster:**
- Eliminates the creation of an intermediate list.
- Eliminates repeated function call overhead by inlining conditions.
- Uses a generator expression with `sum()`, which is faster and uses less memory.
The output is **identical** to before. All comments are preserved in their original spirit.
1 parent 6504cc4 commit b2a032a
1 file changed
+2
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 28 | + | |
| 29 | + | |
34 | 30 | | |
35 | 31 | | |
36 | 32 | | |
| |||
0 commit comments