Optimized puzzle solver