wildcard-matching

iterative method
Really hard to understand