# [Jelly], 39 [bytes]

    ,Z.ịḊṖ$€Ɗ€
    Ẇ€Z$⁺Ẏµ,ZẈ>2ẠµƇµḊṖZƊ⁺FṀ<ÇȦ)Ṁ

[Test suite.][TIO-jhasvsph]

[Jelly]: https://github.com/DennisMitchell/jelly
[TIO-jhasvsph]: https://tio.run/##lVO9TsMwEN77FB66IFkIx3YdJMTIQyTKyIL6AmyUgaIiMTIzMbFWomFrpYrXcF8knO8nTls6IFkX58vn777zXe5up9P7rtPVefx@iV@LuHob7x4/twsIo9g@waMa72ZtbF/XS13F9vm6iO37ermdr5fEr4A8a2/i6uFqM//5OINNt5nDwa6rR0rVtdMqaDXRymtVNlrVsC20sloZwBiwiAkQkAyxhINNo1HHCCvFxDKiGjIQ8DNElxkg4o50TPpOHixTEWUSOShRiq0kFkk5tEExcAEG2XRAYI8kAjzqe4bJN9lzDOfiqABOSfkmiLFUZpcYaSGbfJETKr2Ukrz0of8kJu2gHpdLstICnztTSjF98sCwlbTlnojBN4NLTHpU8IMmh745/gKoIQV/gX3B/YRQBPYYuaf93Rm@B4uZZVjojTpi/2Tsa7BwPsOsvnmic8TIqgMdI3dg2KCRgS8y8C8GC1tMxSvPtMmTbQdNOMkYaGRhJ8vmQWT48Jg7xRhoHPbK5d@fpuASLFGPk7lUdrKanCPPpHECpgGqAW6B3CJNf7rtNL9pMOFHHzW/ "Jelly – Try It Online"

Outputs **1** if the matrix contains mountain ranges, **0** otherwise.

## How it works

I may be able to shorten the code a bit, so this section will probably undergo heavy editing.

**The helper link**

    ,Z.ịḊṖ$€Ɗ€ – Helper link. Let S be the input matrix.
    ,Z         – Pair S with its transpose.
            Ɗ€ – For each matrix (S and Sᵀ), Apply the previous 3 links as a monad.
      .ị       – Element at index 0.5; In Jelly, the ị atom returns the elements at
                 indices floor(x) and ceil(x) for non-integer x, and therefore this
                 returns the 0th and 1st elements. As Jelly is 1-indexed, this is the
                 same as retrieving the first and last elements in a list.
        ḊṖ$€   – And for each list, remove the first and last elements.

For example, given a matrix in the form:

    A(1,1) A(1,2) A(1,3) ... A(1,n)
    A(2,1) A(2,2) A(2,3) ... A(2,n)
    A(3,1) A(3,2) A(3,3) ... A(3,n)
    ...
    A(m,1) A(m,2) A(m,3) ... A(m,n)

This returns the arrays (the order doesn't matter):

    A(1,2), A(1,3), ..., A(1,n-1)
    A(m,2), A(m,3), ..., A(m,n-1)
    A(2,1), A(3,1), ..., A(m-1,1)
    A(2,n), A(3,n), ..., A(m-1,n)

Long story short, this generates the outermost rows and columns, with the corners removed.

**The main link**

    Ẇ€Z$⁺Ẏµ,ZẈ>2ẠµƇµḊṖZƊ⁺FṀ<ÇȦ)Ṁ – Main link. Let M be the input matrix.
    Ẇ€                           – For each row of M, get all its sublists.
      Z$                         – Transpose and group into a single link with the above.
        ⁺                        – Do twice. So far, we have all contiguous sub-matrices.
         Ẏ                       – Flatten by 1 level.
          µ      µƇ              – Filter-keep those that are at least 3 by 3:
           ,Z                      – Pair each sub-matrix S with Sᵀ.
             Ẉ                     – Get the length of each (no. rows, no. columns).
              >2                   – Element-wise, check if it's greater than 2.
                Ạ                  – All.
                   µ          )  – Map over each sub-matrix S that's at least 3 by 3
                    ḊṖ           – Remove the first and last elements.
                      ZƊ         – Zip and group the last 3 atoms as a single monad.
                        ⁺        – Do twice (generates the inner cells).
                         FṀ      – Flatten, and get the maximum.
                           <Ç    – Element-wise, check if the results of the helper
                                   link are greater than those in this list.
                             Ȧ   – Any and all. 0 if it is empty, or contains a falsey
                                   value when flattened, else 1.
                               Ṁ – Maximum.

[bytes]: https://github.com/DennisMitchell/jellylanguage/wiki/Code-page