Trim the Search Space Smartly
Fix one variable and search the rest.
Smaller Search, Same Answer
Sometimes brute force is just barely too slow. The fix is to shrink what you search without losing any correct answer. 🙂
Fix One Variable
A powerful trick is to fix one variable by looping over it, then solve the rest faster. You trade a full search for many small ones.
All lessons in this course
- Brute Force Is a Valid Strategy
- Enumerate with itertools
- Bitmask Subset Enumeration
- Trim the Search Space Smartly