Change 10271 algorithm to from longest to shortest