Avoiding explosive search in automatic selection of simplest pattern codes