# The matrix has U

## JavaScript (ES7),  124 110  105 bytes

Returns a Boolean value.

m=>m.some((r,y)=>r.some((v,x)=>(g=n=>n--?v==(m[y+~-(n/5)]||0)[x+n%5-1]^144140166590/3**n%3&&g(n):1)(24)))


Try it online!

### How?

For each reference cell of value $$\v\$$ at $$\(x,y)\$$ in the input matrix $$\m\$$, we test 24 neighbor cells.

The constant $$\144140166590\$$ is $$\111210001101011010121112_3\$$ in base 3. By reversing the digits and rearranging them into a 5x5 matrix, this gives:

$$\begin{pmatrix}2&1&1&1&2\\ 1&\color{red}0&1&0&1\\ 1&0&1&0&1\\ 1&0&0&0&1\\ 2&1&1&1&-\end{pmatrix}$$

where:

• the cell in red is the reference cell
• $$\0\$$ means that this cell must be equal to $$\v\$$
• $$\1\$$ means that this cell must be different from $$\v\$$
• $$\2\$$ means that we don't care

The bottom-right cell of the matrix is ignored, but it should be a $$\2\$$ anyway (for we don't care).

The $$\n\$$-th cell to test (0-indexed) is the cell whose coordinates are:

$$\big(x+(n\bmod 5)-1,y+\lfloor n/5\rfloor-1\big)$$

The corresponding value in the above matrix is given by:

$$V=\left\lfloor\frac{144140166590}{3^n}\right\rfloor\bmod 3$$

We do a bitwise XOR between the cell comparison test and $$\V\$$:

 is equal |  V  | XOR | success?
----------+-----+-----+--------------------------
0    |  0  |  0  | no (should be equal)
1    |  0  |  1  | yes
----------+-----+-----+--------------------------
0    |  1  |  1  | yes
1    |  1  |  0  | no (should be different)
----------+-----+-----+--------------------------
0    |  2  |  2  | yes \__ always
1    |  2  |  3  | yes /   ≠ 0


If all 24 tests are successful, we've found a valid U.

## Julia 0.6, 78 75 bytes

x->any(n->7∈conv2(reshape(digits(287035908958,3)-1,5,5),1÷-~abs(x-n)),x)


Try it online!

Uses 2D-convolution to find the pattern encoded in the magic constant. The constant is derived via base 3 digits similarly to Arnauld's answer, but with 0 and 2 swapped. This way, after subtracting 1, we get the following correspondence: N = 1, '+' = 0, '-' = -1.

The input matrix is transformed to N = 1, everything else = 0. After convolution, the middle cell of the found pattern will accumulate a total of 7 (for the number of N's in the U-shape). If any of required N's is missing, the sum will not reach 7, and if an N (= 1) is present in the forbidden position, it will gain a negative contribution due to the multiplication by -1 in the pattern.

## APL (Dyalog Extended), 6251 45 bytes (SBCS)

-6 based on fireflame241's solution.

⍲,(⍱{'GILNQRS'≡⎕A[⍸,⍵]~'AEUY'}⌺5 5⍤=)¨∘⊂0⍪0,⊢


Try it online!