title: Two Dimensional Pattern Matching with Wildcards in Numpy Arrays
body: <p>First of, I'm aware of <a href="https://gamedev.stackexchange.com/questions/48065/identifying-quad-patterns-in-a-two-dimensional-array">this</a>, <a href="https://cstheory.stackexchange.com/questions/8445/n-dimensional-pattern-matching">this</a> and <a href="https://stackoverflow.com/questions/32531377/how-can-i-check-if-one-two-dimensional-numpy-array-contains-a-specific-pattern-o">this</a> post about two-dimensional pattern matching, these posts however all don't include wildcard matching. Furthermore, I know there are several papers such as <a href="https://www.sciencedirect.com/science/article/pii/S0196677496908445" rel="nofollow noreferrer">this one</a> that have solved the issue I'm facing. However, I'm only just getting familiar with pattern matching in two dimensional arrays and trying to implement the algorithms in the papers is non-trivial for me at the moment. </p>
  
  <p>Thus, the following problem is what I'm facing.</p>
  
  <p>Given a two dimensional array:</p>
  
  <pre><code>[[1 3 4 5 3 3]
   [4 1 4 5 5 2]
   [5 4 3 4 4 2] # pattern
   [4 5 3 4 1 3] # pattern
   [3 3 3 4 4 4] # pattern
   [3 4 3 4 2 5] # pattern
   [4 5 3 4 1 2] # pattern
   [5 1 1 2 4 2]
   [2 1 3 2 1 5]
   [4 4 1 3 3 1]
   [1 4 3 4 4 1]
   [5 2 4 4 4 1]]
  </code></pre>
  
  <p>And the following example pattern (where a ? would indicate the wildcard match):</p>
  
  <pre><code>[[? ? 3 4 ? ?]
   [? ? 3 4 ? ?]
   [3 3 3 4 4 4]
   [? ? 3 4 ? ?]
   [? ? 3 4 ? ?]]
  </code></pre>
  
  <p>How would a function be written that takes in the two dimensional array and the pattern, returning True if the pattern is present in the array or False if it is not?</p>
  
  <p>If possible a generalized solution to this problem would be highly appreciated, as there are numerous distinct patterns that I'm trying to match. If required I'm more than willing to provide additional examples. </p>