code for searching solution space via pruning and enumeration