wildcard-matching: attempt 3. dp alg, too slow