Finding a pattern which separates two sets is a critical task in discovery. Given two sets of strings, consider the problem
to find a subsequence that is common to one set but never appears in the other set. The problem is known to be NP-complete.
Episode pattern is a generalized concept of subsequence pattern where the length of substring containing the subsequence is
bounded. We generalize these problems to optimization problems, and give practical algorithms to solve them exactly. Our algorithms
utilize some pruning heuristics based on the combinatorial properties of strings, and efficient data structures which recognize
subsequence and episode patterns.