Using the definitions
typedef vector<char> Row;
typedef vector<Row> Matrix;
implement a function
int pattern(const Matrix& P, const Matrix& M);
to compute how many times the pattern @P@ appears inside the matrix @M@. It is guaranteed that both matrices are rectangular. Furthermore, if @P@ has dimensions and @M@ has dimensions , then it holds and .
For instance, the pattern to the left appears twice in the matrix to the right. $$\left( \begin{array}{ccc} \mbox{a} & \mbox{b} & \mbox{b} \\ \mbox{b} & \mbox{b} & \mbox{c} \end{array} \right) \hspace*{4cm} \left( \begin{array}{cccc} \mbox{a} & \mbox{a} & \mbox{b} & \mbox{b} \\ \mbox{a} & \mbox{b} & \mbox{b} & \mbox{c} \\ \mbox{b} & \mbox{b} & \mbox{c} & \mbox{a} \end{array} \right)$$
You may implement auxiliar procedures if needed.
The expected solution simply checks the pattern on every possible position of the matrix.
You only need to submit the required procedure; your main program will be ignored.