Implement 10271
Change 10271 algorithm to from longest to shortest
Use badness cache
Update comment
Update comment
Fix 10271