text:
All the single eights
Given a non-empty rectangular array of integers from 0 to 9, output the amount of cells that are 8 and do not have a neighbour that is 8. Neighbouring is here understood in the Moore sense, that is, including diagonals. So each cell has 8 neighbours, except for cells at the edges of the array.
For example, given the input
8 4 5 6 5
9 3 8 4 8
0 8 6 1 5
6 7 9 8 2
8 8 7 4 2

the output should be 3. The three qualifying cells would be the following, marked with an asterisk (but only the amount of such entries should be output):
* 4 5 6 5
9 3 8 4 *
0 8 6 1 5
6 7 9 * 2
8 8 7 4 2

Additional rules

You can optionally take two numbers defining the size of the array as additional inputs.
Input can be taken by any reasonable means. The format is flexible as usual. For example, it can be a 2D character array, or a list of lists of numbers, or a flat list.
Programs or functions are allowed, in any programming language. Standard loopholes are forbidden.
Shortest code in bytes wins.

Test cases

Input:
8 4 5 6 5
9 3 8 4 8
0 8 6 1 5
6 7 9 8 2
8 8 7 4 2

Output: 3
Input
8 8
2 3

Output: 0
Input:
5 3 4
2 5 2

Output: 0
Input:
5 8 3 8

Output: 2
Input:
8
0
8

Output: 2.
Input:
4 2 8 5
2 6 1 8
8 5 5 8

Output: 1
Input:
4 5 4 3 8 1 8 2
8 2 7 7 8 3 9 3
9 8 7 8 5 4 2 8
4 5 0 2 1 8 6 9
1 5 4 3 4 5 6 1

Output 3.
Input:
8

Output: 1
Input:
8 5 8 1 6 8 7 7
9 9 2 8 2 7 8 3
2 8 4 9 7 3 2 7
9 2 9 7 1 9 5 6
6 9 8 7 3 1 5 2
1 9 9 7 1 8 8 2
3 5 6 8 1 4 7 5

Output: 4.
Input:
8 1 8
2 5 7
8 0 1

Output: 3.

Inputs in MATLAB format:
[8 4 5 6 5; 9 3 8 4 8; 0 8 6 1 5; 6 7 9 8 2; 8 8 7 4 2]
[8 8; 2 3]
[5 3 4; 2 5 2]
[5 8 3 8]
[8; 0; 8]
[4 2 8 5; 2 6 1 8; 8 5 5 8]
[4 5 4 3 8 1 8 2; 8 2 7 7 8 3 9 3; 9 8 7 8 5 4 2 8; 4 5 0 2 1 8 6 9; 1 5 4 3 4 5 6 1]
[8]
[8 5 8 1 6 8 7 7; 9 9 2 8 2 7 8 3; 2 8 4 9 7 3 2 7; 9 2 9 7 1 9 5 6; 6 9 8 7 3 1 5 2; 1 9 9 7 1 8 8 2; 3 5 6 8 1 4 7 5]
[8 1 8; 2 5 7; 8 0 1]

Inputs in Python format:
[[8, 4, 5, 6, 5], [9, 3, 8, 4, 8], [0, 8, 6, 1, 5], [6, 7, 9, 8, 2], [8, 8, 7, 4, 2]]
[[8, 8], [2, 3]]
[[5, 3, 4], [2, 5, 2]]
[[5, 8, 3, 8]]
[[8], [0], [8]]
[[4, 2, 8, 5], [2, 6, 1, 8], [8, 5, 5, 8]]
[[4, 5, 4, 3, 8, 1, 8, 2], [8, 2, 7, 7, 8, 3, 9, 3], [9, 8, 7, 8, 5, 4, 2, 8], [4, 5, 0, 2, 1, 8, 6, 9], [1, 5, 4, 3, 4, 5, 6, 1]]
[[8]]
[[8, 5, 8, 1, 6, 8, 7, 7], [9, 9, 2, 8, 2, 7, 8, 3], [2, 8, 4, 9, 7, 3, 2, 7], [9, 2, 9, 7, 1, 9, 5, 6], [6, 9, 8, 7, 3, 1, 5, 2], [1, 9, 9, 7, 1, 8, 8, 2], [3, 5, 6, 8, 1, 4, 7, 5]]
[[8, 1, 8], [2, 5, 7], [8, 0, 1]]

Outputs:
3, 0, 0, 2, 2, 1, 3, 1, 4, 3

If you like it then you should have put a vote on it

When I read "cells that equal 8", for a moment I thought you meant that a cell could be larger than a 1x1 chuck (NxN) of the grid. Should probably rephrase that to "cells that are 8" to clarify no math needed. =P

@Tezra Edited. I find the new wording a little less natural, but I’m not a native speaker so I’ll trust your criterion

MATL, 21 17 10 bytes
8=t3Y6Z+>z

Try it online!
Thanks to Luis Mendo for help in chat, and for suggesting 2D convolution.
Explanation:
	#implicit input, m
8=	#equal to 8? matrix of 1 where m is 8, 0 otherwise
t	#duplicate
3Y6	#push [1 1 1; 1 0 1; 1 1 1], "neighbor cells" for convolution
Z+	#2D convolution; each element is replaced by the number of neighbors that are 8
>	#elementwise greater than -- matrix of 1s where an 8 is single, 0s otherwise
z	#number of nonzero elements -- number of single eights
	#implicit output

You could save quite a few bytes using (2D-)convolution, if you are famiiar with the concept

@LuisMendo 2D convolution is one of those things where I don't understand 1D convolution either so there's no hope for me there...sounds like an opportunity to learn both!

If you need help with that let me know in the chat room. Convolution is a very useful operation. If you want to learn convolution start with 1D. The generalization to 2D is immediate

R, 117 63 59 bytes
function(m)sum(colSums(as.matrix(dist(which(m==8,T)))<2)<2)

Try it online!
dist computes distances (default is Euclidean) among rows of a matrix. which with second argument TRUE returns the coordinates where the predicate is true.
Coordinates are neighbours if the distance between them is not more than the square root of 2, but the inner <2 is good enough because the possible distance jumps from sqrt(2) ro 2.

it's a shame numerical imprecision doesn't allow colSums()^2<=2 to work.

@Giuseppe of course there are only a few possible distances and sqrt(2) jumps to 2 (e.g. sort(c(dist(expand.grid(1:6,1:6))), decreasing = TRUE))) so we were being too clever there.

APL (Dyalog Classic), 29 28 25 bytes
≢∘⍸16=2⊥¨3,⌿3,/8=(⍉0,⌽)⍣4

Try it online!

Note: 0 index origin is not even needed.

@Zacharý I always use it as a default, to avoid surprises.

Ah, so like others with 1 (except not explicitly set). That makes sense.

Surprised this doesn't use Stencil. Is there something that makes stencil inconvenient here?

@lirtosiast it's just longer with it :)

(⍉0,⌽)⍣4 to get a border of 0s is amazing. I was jumping through hoops like h w←⍴⍵⋄¯1⊖¯1⌽(h+2)(w+2)↑⍵ for that.

Jelly, 18 15 bytes
8=µ+Ż+ḊZµ⁺ỊṖḋµS

Try it online!
How it works
8=µ+Ż+ḊZµ⁺ỊṖḋµS    Main link (monad). Input: digit matrix
8=              1) Convert elements by `x == 8`
  µ             2) New chain:
   +Ż+Ḋ              x + [0,*x] + x[1:] (missing elements are considered 0)
                     Effectively, vertical convolution with [1,1,1]
       Z             Transpose
        µ⁺      3) Start new chain, apply 2) again
          ỊṖ       Convert elements by `|x| <= 1` and remove last row
            ḋ      Row-wise dot product with result of 1)
             µS 4) Sum

Previous solution, 18 bytes
æc7B¤ZḊṖ
8=µÇÇỊḋµS

Try it online!
Wanted to share another approach, though this is 1 byte longer than Jonathan Allan's solution.
How it works
æc7B¤ZḊṖ    Auxiliary link (monad). Input: integer matrix
æc7B¤       Convolution with [1,1,1] on each row
     ZḊṖ    Zip (transpose), remove first and last elements

8=µÇÇỊḋµS    Main link (monad). Input: digit matrix
8=           Convert 8 to 1, anything else to 0 (*A)
  µÇÇ        Apply aux.link twice (effective convolution with [[1,1,1]]*3)
     Ịḋ      Convert to |x|<=1, then row-wise dot product with A
       µS    Sum the result

Jelly, 17 bytes
=8ŒṪµŒcZIỊȦƲƇẎ⁸ḟL

Try it online! Or see the test-suite.
How?
=8ŒṪµŒcZIỊȦƲƇẎ⁸ḟL - Link: list of lists of integers (digits)
=8                - equals 8?
  ŒṪ              - multidimensional truthy indices (pairs of row & column indices of 8s)
    µ             - start a new monadic chain
     Œc           - all pairs (of the index-pairs)
            Ƈ     - filter keep if:  (keep those that represent adjacent positions)
           Ʋ      -   last four links as a monad:
       Z          -     transpose
        I         -     incremental differences
         Ị        -     insignificant? (abs(x) <= 1)
          Ȧ       -     all?
             Ẏ    - tighten (to a list of all adjacent 8's index-pairs, at least once each)
              ⁸   - chain's left argument (all the index-pairs again)
               ḟ  - filter discard (remove those found to be adjacent to another)
                L - length (of the remaining pairs of indices of single 8s)

JavaScript (Node.js), 88 85 bytes
a=>g=(x,y=0,c=0)=>a.map(p=>p.map((q,j)=>c+=q-8?0:1/x?(x-j)**2+y*y<3:g(j,-y)<2)&--y)|c

Try it online!
Thank Arnauld for 2 bytes

J,43, 40 37 bytes
-3 bytes thanks to Bubbler
1#.1#.3 3(16=8#.@:=,);._3(0|:@,|.)^:4

Try it online!
Explanation:
The first part of the algorithm assures that we can apply a 3x3 sliding window to he input. This is achieved by prepending a row of zeroes and 90 degrees rotation, repeated 4 times.
1#.1#.3 3(16=8#.@:=,);._3(0|:@,|.)^:4
                         (       )^:4 - repeat 4 times
                          0|:@,|.     - reverse, prepend wit a row of 0 and transpose
                     ;._3             - cut the input (already outlined with zeroes)
      3 3                             - into matrices with size 3x3
         (          )                 - and for each matrix do
                   ,                  - ravel (flatten)
             8    =                   - check if each item equals 8
              #.@:                    - and convert the list of 1s and 0s to a decimal
          16=                         - is equal to 16?
   1#.                                - add (the result has the shape of the input)
1#.                                   - add again

37 bytes using @: and moving |.. Note that @ in place of @: doesn't work.

This is nice.  Probably worth adding at least a high level explanation of how it works, if not a code breakdown.  It took me 10m or so to figure it out.  Also, it's interesting how much shorter the APL version (which uses the same approach) is.  Looks like that's mostly the result of digraphs instead of single char symbols...

@Jonah I'll add an explanation. For comparison with APL you can look at the revisions of ngn's solution,
especially the 28 byte version

@Jonah Explanation added

Java 8, 181 157 156 149 147 bytes
(M,R,C)->{int z=0,c,f,t;for(;R-->0;)for(c=C;c-->0;z+=f%9/8)for(f=t=9;M[R][c]==8&t-->0;)try{f-=M[R+t/3-1][c+t%3-1]%9/8;}finally{continue;}return z;}

-24 bytes thanks to @OlivierGrégoire
-2 bytes thanks to @ceilingcat.
Takes the dimensions as additional parameters R (amount of rows) and C (amount of columns).
The cells are checked pretty similar as I did in my Fryer simulator answer.
Try it online.
Explanation:
(M,R,C)->{                  // Method with integer-matrix as parameter & integer return
  int z=0,                  //  Result-counter, starting at 0
      c,f,t;                //  Temp-integers, starting uninitialized
  for(;R-->0;)              //  Loop over the rows:
    for(c=C;c-->0           //   Inner loop over the columns:
           ;                //     After every iteration:
            z+=f%9/8)       //      If the digit in this cell is 8:
                            //       Increase the result-counter by 1
                            //      Else: leave it the same
      for(f=t=9;            //    Reset the flag to 9
          M[R][c]==8&       //    If the current cell contains an 8:
            t-->0;)         //     Inner loop `t` in the range (9, 0]:
        try{f-=             //      Decrease the flag by:
               M[R+t/3-1]   //       If `t` is 0, 1, or 2: Look at the previous row
                            //       Else-if `t` is 3, 4, or 5: Look at the current row
                            //       Else (`t` is 6, 7, or 8): Look at the next row
                [c+t%3-1]   //       If `t` is 0, 3, or 6: Look at the previous column
                            //       Else-if `t` is 1, 4, or 7: Look at the current column
                            //       Else (`t` is 2, 5, or 8): Look at the next column
                %9/8;       //       And if the digit in this cell is 8:
                            //        Decrease the flag-integer by 1
                            //       Else: leave it the same
        }finally{continue;} //      Catch and ignore ArrayIndexOutOfBoundsExceptions
                            //      (try-finally saves bytes in comparison to if-checks)
  return z;}                //  And finally return the counter

Retina 0.8.2, 84 bytes
.+
_$&_
m`(?<!(?(1).)^(?<-1>.)*.?.?8.*¶(.)*.|8)8(?!8|.(.)*¶.*8.?.?(?<-2>.)*$(?(2).))

Try it online! Explanation:
.+
_$&_

Wrap each line in non-8 characters so that all 8s have at least one character on each side.
m`

This is the last stage, so counting matches is implied. The m modifier makes the ^ and $ characters match at the start or end of any line.
(?<!...|8)

Don't match a character directly after an 8, or...
(?(1).)^(?<-1>.)*.?.?8.*¶(.)*.

... a character below an 8; the (?(1).)^(?<-1>.)* matches the same column as the ¶(.)* on the next line, but the .?.? allows the 8 to be 1 left or right of the character after the . on the next line.
8

Match 8s.
(?!8|...)

Don't match an 8 immediately before an 8, or...
.(.)*¶.*8.?.?(?<-2>.)*$(?(2).)

... a character with an 8 in the line below; again, the (?<-2>.)*$(?(2).) matches the same column as the (.)*¶ on the previous line, but the .?.? allows the 8 to be 1 left or right of the 8 before the . on the previous line.

J, 42 bytes
[:+/@,8=]+[:+/(<:3 3#:4-.~i.9)|.!.0(_*8&=)

Try it online!
explanation
The high-level approach here is similar to the one used in the classic APL solution to the game of life: https://www.youtube.com/watch?v=a9xAKttWgP4.
In that solution, we shift our matrix in the 8 possible neighbor directions, creating 8 duplicates of the input, stack them up, and then add the "planes" together to get our neighbor counts.
Here, we use a "multiply by infinity" trick to adapt the solution for this problem.
[: +/@, 8 = ] + [: +/ (neighbor deltas) (|.!.0) _ * 8&= NB.
                                                        NB.
[: +/@,                                                 NB. the sum after flattening
        8 =                                             NB. a 0 1 matrix created by
                                                        NB. elmwise testing if 8
                                                        NB. equals the matrix
            (the matrix to test for equality with 8   ) NB. defined by...
            ] +                                         NB. the original input plus
                [: +/                                   NB. the elmwise sum of 8
                                                        NB. matrices defined by
                                                _ *     NB. the elmwise product of
                                                        NB. infinity and
                                                    8&= NB. the matrix which is 1
                                                        NB. where the input is 8
                                                        NB. and 0 elsewhere, thus
                                                        NB. creating an infinity-0
                                                        NB. matrix
                                        (|.!.0)         NB. then 2d shifting that
                                                        NB. matrix in the 8 possible
                                                        NB. "neighbor" directions
                      (neighbor deltas)                 NB. defined by the "neighbor
                                                        NB. deltas" (see below)
                                                        NB. QED.
                                                        NB. ***********************
                                                        NB. The rest of the
                                                        NB. explanation merely
                                                        NB. breaks down the neighbor
                                                        NB. delta construction.

                      (neighbor deltas  )               NB. the neighbor deltas are
                                                        NB. merely the cross product
                                                        NB. of _1 0 1 with itself,
                                                        NB. minus "0 0"
                      (<: 3 3 #: 4 -.~ i.9)             NB. to create that...
                       <:                               NB. subtract one from
                          3 3 #:                        NB. the base 3 rep of
                                       i.9              NB. the numbers 0 - 8
                                 4 -.~                  NB. minus the number 4
                                                        NB.
                                                        NB. All of which produces
                                                        NB. the eight "neighbor"
                                                        NB. deltas:
                                                        NB.
                                                        NB.       _1 _1
                                                        NB.       _1  0
                                                        NB.       _1  1
                                                        NB.        0 _1
                                                        NB.        0  1
                                                        NB.        1 _1
                                                        NB.        1  0
                                                        NB.        1  1

You have forgotten to remove a space between ~ and >

@GalenIvanov Fixed now.  Thank you.

Jelly, 12 bytes
œẹ8ạṀ¥þ`’Ạ€S

Try it online!
How it works
œẹ8ạṀ¥þ`’Ạ€S  Main link. Argument: M (matrix)

œẹ8           Find all multidimensional indices of 8, yielding an array A of pairs.
      þ`      Table self; for all pairs [i, j] and [k, l] in A, call the link to the
              left. Return the results as a matrix.
   ạ              Absolute difference; yield [|i - k|, |j - l|].
    Ṁ             Take the maximum.
        ’     Decrement all the maxmima, mapping 1 to 0.
         Ạ€   All each; yield 1 for each row that contains no zeroes.
           S  Take the sum.

05AB1E, 27 bytes
8Q2Fø0δ.ø}2Fø€ü3}˜9ôʒÅs}OΘO

Try it online or verify all test cases.
Explanation:
8Q       # Check for each inner value in the (implicit) input-matrix if it's an 8
         # (1 if 8; 0 if not)
2Fø0δ.ø} # Add a border of 0s around the matrix:
2F     } #  Loop 2 times:
  ø      #   Zip/transpose; swapping rows/columns
    δ    #   Map over each inner list:
   0 .ø  #    Surround it with a leading/trailing 0
2Fø€ü3}  # Then get all overlapping 3x3 blocks of this modified matrix:
2F    }  #  Loop 2 times again:
  ø      #   Zip/transpose again
   €     #   Map over each inner list again:
    ü3   #    Split it into overlapping triplets
˜        # Flatten the entire list of lists of lists of lists of integers
         # (aka the list of lists of 3x3 blocks)
 9ô      # Split it into parts of size 9
         # (so we now have a single list with flattened 3x3 blocks)
ʒÅs}     # Keep the (flattened) 3x3 blocks with a 1 in the center:
ʒ  }     # Filter over the list of flattened 3x3 blocks:
 Ås      #  Pop the list and push its center value
O        # Sum the inner lists of any remaining flattened 3x3 block
 Θ       # Check for each sum whether it's equal to 1 (1 if 1; 0 otherwise)
  O      # Sum those together again
         # (after which this sum is output implicitly as result)

Python 2, 130 bytes
lambda a:sum(sum(u[~-c*(c>0):c+2].count(8)for u in a[~-r*(r>0):r+2])*8==8==a[r][c]for r in range(len(a))for c in range(len(a[0])))

Try it online!

Seems shorter if take length from args

Powershell, 121 bytes
param($a)(($b='='*4*($l=($a|% Le*)[0]))+($a|%{"!$_!"})+$b|sls "(?<=[^8]{3}.{$l}[^8])8(?=[^8].{$l}[^8]{3})" -a|% m*).Count

Less golfed test script:
$f = {

param($a)

$length=($a|% Length)[0]
$border='='*4*$length
$pattern="(?<=[^8]{3}.{$length}[^8])8(?=[^8].{$length}[^8]{3})"
$matches=$border+($a|%{"!$_!"})+$border |sls $pattern -a|% Matches
$matches.count

}

@(

,(3,"84565","93848","08615","67982","88742")
,(0,"88","23")
,(0,"534","252")
,(2,"5838")
,(2,"8","0","8")
,(1,"4285","2618","8558")
,(3,"45438182","82778393","98785428","45021869","15434561")
,(1,"8")
,(4,"85816877","99282783","28497327","92971956","69873152","19971882","35681475")
,(3,"818","257","801")
,(0,"")

) | % {
    $expected,$a = $_
    $result = &$f $a
    "$($result-eq$expected): $result : $a"
}

Output:
True: 3 : 84565 93848 08615 67982 88742
True: 0 : 88 23
True: 0 : 534 252
True: 2 : 5838
True: 2 : 8 0 8
True: 1 : 4285 2618 8558
True: 3 : 45438182 82778393 98785428 45021869 15434561
True: 1 : 8
True: 4 : 85816877 99282783 28497327 92971956 69873152 19971882 35681475
True: 3 : 818 257 801
True: 0 :

Explanation:
First, the script calculates a length of the first string.
Second, it adds extra border to strings. Augmended reality string likes:
....=========!84565! !93848! !08615! !67982! !88742!===========....

represents the multiline string:
...=====
=======
!84565!
!93848!
!08615!
!67982!
!88742!
=======
========...

Note 1: the number of = is sufficient for a string of any length.
Note 2: a large number of = does not affect the search for eights.
Next, the regular expression (?<=[^8]{3}.{$l}[^8])8(?=[^8].{$l}[^8]{3}) looks for the digit 8 with the preceding non-eights (?<=[^8]{3}.{$l}[^8]) and the following non-eights (?=[^8].{$l}[^8]{3}):
.......
<<<....
<8>....
>>>....
.......

Finally, the number of matches is returned as a result.

JavaScript (ES6), 106 bytes
a=>a.map((r,y)=>r.map((v,x)=>k+=v==8&[...'12221000'].every((d,i,v)=>(a[y+~-d]||0)[x+~-v[i+2&7]]^8)),k=0)|k

Try it online!

Bitwise approach, 110 bytes
a=>a.map(r=>r.map(v=>x=x*2|v==8,x=k=0)|x).map((n,y,b)=>a[0].map((_,x)=>(n^1<<x|b[y-1]|b[y+1])*2>>x&7||k++))&&k

Try it online!

Bitwise approach fail on [[7]]

Clojure, 227 198 bytes
(fn[t w h](let[c #(for[y(range %3 %4)x(range % %2)][x y])e #(= 8(get-in t(reverse %)0))m(fn[[o p]](count(filter e(c(dec o)(+ o 2)(dec p)(+ p 2)))))](count(filter #(= 1(m %))(filter e(c 0 w 0 h))))))

Ouch. Definitely not the shortest here by any means. 54 bytes of parenthesis is killer. I'm still relatively happy with it though.
-29 bytes by creating a helper function that generates a range since I was doing that twice, changing the reduce to a (count (filter setup, and getting rid of the threading macro after golfing.
(defn count-single-eights [td-array width height]
  ; Define three helper functions. One generates a list of coords for a given range of dimensions, another checks if an eight is
  ; at the given coord, and the other counts how many neighbors around a coord are an eight
  (letfn [(coords [x-min x-max y-min y-max]
            (for [y (range y-min y-max)
                  x (range x-min x-max)]
              [x y]))
          (eight? [[x y]] (= 8 (get-in td-array [y x] 0)))
          (n-eights-around [[cx cy]]
            (count (filter eight?
                           (coords (dec cx) (+ cx 2), (dec cy) (+ cy 2)))))]

    ; Gen a list of each coord of the matrix
    (->> (coords 0 width, 0 height)

         ; Remove any coords that don't contain an eight
         (filter eight?)

         ; Then count how many "neighborhoods" only contain 1 eight
         (filter #(= 1 (n-eights-around %)))
         (count))))

(mapv #(count-single-eights % (count (% 0)) (count %))
      test-cases)
=> [3 0 0 2 2 1 3 1 4 3]

Where test-cases is an array holding all the "Python test cases"
Try it online!


text:
Should this identifier be suggested?
Introduction
In Android Studio and other IDEs there are code completions to assist efficient code insertion (especially when the names of the classes or methods are so verbose), like the one in the image below.

There are slightly different logics used between IDEs to determine what classes, methods and variables to suggest, but otherwise are common: typing the initial letters of each word, and the identifier matching those initial letters will be suggested.
Challenge
In this challenge, write a program or function which receives two strings, namely input and identifier, determine whether the identifier matches the input.
We split identifier into words where:

a lowercase letter is followed by an uppercase letter ("SplitHere" -> "Split", "Here"),
an uppercase letter is followed by an uppercase letter and a lowercase letter ("SPLITHere" -> "SPLIT", "Here"), or
there is a number or an underscore _ ("SPLIT_HERE" -> "SPLIT", "HERE").

If this is still not clear enough, here is the regex representing the condition to split: (?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|[_0-9]. Here are a few samples:

theWord_Example, in which 3 words (the, Word, Example) can be found.
THEWORD2EXAMPLE, in which only 2 words (THEWORD, EXAMPLE) can be found (because THEWORD is a run of uppercase letters and so does EXAMPLE).
THEWordEXAMPLE3, in which 3 words (THE, Word, Example) can be found (Word is considered to be a separate word here).
THEWORDEXAMPLEFOUR, in which only 1 words (THEWORDEXAMPLEFOUR) can be found (the whole run of uppercase letters).

For this purpose here we use a simplified version. In reality the logic is far more complex. In this version there are only two rules:

If input consists of only lowercase letters, then an identifier matches the input only if there is a splitting of input into substrings, that for each substring there is a word within the identifier starting with that substring, in that exact order.

Example input: sbo
Truthy cases: SQLiteBindOrColumnIndexOutOfRangeException, SparseBooleanArray, (UPDATE) StringIndexOutOfBoundException
Falsy cases: SeekBar (missing o), StatusBarNotification (the o is not at the beginning of a word)

If input contains uppercase letters, then a split on the input must be made before each uppercase letter when applying Rule 1.

Example input: sbO
Truthy cases: SQLiteBindOrColumnIndexOutOfRangeException
Falsy cases: SparseBooleanArray (the O must appear at the beginning of a word), StringIndexOutOfBoundException (wrong order)

I/O
Input: two strings, one for input and one for identifier. You can assume that the regex [A-Za-z]+ matches input and the regex [A-Za-z0-9_] matches identifier.
Output: one of the truthy or falsy values. You can choose what value to return as truthy and what as falsy, but your choice must be consistent across all cases. For example you can return 1/0, true/false, π/e or whatever, but they must stay the same across all cases.
Test cases
Each line consists of two strings, namely input and identifier respectively.
Truthy cases:
"sbo" "SparseBooleanArray"
"sbo" "StringIndexOutOfBoundException"
"sbo" "SQLiteBindOrColumnIndexOutOfRangeException"
"sbO" "SQLiteBindOrColumnIndexOutOfRangeException"
"Al" "ArrayList"
"AL" "ArrayList"
"Al" "ALARM_SERVICE"
"As" "ALARM_SERVICE"
"AS" "ALARM_SERVICE"
"SD" "SQLData"
"SqD" "SQLData"
"SqlD" "SQLData"
"SqDa" "SQLData"
"the" "theWord_Example"
"the" "THEWORD2EXAMPLE"
"the" "THEWordEXAMPLE3"
"the" "THEWORDEXAMPLEFOUR"
"thw" "theWord_Example"
"thw" "THEWordEXAMPLE3"
"te" "theWord_Example"
"te" "THEWORD2EXAMPLE"
"te" "THEWordEXAMPLE3"

Falsy cases:
"sbo" "SeekBar"
"sbo" "StatusBarNotification"
"sbO" "StringIndexOutOfBoundException"
"sbO" "SparseBooleanArray"
"AL" "ALARM_SERVICE"
"ASE" "ALARM_SERVICE"
"SQD" "SQLData"
"SqLD" "SQLData"
"SLD" "SQLData"
"SQDt" "SQLData"
"SQDA" "SQLData"
"thw" "THEWORD2EXAMPLE"
"thw" "THEWORDEXAMPLEFOUR"
"te" "THEWORDEXAMPLEFOUR"

Winning Criteria
This is a code-golf, so shortest code of each language wins. Default loopholes are not allowed.

so "SQLData", "SQLData" is false?

@l4m2 Yes as per the simplified rules. However "sqldata", "SQLData" is true.

can "sbo" "StringIndexOutOfBoundException"match *S*tringIndexOutOf*Bo*undException ?

@TFeld Oh I made a mistake on the cases, thanks for reminding

Python 2, 239 227 bytes
lambda a,b:any(re.match(w,''.join(map(str.title,re.sub('(?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z])|(\d)','_',b).split('_'))))for w in g(a))
import re
g=lambda s:s and{c+w for w in g(s[1:])for c in[s[0],'.*'+s[0].upper()][s<'[':]}or{''}

Try it online!

JavaScript (ES6), 177 bytes
Expects (identifier)(input).
S=>g=([c,...s],l=[],o='')=>c?g(s,o?[...l,o]:l,c)|c>{}&g(s,l,o+c):eval(`/~${[...l,o].join`.*~`}/i`).test(S.replace(/./g,(c,i)=>!i|(!/[A-Z]/.test(l)|S[i+1]>'_')&(l=c)<{}?'~'+c:c))

Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Couch 2048: How much more till 2048?
I have just tried a game called Couch 2048.
(Note: You should have a look to better understand this question.)
Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'
That inspired me to post a challenge, because calculating this in not as easy as I thought.
Your goal:
Given a list of balls on the sofa, you have to output how many balls with a value of 2 have to fall from the sky so that one can win the game (by reaching the 2048 ball).

Assume the input is valid.
Assume the player won't drop any balls.
Assume the balls which fall from the sky always have a value of 2, as I've said.
Valid output examples: 3, "4", [5], ["6"]

Edit:
I should clarify something:
 - You have to print the smallest amount of 2s needed.
Test cases:
[2048] -> 0 You've already won
[1024,1024] -> 0 You don't need any more balls to win
[1024,512,256,128,64,32,16,8,4,2] -> 1 One ball required to 'activate the chain'
[512] -> 768
[512,2] -> 767
[4,16,64] -> 982
Notes:
I'm not a native speaker - Tell me if you spotted a typo or some non-grammatical text.
If something's unclear, ask in comments.

why [4,16,64] -> 22?

Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.

@Shaggy thx for noticing a silly mistake

Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!

Thx @KevinCruijssen

Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!

@micnap It's expected for easy challenges to get many answers, but don't make it too trivial, like this.

Can there be a number being 1, not a power of 2 or larger than 2048 to be in the input? (I don't play the game)

It don't want to blame Kevin Cruijssen but his comment may have had accelerated the answer influx.

@user202729 no. Just 2,4,8,16,32,64,128,256,512,1024,2048

Hey, downvoter: explain your point of view! It's necessary for the challenge to improve!

@micnap Usually it's because they don't like the challenge. /// It's not recommended to leave such comments, which may be observed as vote manipulation.

Java 8, 17 bytes
s->1024-s.sum()/2

Port of @LuisFelipeDeJesusMunoz' JavaScript answer.
Try it online.
Explanation:
s->           // Method with IntStream parameter and int return-type
  1024-       //  Return 1024, minus:
   s.sum()    //   The sum of the input-IntStream
          /2  //   Divided by 2

That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)

Brain-Flak, 72 bytes
({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})

Try it online!
({{}})                     # Sum entire stack
      (                  ) # Push:
       {<          >()}{}  #   The number of times you can...
         ({}[()()])        #   Subtract 2 before reaching 0

([{}]                                        ) # Subtract that from...
     ((((((((()()()()){}){}){}){}){}){}){}){}  # 1024

Thank you! I'm interested in learning Brain-Flak and your explanation was useful.

Python 2, 22 bytes
lambda x:4**5-sum(x)/2

Y'know, I just realized that 4**5 is the same length as 1024.
Try it online!

MathGolf, 6 5 bytes
Σc/◘+

First MathGolf answer. :)
Try it online or verify all test cases.
Explanation:
Σ         # Sum of the (implicit) input-list
 c/       # Divide it by -2
   ◘+     # Add 1024 to it (and output implicitly)

05AB1E, 5 bytes
O;žBα

Port of @LuisFelipeDeJesusMunoz' JavaScript answer.
Try it online or verify all test cases.
Explanation:
O        # Sum of the (implicit) input-list
 ;       # Halved
  žB     # Push 1024
    α    # Absolute difference between the two (and output implicitly)

JavaScript (Node.js), 25 bytes
Based on @Shaggys' comment and answer
-3 bytes from @Arnauld =D
_=>1024-eval(_.join`+`)/2

Try it online!

APL (Dyalog Unicode), 10 bytes
2÷⍨2048-+/

Try it online!

J, 10 bytes
2048-:@-+/

Try it online!
Alternative:
J, 10 bytes
1024-1#.-:

Try it online!

Ruby, 17 bytes
->l{1024-l.sum/2}

Try it online!

Catholicon, 5 bytes
-`L̇½Ṗ

Explanation:
-      subtract
 `L̇    1024
       from
   ½   half of the
    Ṗ  sum [of the input]

Is that a new golfing language I smell? :)

+1 for the new language. Another one to learn

TI-Basic, 8 bytes
4^5-.5sum(Ans

Japt, 7 6 bytes
xz nH²

Try it or verify all test cases
 z         :(Floor) divide each by 2
x          :Reduce by addition
   n       :Subtract from
    H      : 32
     ²     : Squared

JavaScript, 28 bytes
a=>a.map(n=>x-=n/2,x=1024)|x

Try it online

Jelly, 7 6 bytes
HSạ⁽¡ç

Try it online!
Explanation:
HSạ⁽¡ç    Example input: [4,16,64]
H         Halve input. [2, 8, 32]
 S        Sum. 42
   ⁽¡ç    Number 1024.
  ạ       Difference. 982

 -1 byte by using a base-250 number

perl -aE, 27 bytes
$"=$:;say eval"(2048-@F)/2"

This reads a line with numbers (whitespace separated) from STDIN, and writes the answer to STDOUT.
What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The -a switch puts the in the array @F (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of $" between the elements. The little used variable $: is be default \n-; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The eval does the calculation.

Vyxal, 5 bytes
∑k¦ε½

Try it Online!
∑     # Sum
 k¦   # 2048
   ε  # Abs. diff.
    ½ # halved

JavaScript (Node.js), 33 bytes
a=>!a.map(n=>x-=n/2,x=1024)>x?0:x

Try it online!
Why you don't do on [1024,1024,1024]?

R, 17 bytes
4^5-sum(scan())/2

Try it online!

TeaScript, 11 bytes
4p5)-(xx)/2

Try it online!

Stax, 6 bytes
ë3i─♠÷

Run and debug it

Perl 6, 12 bytes
1024-*.sum/2

Try it online!
Anonymous Whatever lambda that takes a list and returns a number.

AWK, 26 bytes
{s+=$1}END{print 1024-s/2}

Input numbers are separated by newlines (i.e. one per line)

Neim, 6 bytes
Pretty new to Neim but got it working
ᚺςᚫᛦ

Explanation:
           : Sum input
   ᚺ        : Divide by 2 (stack now [input summed and divided by 2])
    ς       : Variable set to 16 pushed to stack
     ᚫ      : Multiply by 2
      ᛦ     : Square (stack now [input summed and divided by 2, 1024])
           : Subtract then absolute

Try it online!

JAVA,  30 bytes
2048-IntStream.of(a).sum()/2;

RAD, 10 bytes
1024-+/ω÷2

Try it online!

F#, 24 bytes
fun f->1024-List.sum f/2

1024 minus the sum divided by 2.

Clojure, 24 bytes
#(- 1024(/(apply + %)2))

Try it online!

Haskell, 16 bytes
(1024-).(/2).sum

An anonymous function, takes a list and returns a float.
Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
FreeChat Online
FreeChat Online
It is 1985, and you are a humble Russian potato farmer. Sadly, your glorious homeland is going through a time of crisis and it needs your help! The KGB, with the "assistance" of your wife and children, has convinced you to build their up-and-coming government FreeChat Online service for high ranking soviet officials. Luckily, the Russian government has provided you with several items seized through routine surveillance of the US's technological innovations—a cutting edge Macintosh XL, and the prototype source code for LucasArts's Habitat, an advanced communication service with cutting edge graphics. Your task is simple: create a few modifications for the Russian government…
Due to Communism's tendency to coalesce toward collectivistic cultures, the Russian government wants this chat to embody their perfect world—one without silly notions of self or individualism. Alas, Macintosh compatibility leads you astray. Due to problems in the prototype, every other sentence in the chat buffer is corrupted, except for the ending period. Lucky for you, the Russian people make classification easy for you.
CHALLENGE:
For a String s in the input, there are 1 or more sentences, separated by ".  "(period, TWO spaces) The 2nd, 4th, 6th, and so on sentences are corrupted. The last sentence may have nothing, ".", ". ", or ".  " as its end. Here's some examples of an input:
"L'etat c'est moi (I am the state) - King Louis XIV"
|----------------one sentence, ended by nothing--------------|
"Hello World.  GojdGojog.  How are you.  "
|--three sentences, one corrupted, ended by ".  "--|
"Hi.  gfhyG.  My favorite food is Baseball. jijhojh. Foobar. "
|---------------Five sentences, two corrupted, ended by ". "-----------|
You must process this string, replacing any capitalized word besides the first word of a sentence, words in parentheses (no nested, but there can be multiple sets in a sentence), or corrupted sentences with the string "The State".
Examples:
"L'etat c'est moi (I am the state) - King Louis XIV"
--->"L'etat c'est moi (I am the state) - The State The State The State"
"Hello World.  GojdGojog.  How are you.  "
--->"Hello The State.  GojdGojog.  How are you.  "
"Hi.  gfhyG.  My favorite food is Baseball. jijhojh. Foobar. "
--->"Hi.  gfhyG.  My favorite food is The State. jijhojh. Foobar. "
Rules:

Standard Loopholes are prohibited

ASCII Text Input

If the input doesn't match the specifications set above, do whatever you please with the output!

This is code-golf, so the shortest(valid)answer (in each language) wins!

Bonus points for a one-liner  (Not really tho, just cool points)

I had thought this post is a spam when I read its title in questions list.

Why Hi.  gfhyG.  My favorite food is Baseball. jijhojh. Foobar. is 4 sentences? Should it be 3? Hi., gfhyG., My favorite food is Baseball. jijhojh. Foobar.

@tsh u rite but 5

@Michael Why? Where are the another 2? Should dot followed by one space considered as stop of a sentence?

@tsh the code backticks remove trailing whitespace, its in my editor but not visible, just added commas

@JoKing I got u no nested, but there can be multiple sets in a sentence

For the first example, is it unintended that the "C" is capitalized in the input?

You state "The 2nd, 4th, 6th, and so on sentences are corrupted.", but your first example is only a single sentence, so why are King Louis XIV replaced with 3x The State? Also, as mentioned by @KamilDrakari above, why isn't the C (or C'est) not replaced with The State while the King Louis XIV are?

@KevinCruijssen I think it's one indexed

@JoKing That's what I assumed as well, so why is the first test cases which is a single sentence (1 in 1-indexed) corrupted with its capitalized words replaced?

@KevinCruijssen You're meant to ignore corrupted sentences, so it's okay to make replacements in the first sentence

@Michael Can an input-sentence end with a trailing dot an two spaces?

@Michael Should I in the first example be replaced with The State as well? Or does the single letter I not count as a capitalized word?

@KevinCruijssen No replacing words in parenthesises

@JoKing Yeah, someone else already replied that to me, but I see (s)he now deleted their message..

@KevinCruijssen I think I fixed all the vague areas in my examples, can I has main page pls

Retina 0.8.2, 77 bytes
(?<=^(([^.]*)\. +([^.]*)\. +)*[^ .][^.]*)(?<!\([^)]*)[A-Z][A-Za-z]*
The State

Try it online! Link includes test cases. Explanation:
(?<=^(([^.]*)\. +([^.]*)\. +)*[^ .][^.]*)

Only match in the middle of alternate sentences.
(?<!\([^)]*)

Don't match inside parentheses.
[A-Z][A-Za-z]*

Match words beginning with uppercase letters.
The State

Replace them as desired.

Java 10, 164 bytes
s->{var S=s.split(".  ",-1);for(int l=S.length,i=0;i<l;)System.out.print((i%2<1?S[i].replaceAll("(?!^)[A-Z]\\w*(?<!\\([^)]*)","The State"):S[i])+(++i<l?".  ":""));}

Try it online.
Explanation:
s->{                       // Method with String as both parameter and return-type
  var S=s.split(".  ",-1); //  Split the input by ".  " to get the list of sentences
                           //  (the -1 is in case the input ends in a trailing ".  ")
  for(int l=S.length,      //  Amount of sentences
      i=0;i<l;)            //  Loop `i` in the range [0, amount_of_sentences):
    System.out.print(      //   Print (without newline):
     (i%2<1?               //    If `i` is even:
       S[i]                //     Print the sentence,
        .replaceAll(       //      After we've replaced all
          "(?!^)           //       (except the very first)
           [A-Z]\\w*       //       capitalized words,
           (?<!\\([^)]*)"  //       that are not within parenthesis
          "The State")     //      With "The State"
      :                    //    Else:
       S[i])               //     Print the sentence as is
            +(++i<l?       //    And if it's not the last iteration:
               ".  "       //     Append ".  "
              :            //    Else:
               ""));}      //     Append nothing more

Perl 6, 91 bytes
{S:g/\s<:Lu><-[.\s]>+<?{!grep {$/.prematch.comb($_)%2},'.  ',/\(|\)/,/\.\s$/}>/ The State/}

Try it online!
Regex based solution.
Explanation:
 S:g/                  # Do a global substitution
     \s<:Lu><-[.\s]>+  # On all words starting with capital letters
               <?{                                        }>  # Where:
                  !grep {                       } # None of:
                                                 ,'.  '   # Sentence terminators
                                                 ,/\(|\)/ # Parenthesises
                                                 ,/\.\s$/ # Is first word of sentence?
                                    .comb($_)%2   # Have an odd amount of matches
                         $/.prematch              # From the string before
                                                           / The State/  # And replace


text:
Alignment of a string
This is similar to the alignment used in word.
Task
3 inputs: A 1 line string, a positive integer k, and direction (left or middle or right)
Your job is to insert new lines(\n) and spaces in the string such that every line has k characters in it and aligned to the direction given.
Rules
The words must not be split(unless their length is greater than k)
Direction can be taken as any 3 unique characters(must be mentioned).
Any format and order of input is valid(must be mentioned).
Input will only have alphabetical characters of any case(and spaces).
There will not be any trailing or leading spaces in the input and will have only 1 space between words.
Output can be either a string on one line as is in examples or multiple lines.
If the direction is left:
There should not be any spaces in left of the line and only 1 space between words.
If the direction is right:
There cannot be any spaces to the right of the line and only 1 space between words.
If the direction is middle:
There cannot be any spaces to the left or right of a line and an equal number of spaces between words on one line.
In case the word length is shorter than k and only 1 word can fit in 1 line, then spaces on the right is allowed.
If more than 2 words can fit in one line but they cannot be divided keeping number of spaces equal, words will shift to next line to keep number of spaces equal.
Test Cases
input: 'Hello World',6,right
output: ' Hello\n World'

input: 'Hello World',7,left
output: 'Hello  \nWorld  '

input: 'Hello World',7,middle
output: 'Hello  \nWorld  '

input: 'This is a test case',5,middle
output: 'This \nis  a\ntest \ncase '

input: 'This is a test case',5,left
output: 'This \nis a \ntest \ncase '

input: 'For example',1,left
output: 'F\no\nr\ne\nx\na\nm\np\nl\ne' #The space is removed as the next word is in a newline.

input: 'Hello Worlds How are you',5,left
output: 'Hello\nWorld\ns How\nare  \nyou  '

input: 'qwert asdfghjkl zxcvbnm',7,middle
output: 'qwert  \nasdfghj\nkl      \nzxcvbnm'

input: 'ab abcdefg',6,middle
output: 'ab    \nabcdef\ng     '

input: 'This is code golf so shortest code wins',10,middle
output: 'This    is\ncode  golf\nso        \nshortest  \ncode  wins'

input: 'Credit to Jo for this case',13,middle
output: 'Credit     to\nJo  for  this\ncase         '

This is code-golf so shortest code wins

Related.

Can we remove trailing whitespace?

@JoKing, No, you can't.

input: 'the maximums',6,middle; output: ? from the post, I could argue both 'the   \nmaximu\nms    ', or 'the ma\nximums'.

@ChasBrown, the...\nmaximu\nms.... (same as left)

@ChasBrown, 1 example was wrong,fixed it

Perl 6, 195 186 177 132 bytes
-41 bytes thanks to nwellnhof!
{->\b,\c{$!={!c*(b-$0.comb)/($0-1||1)+1};S:g{[(\S+)[\s|$]<?{b>=$0.ords&&.$!%%1}>]+|(\S**{b})}=$0.join(' 'x.$!).fmt("%{b*c||-b}s
")}}

Try it online!
Anonymous code block that takes input curried, e.g. f('text')(length, direction). Uses the values -1,0,1 as left, middle and right respectively.

Python 2, 245 243 237 225 221 bytes
import re
s,k,d=input()
s=filter(bool,re.split('(\w{%d})| '%k,s))
while s:l,s=max((j,s[i:])for i in range(len(s)+1)for x in range(d&1or k)for j in[(-~x*' ').join(s[:i])]if[k,0][d|(i<2)]<=len(j)<=k);print'%*s'%(-(d|1)*k,l)

Try it online!
Takes left, middle, right as  1,0,-1


text:
Upward and onward to greater glory!
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:

Finally, what does “Excelsior” mean? “Upward and onward to greater glory!”  That’s what I wish you whenever I finish tweeting! Excelsior!

Challenge
Given a series of non-negative integers, output a line with Excelsior! every time an integer is greater than the previous one.
Rules

Input will be an array of non-negative integers.
Output will consist of lines with the word Excelsior (case does matter) followed by as many ! as the length of the current run of increasingly greater numbers. You can also return an array of strings.
Input and output formats are flexible according to the site rules, so feel free to adapt them to your language formats. You can also add spaces at the end of the lines, or even extra new lines after or before the text if you need.

Examples
Input             Output
-----------------------------------
[3,2,1,0,5]       Excelsior!      // Excelsior because 5 > 0

[1,2,3,4,5]       Excelsior!      // Excelsior because 2 > 1
                  Excelsior!!     // Excelsior because 3 > 2 (run length: 2)
                  Excelsior!!!    // Excelsior because 4 > 3 (run length: 3)
                  Excelsior!!!!   // Excelsior because 5 > 4 (run length: 4)

[]                <Nothing>

[42]              <Nothing>

[1,2,1,3,4,1,5]   Excelsior!      // Excelsior because 2 > 1
                  Excelsior!      // Excelsior because 3 > 1
                  Excelsior!!     // Excelsior because 4 > 3 (run length: 2)
                  Excelsior!      // Excelsior because 5 > 1

[3,3,3,3,4,3]     Excelsior!      // Excelsior because 4 > 3

This is code-golf, so may the shortest code for each language win!

ouflak assumes integers are 1 digit long, is that ok

@ASCII-only not really. I don't know if LUA has a limitation with that, but if that's not the case ouflak should parse integers of any length.

@Charlie I don't know Lua, but although it's verbose, it is possible to take for example a space-delimited input and split like this.

I'm looking at it. The trick is to be able to handle both scenarios.

FWIW languages like C or Javascript will only handle integers within its precision (9/16 digits) anyway.

@user202729 I meant "any length handled by your language". :-)

Pedantically: C (the language) can handle any length up to computer memory/addressable memory, but the int type can only handle ~9 digits.

JavaScript (ES6), 58 54 bytes
a=>a.map(c=>a<(a=c)?`Excelsior${s+='!'}
`:s='').join``

Try it online!
Commented
a =>                           // a[] = input array, also used to store the previous value
  a.map(c =>                   // for each value c in a[]:
    a <                        //   compare the previous value
    (a = c)                    //   with the current one; update a to c
                               //   this test is always falsy on the 1st iteration
    ?                          //   if a is less than c:
      `Excelsior${s += '!'}\n` //     add a '!' to s and yield 'Excelsior' + s + linefeed
    :                          //   else:
      s = ''                   //     reset s to an empty string and yield an empty string
  ).join``                     // end of map(); join everything

Why re-using a[ ] to store the previous value is safe
There are three possible cases:

If \$a[\text{ }]\$ is empty, the callback function of .map() is not invoked at all and we just get an empty array, yielding an empty string.
If \$a[\text{ }]\$ contains exactly one element \$x\$, it is coerced to that element during the first (and unique) test a < (a = c). So, we're testing \$x < x\$, which is falsy. We get an array containing an empty string, yielding again an empty string.
If \$a[\text{ }]\$ contains several elements, it is coerced to NaN during the first test a < (a = c). Therefore, the result is falsy and what's executed is the initialization of \$s\$ to an empty string -- which is what we want. The first meaningful comparison occurs at the 2nd iteration.

Python 2, 84 83 81 70 68 bytes
a=n=''
for b in input():
 n+='!';n*=a<b;a=b
 if n:print'Excelsior'+n

Try it online!
-2 bytes, thanks to ASCII-only

68?

functions are too long :(

well, recursive approaches at least

same with zip

05AB1E, 26 24 23 bytes
ü‹γvyOE.•1Š¥èò²•™N'!×«,

-2 bytes thanks to @Kroppeb.
Try it online or verify all test cases.
Explanation:
ü                        # Loop over the (implicit) input as pairs
 ‹                       #  And check for each pair [a,b] if a<b is truthy
                         #   i.e. [1,2,1,3,4,1,5,7,20,25,3,17]
                         #   → [1,0,1,1,0,1,1,1,1,0,1]
  γ                      # Split it into chunks of equal elements
                         #  i.e. [1,0,1,1,0,1,1,1,1,0,1]
                         #   → [[1],[0],[1,1],[0],[1,1,1,1],[0],[1]]
   vy                    # Foreach `y` over them
     O                   #  Take the sum of that inner list
                         #   i.e. [1,1,1,1] → 4
                         #   i.e. [0] → 0
      E                  #  Inner loop `N` in the range [1, length]:
       .•1Š¥èò²•         #   Push string "excelsior"
                ™        #   Titlecase it: "Excelsior"
                 N'!×«  '#   Append `N` amount of "!"
                         #    i.e. N=3 → "Excelsior!!!"
                      ,  #   Output with a trailing newline

See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•1Š¥èò²• is "excelsior".

I don't really know 05AB1E but can't you exchange the 0Kg with O?

@Kroppeb Ah, completely missed that, but yes, I indeed can. Thanks! :)

Perl 6, 60 58 57 bytes
-1 byte thanks to nwellnhof
{"Excelsior"X~("!"Xx grep +*,[\[&(-+^*×*)]] .skip Z>$_)}

Try it online!
Anonymous code block that returns a list of Excelsiors!

Java-8 118 113 Bytes
n->{String e="";for(int i=0;i<n.length-1;)System.out.print(""==(n[i+1]>n[i++]?e+="!":(e=""))?e:"Excelsior"+e+"\n");}

Easy to read :
private static void lee(int num[]) {
    String exclamation = "";
    for (int i = 0; i < num.length - 1;) {
        exclamation = num[i + 1] > num[i++] ? exclamation += "!" : "";
        System.out.print("".equals(exclamation) ? "" : "Excelsior" + exclamation + "\n");
    }
}

Here some golfs to save 10 bytes: n->{var e="";for(int i=0;i<n.length-1;System.out.print(""==e?e:"Excelsior"+e+"\n"))e=n[i++]<n[i]?e+="!":"";}. Try it online (108 bytes). (Java 10+)

n->{for(int e=0,i=0;i<n.length-1;)if(n[i++]<n[i])System.out.println("Excelsior"+"!".repeat(e++));else e=0;} (107 bytes)

Fixing my issue: ++e instead of e++ so that there is at least one ! to be printed.

@KevinCruijssen Small typo in your golf to make you gain one byte: e=...?e+"!": instead of e=...?e+="!":.

Japt -R, 25 22 bytes
ò¨ ËÅ£`ExlÐâ`ú'!Y+A
c

Try it
3 bytes saved thanks to Kamil
ò¨                      :Partition at items that are greater than or equal to the previous item
   Ë                    :Map
    Å                   :  Slice off the first element
     £                  :  Map each element at 0-based index Y
      `ExlÐâ`           :    Compressed string "Excelsior"
             ú'!        :    Right pad with exclamation marks
                Y+A     :     To length Y+10
c                       :Flatten
                        :Implicitly join with newlines & output

Another 25 bytes

The -R flag isn't actually necessary, the challenge says you can output an array of strings.

Nice one, thanks, @KamilDrakari. I tried a solution using slice on my first pass but dismissed it when it worked out too long. Coming back to it now, with your prompting, I guess I should have stuck with it 'cause I got it down to 22 too.

05AB1E, 20 19 bytes
ü‹0¡€ƶ˜ε'!×”¸Îsiorÿ

Try it online!
Explanation
ü‹                    # pair-wise comparison, less-than
  0¡                  # split at zeroes
    €ƶ                # lift each, multiplying by its 1-based index
      ˜               # flatten
       ε              # apply to each
        '!×           # repeat "!" that many times
                  ÿ   # and interpolate it at the end of
           ”¸Îsior    # the compressed word "Excel" followed by the string "sior"

C (gcc/clang), 106 99 97 bytes
f(a,n)int*a;{int r=0,s[n];for(memset(s,33,n);n-->1;)r*=*a<*++a&&printf("Excelsior%.*s\n",++r,s);}

Thanks to gastropner for golfing 2 bytes.
Try it online here.
Ungolfed:
f(a, n) // function taking a pointer to the first integer and the length of the array
  int *a; { // a is of type pointer to int, n is of type int

    int r = 0, // length of the current run
        i = 0, // loop variable
        s[n];  // buffer for exclamation marks; we will never need more than n-1 of those (we are declaring an array of int, but really we will treat it as an array of char)

    for(memset(s, 33, n); // fill the buffer with n exclamation marks (ASCII code 33)
        n -- > 1; ) // loop over the array

        r *= *a < *(++ a) // if the current element is less than the next:
             && printf("Excelsior%.*s\n", // print (on their own line) "Excelsior", followed by ...
                       ++ r, // ... r (incremented) of the ...
                       s) // ... n exclamation marks in the buffer s
             ; // else r is reset to 0

}

I started making a solution, but ended up so close to yours that posting mine as a separate answer felt a bit silly. Still, the few differences there are can save you a few bytes.

@gastropner Thanks for sharing your version. I have incorporated your improvements and golfed it further to 99 bytes. If only we didn't need to handle the empty array – otherwise it would be 97 bytes, using your style of loop.

R, 86 bytes
Half of this answer is @Giuseppe's. RIP Stan Lee.
function(a)for(i in diff(a))"if"(i>0,cat("Excelsior",rep("!",F<-F+1),"
",sep=""),F<-0)

Try it online!

Common Lisp, 111 bytes
(setq i 0)(loop for(a b)on(read)do(incf i(if(and b(> b a))1(- i)))(format(> i 0)"Excelsior~v@{~a~:*~}~%"i #\!))

Try it online!

R, 111 bytes
function(a,r=rle(sign(diff(a))),v=r$l[r$v>0])write(paste0(rep("Excelsior",sum(v)),strrep("!",sequence(v))),1,1)

Try it online!
A far better R tribute can be found here -- I was too fixated on sequence and rle.

This doesn't give some blank lines, but 86 bytes?

@J.Doe dang, that's way better. I'd post that myself if I were you.

Java 8, 106 bytes
n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]<n[i]?"Excelsior"+(s+="!")+"\n":(s="")+s;return z;}

Try it online!
(those reassignments of s...yikes)

You can golf two more bytes by replacing (s="")+s => (s="")

n->{String s="",z=s;for(int i=0;i<n.length-1;)z+=n[i++]>=n[i]?s="":"Excelsior"+(s+="!")+"\n";return z;} (103 bytes) Move the s="" to spare bytes.

Stax, 17 bytes
Θx7├╖&σ '@7g┼┘Ñ«═

Run and debug it

Jelly, 16 bytes
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ

A monadic Link yielding a list of lists of characters.
Try it online! (footer joins with newlines)
How?
<Ɲṣ0ÄẎ”!ẋ“Ø6ḥ»;Ɱ - Link: list of integers     e.g. [1,1,4,2,1,1,3,4]
 Ɲ               - for each pair of integers:      [1,1] [1,4] [4,2] [2,1] [1,1] [1,3] [3,4]
<                -   less than?                    [  0,    1,    0,    0,    0,    1,    1]
  ṣ0             - split at zeros                  [[],    [1],     [],   [],      [1,    1]]
    Ä            - cumulative sums                 [[],    [1],     [],   [],      [1,    2]]
     Ẏ           - tighten                         [1,1,2]
      ”!         - literal '!' character           '!'
        ẋ        - repeat (vectorises)             [['!'],['!'],['!','!']]
         “Ø6ḥ»   - dictionary lookup               ['E','x','c','e','l','s','i','o','r']
               Ɱ - map with:
              ;  -   concatenate                   [['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!'],['E','x','c','e','l','s','i','o','r','!','!']]

Perl 5 -n, 41 bytes
$_>$l&&$l?say$c.='!':($c=Excelsior);$l=$_

Try it online!
Takes its input on separate lines.

PowerShell, 87 85 bytes
param($n)for(;++$i-lt$n.count){if($n[$i]-gt$n[$i-1]){"Excelsior"+"!"*++$c}else{$c=0}}

Try it online!
There's probably a restructuring hiding in there, most likely in the if-else, but overall pretty alright. Uses the ol' "Un-instantiated variable defaults to 0" trick for both making the index and the !.

Powershell, 69 bytes
$args|%{if($o-ne$e-and$_-gt$o){'Excelsior'+'!'*++$c}else{$c=0}$o=$_}

Less golfed test script:
$f = {

$args|%{
    if($old-ne$empty-and$_-gt$old){
        'Excelsior'+'!'*++$c
    }else{
        $c=0
    }
    $old=$_
}

}

@(
    ,( (3,2,1,0,5),  'Excelsior!')      # Excelsior because 5 > 0

    ,( (1,2,3,4,5),  'Excelsior!',      # Excelsior because 2 > 1
                    'Excelsior!!',     # Excelsior because 3 > 2 (run length: 2)
                    'Excelsior!!!',    # Excelsior because 4 > 3 (run length: 3)
                    'Excelsior!!!!')   # Excelsior because 5 > 4 (run length: 4)

    ,( $null,         '')                # <Nothing>

    ,( (42),          '')                # <Nothing>

    ,( (1,2,1,3,4,1,5), 'Excelsior!',      # Excelsior because 2 > 1
                        'Excelsior!',      # Excelsior because 3 > 1
                        'Excelsior!!',     # Excelsior because 4 > 3 (run length: 2)
                        'Excelsior!')      # Excelsior because 5 > 1

    ,( (3,3,3,3,4,3),   'Excelsior!')      # Excelsior because 4 > 3
) | % {
    $a,$expected = $_
    $result = &$f @a
    "$result"-eq"$expected"
    $result
}

Output:
True
Excelsior!
True
Excelsior!
Excelsior!!
Excelsior!!!
Excelsior!!!!
True
True
True
Excelsior!
Excelsior!
Excelsior!!
Excelsior!
True
Excelsior!

There it is, I was trying to get a lag pointer to work but couldn't think of how.

Japt, 22 bytes
ò¨ ®£`ExlÐâ`+'!pYÃÅÃc

Try it online!
Explanation, with simplified example:
ò¨                       :Split whenever the sequence does not increase
                           e.g. [2,1,1,3] -> [[2],[1],[1,3]]
   ®               Ã     :For each sub-array:
    £            Ã       :  For each item in that sub-array:
     `ExlÐâ`             :    Compressed "Excelsior"
            +            :    Concat with
             '!pY        :    a number of "!" equal to the index
                               e.g. [1,3] -> ["Excelsior","Excelsior!"]
                  Å      :  Remove the first item of each sub-array
                            e.g. [[Excelsior],[Excelsior],[Excelsior,Excelsior!]]->[[],[],[Excelsior!]]
                    c    :Flatten
                           e.g. [[],[],[Excelsior!]] -> [Excelsior!]

Lua, 88 87 83 82 96 95 113 bytes
Thanks @Kevin Cruijssen for update adhering to spirit of original question.
s=io.read()n=9 e="Excelsior!"f=e
for c in s.gmatch(s,"%S+")do if n<c+0then print(e)e=e..'!'else e=f end n=c+0 end

Try it online!

Sorry but you need to print the exclamation mark according to the rules (one exclamation mark per length of the current run of increasingly greater numbers).

No problem. Think I've done as much as I can do here unless someone else sees something...

I don't know Lua too well, but here is a fix for your code so it runs all test cases correctly Currently you just print an "!" more every time a number is higher than the previous, but you don't reset it back to 1 when that isn't the case. More can probably be golfed, but since I've never golfed in Lua I focused on fixing it with only minor golfs. PS: Not sure if assuming the input are always single digits is correct..

Since @Charlie mentioned in a comment below the challenge description that it should be possible to take multi-digits numbers as input, here a possible fix by taking a space-delimited input and split on it.

I decided that Kevin Cruijssen modifications are more inline with the OP's expectation. Thanks!

Retina, 55 bytes
\d+
*
L$rv`(_*,(?<!(?(1)\1|\2,)))+(_+)\b
Excelsior$#1*!

Try it online! Link includes test cases. Explanation:
\d+
*

Convert to unary.
rv`(_*,(?<!(?(1)\1|\2,)))+(_+)\b

Process overlapping matches from right to left (although the matches are then listed from left to right). This means that we can match every number in a run, and the match extends to the start of the run. Each match is further constrained that each additional matched number must be less than the previously matched additional number, or the first number if no additional numbers have been matched yet.
L$...
Excelsior$#1*!

For each match, output Excelsior with the number of additional numbers in the run as desired.

Pyth, 32 bytes
j+L"Excelsior"*L\!fT.u*hN<0Y.+Q0

Try it online here, or verify all the test cases at once here.
j+L"Excelsior"*L\!fT.u*hN<0Y.+Q0   Implicit: Q=eval(input())
                            .+Q    Get forward difference between consecutive elements of Q
                    .u         0   Reduce the above, returning all steps, with current value N starting at 0, next element as Y, using:
                       hN            N+1
                      *              Multiplied by
                         <0Y         1 if 0<Y, 0 otherwise
                  fT               Filter to remove 0s
              *L\!                 Repeat "!" each element number of times
 +L"Excelsior"                     Prepend "Excelsior" to each
j                                  Join on newlines, implicit print

Jelly, 18 bytes
<Ɲ‘×¥\ḟ0”!ẋ“Ø6ḥ»;Ɱ

Try it online!
Output prettified over TIO.

C++ 14 (g++), 123 118 bytes
[](auto a){for(int n=0,i=0;++i<a.size();)a[i]>a[i-1]?puts(&("Excelsior"+std::string(++n,33))[0]):n=0;}

Fortunately std::string has a constructor that repeats a char. Try it online here.
Thanks to gastropner for saving 5 bytes.
Ungolfed:
[] (auto a) { // void lambda taking a std::array of integer

    for(int n = 0, // length of the current run
        i = 0; // loop variable
        ++ i < a.size(); ) // start with the second element and loop to the last
        a[i] > a[i - 1] // if the current element is greater than the previous ...
        ? puts( // ... print a new line:
               &("Excelsior" + // "Excelsior, followed by ...
                std::string(++ n, 33)) // ... the appropriate number of exclamation marks (33 is ASCII code for '!'); increment the run length
               [0]) // puts() takes a C string
        : n = 0; // else reset run length

}

You can shave off another 5 bytes

C# (.NET Core), 115 107 105 bytes
a=>{var b="";for(int i=0;++i<a.Length;)if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));else b="";}

Try it online!
-8 bytes: changed b to a string holding "!"s from an int counter
-2 bytes: set b+="!" as an inline function (thanks to Zac Faragher)
Uses an Action delegate to pull in the input and not require a return.
Ungolfed:
a => {
    var b = "";                         // initialize the '!' string (b)
    for(int i = 0; ++i < a.Length;)     // from index 1 until the end of a
        if(a[i] > a[i - 1])                 // if the current index is greater than the previous index
            Console.WriteLine("Excelsior" +     // on a new line, print "Excelsior"
                                    (b += "!"));    // add a "!" to b, and print the string
        else                                // if the current index is not greater than the previous index
            b = "";                             // reset b
}

you can save 2 bytes by making the b+="!" inline with the Excelsior
if(a[i]>a[i-1])Console.WriteLine("Excelsior"+(b+="!"));
Try it online!

J, 50 bytes
'Excelsior',"1'!'#"0~[:;@(([:<+/\);._1)0,2</\ ::0]

Try it online!
ungolfed
'Excelsior' ,"1 '!' #"0~ [: ;@(([: < +/\);._1) 0 , 2 </\ ::0 ]

PHP, 117 109 bytes
<?php do{$i=next($argv);if($p!==null&&$p<$i){$e.='!';echo "
Excelsior$e";}else$e='';$p=$i;}while($i!==false);

Try it online!

Java, 113 bytes
String i="";for(int a=0;a<s.length-1;a++){if(s[a+1]>s[a]){i+="!";System.out.println("Excelsior"+i);}else{i="";}}

VBA, 114 bytes
For i=0 To UBound(a)-LBound(a)-1 If a(i+1)>a(i)Then s=s&"!" Debug.Print("Excelsior"&s&"") Else s="" End If Next i

Unfortunately, this is not a valid solution as it relies on having an explicitly defined variable, a. That said, if you define the function as a subroutine that takes the input as a variant of expected type array, then you can turn your approach into a valid solution. A Golfed version of that approach would look like
sub f(x)
For i=0To UBound(x)-1
If x(i+1)>x(i)Then s=s+"!":Debug.?"Excelsior"s:Else s=""
Next
End Sub, where the breaks between code block represent new lines

Japt, 25 bytes
ä< ®?`ExlÐâ`+'!p°T:T=0
f

Try it online!


text:
Hide the buildings
Shorter version of Skyscrapers Challenge
Task
Given an array of building heights and a positive integer k, find all the permutations(without duplicates) of the heights such that exactly k buildings are visible.
Any building will hide all shorter or equal height buildings behind it.
Any format for input and output is valid.
Input array will never be empty.
In case it is not possible to see exactly as many buildings, output anything that cannot be an answer but no error.
Examples:
(Length of output is shown for very long outputs,but your output should be all possible permutations)
input:[1,2,3,4,5],2
output: 50

input:[5,5,5,5,5,5,5,5],2
output: []

input:[1,2,2],2
output:[(1,2,2)]
Seeing from the left, exactly 2 buildings are visible.

input:[1,7,4],2
output:[(4, 7, 1), (1, 7, 4), (4, 1, 7)]

input:[1,2,3,4,5,6,7,8,9],4
output:67284

input:[34,55,11,22],1
output:[(55, 34, 11, 22), (55, 22, 34, 11), (55, 34, 22, 11), (55, 11, 34, 22), (55, 22, 11, 34), (55, 11, 22, 34)]

input:[3,4,1,2,3],2
output:31

This is code-golf so shortest code wins
Optional: If possible, can you add something like if length is greater than 20: print length else print answer. In the footer, not in the code.

Should the output be all qualifying permutations, or the number thereof?

It should be all qualifying permutations @LuisMendo

Suggested test case: [1,2,3,4,5],5 -> [(1,2,3,4,5)]. None of the current test cases ensure that answers can support showing all buildings (though I don't know whether any actually have a problem with that).

05AB1E, 10 9 bytes
œÙʒη€àÙgQ

Try it online or verify (almost) all test cases (test case [1,2,3,4,5,6,7,8,9],4 times out).
Footer of the TIO does what OP asked at the bottom:

Optional: If possible, can you add something like if length is greater than 20: print length else print answer. In the footer, not in the code.

Explanation:
œ            # Permutations of the (implicit) input-list
             #  i.e. [1,2,2] → [[1,2,2],[1,2,2],[2,1,2],[2,2,1],[2,1,2],[2,2,1]]
 Ù           # Only leave the unique permutations
             #  i.e. [[1,2,2],[1,2,2],[2,1,2],[2,2,1],[2,1,2],[2,2,1]]
             #   → [[1,2,2],[2,1,2],[2,2,1]]
  ʒ          # Filter it by:
   η         #  Push the prefixes of the current permutation
             #   i.e. [1,2,2] → [[1],[1,2],[1,2,2]]
    €à       #  Calculate the maximum of each permutation
             #   i.e. [[1],[1,2],[1,2,2]] → [1,2,2]
      Ù      #  Only leave the unique maximums
             #   i.e. [1,2,2] → [1,2]
       g     #  And take the length
             #   i.e. [1,2] → 2
        Q    #  And only leave those equal to the second (implicit) input
             #   i.e. 2 and 2 → 1 (truthy)

Impressive, every single byte here is part of the function tree!

@lirtosiast Yeah, 05AB1E has some pretty short builtins sometimes, which were perfect in this challenge. :) It's actually very similar to your Pyth answer I see. Funny thing is, is that the footer for if length is greater than 20: print length; else print answer; is a̶ ̶b̶y̶t̶e̶ ̶l̶o̶n̶g̶e̶r̶  of equal length in comparison to the program itself. xD

Haskell, 73 bytes
import Data.List
f n=filter((n==).length.nub.scanl1 max).nub.permutations

Try it online!

Jelly, 12 10 bytes
Œ!Q»\QL=ʋƇ

Try it online!
-2 bytes by @Erik the Outgolfer
This is a dyadic function taking the building heights and k in that order.
Œ!                All permutations of first input
Œ!Q               Unique permutations of first input
   »\              Running maximum
     Q             Unique values
      L            Length of this array
       =           Equals k
        ʋ        Create a monad from these 4 links
   »\QL=ʋ        "Are exactly k buildings visible in arrangement x?"
         Ƈ     Filter if f(x)
Œ!Q»\QL=ʋƇ     All distinct perms of first input with k visible buildings.

Hail the new ʋ! (it's pretty older than Ƈ, actually :P)

Pyth, 18 16 bytes
fqvzl{meSd._T{.p

Try it here.
Note that the online version of the Pyth interpreter throws a memory error on the largest test case.
f                       Filter lambda T:
  q                       Are second input and # visible buildings equal?
    v z                     The second input value
    l {                     The number of unique elements in
        m                   the maximums
          e S d             ...
          ._ T              of prefixes of T
    { .p                  over unique permutations of (implicit first input)

Welcome back! :-)

Perl 6, 81 63 bytes
-18 bytes thanks to nwellnhof!
{;*.permutations.unique(:with(*eqv*)).grep:{$_==set [\max] @_}}

Try it online!
Anonymous code block that takes input curried, e.g. f(n)(list). That .unique(:with(*eqv*)) is annoyingly long though :(
Explanation:
{;                                                            }  # Anonymous code block
  *.permutations.unique(:with(*eqv*))  # From all distinct permutations
                                     .grep:{                 }  # Filter where
                                                set [\max] @_   # Visible buildings
                                            $_==      # Equals num

FWIW, I just filed a Rakudo issue so we might get rid of that annoying ; eventually ;)

Japt, 11 bytes
á f_åÔâ Ê¥V

Try it online!
For the longer outputs, adding } l to the end will output the length instead. The online interpreter times out for the [1,2,3,4,5,6,7,8,9],4 test case, regardless of outputting the length or the list.
Explanation:
á              :Get all permutations
  f_           :Keep only ones where:
    åÔ         : Get the cumulative maximums (i.e. the visible buildings)
      â Ê      : Count the number of unique items
         ¥V    : True if it's the requested number

JavaScript (ES6), 108 107 bytes
Takes input as (k)(array). Prints the results with alert().
k=>P=(a,p=[],n=k,h=0)=>a.map((v,i)=>P(a.filter(_=>i--),[...p,v],n-(v>h),v>h?v:h))+a||n||P[p]||alert(P[p]=p)

Try it online!
Commented
k =>                        // k = target number of visible buildings
  P = (                     // P = recursive function taking:
    a,                      //   a[] = list of building heights
    p = [],                 //   p[] = current permutation
    n = k,                  //   n = counter initialized to k
    h = 0                   //   h = height of the highest building so far
  ) =>                      //
    a.map((v, i) =>         // for each value v at position i in a[]:
      P(                    //   do a recursive call:
        a.filter(_ => i--), //     using a copy of a[] without the i-th element
        [...p, v],          //     append v to p[]
        n - (v > h),        //     decrement n if v is greater than h
        v > h ? v : h       //     update h to max(h, v)
      )                     //   end of recursive call
    )                       // end of map()
    + a ||                  // unless a[] was not empty,
    n ||                    // or n is not equal to 0,
    P[p] ||                 // or p[] was already printed,
    alert(P[p] = p)         // print p[] and store it in P

Husk, 9 bytes
fȯ=⁰Lü≤uP

Try it online!

Python 2, 114 113 bytes
lambda a,n:{p for p in permutations(a)if-~sum(p[i]>max(p[:i])for i in range(1,len(p)))==n}
from itertools import*

Try it online!
-1 byte, thanks to ovs

Python 3, 113 bytes
lambda a,n:{p for p in permutations(a)if sum(v>max(p[:p.index(v)]+(v-1,))for v in{*p})==n}
from itertools import*

Try it online!

J, 43 38 bytes
-5 bytes after incorporating an optimization from Kevin's O5AB13 answer
(]#~[=([:#@~.>./\)"1@])[:~.i.@!@#@]A.]

Try it online!
ungolfed
(] #~ [ = ([: #@~. >./\)"1@]) ([: ~. i.@!@#@] A. ])

explanation
we're merely listing all possible perms i.@!@#@] A. ], taking uniq items thereof with ~., then filtering those by the number of visible building, which must equal the left input.
the key logic is in the parenthetical verb which calcs the number of visible buildings:
([: #@~. >./\)

Here we use a max scan >./\ to keep a tally of the tallest building seen so far.  Then we just take the unique elements of the max scan, and that's the number of visible buildings.


text:
Sort by Largest Digit(s)
Challenge:
Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc.
We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the list can be in any way you'd like.
Example:
Input:            [123, 478, -904, 62778, 0, -73, 8491, 3120, 6458, -7738, 373]
Possible outputs: [8491, -904, 62778, 478, -7738, 6458, 373, -73, 3120, 123, 0]
                  [8491, -904, 62778, 478, -7738, 6458, -73, 373, 3120, 123, 0]

Why? Here are the relevant digits the numbers were sorted on:
Output:
[8491,  -904,  62778,   478,     -7738,   6458,  373,   -73,   3120,      123,     0  ]

Relevant digits they were sorted on:
[[9,8], [9,4], [8,7,6], [8,7,4], [8,7,3], [8,6], [7,3], [7,3], [3,2,1,0], [3,2,1], [0]]

Challenge rules:

We ignore duplicated digits, so 478 and -7738 will be ordered as 478, -7738, because the largest digits are [8,7,4] and [8,7,3], and not [8,7,4] and [8,7,7,3].
If multiple numbers have the same digits, the order of those can be either way. So 373 and -73 can be sorted as both 373, -73 or -73, 373 (digits are [7,3] for both of these numbers).
If a number contains no more digits to check, it will be placed at the back of the relevant numbers. So 123 and 3120 will be sorted as 3120, 123, because the largest digits [3,2,1] are the same, but 0 comes before none.
You can assume all numbers in the input are in the range [-999999,999999].
Just one of the possible outputs is enough as result, but you are allowed to output all possible outputs where sublists can be in any permutation if you want (although I doubt it would save bytes in any language).

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
Input:            [123, 478, -904, 62778, 0, -73, 8491, 3120, 6458, -7738, 373]
Possible outputs: [8491, -904, 62778, 478, -7738, 6458, 373, -73, 3120, 123, 0]
                  [8491, -904, 62778, 478, -7738, 6458, -73, 373, 3120, 123, 0]

Input:            [11, -312, 902, 23, 321, 2132, 34202, -34, -382]
Possible outputs: [902, -382, 34202, -34, -312, 321, 2132, 23, 11]
                  [902, -382, 34202, -34, 2132, -312, 321, 23, 11]
                  etc. The sublist [-312, 321, 2132] can be in any permutation

Input:            [9, 44, 2212, 4, 6, 6, 1, 2, 192, 21, 29384, 0]
Possible outputs: [29384, 192, 9, 6, 6, 4, 44, 2212, 21, 2, 1, 0]
                  [29384, 192, 9, 6, 6, 44, 4, 2212, 21, 2, 1, 0]
                  etc. The sublists [4, 44] and [2212, 21] can be in any permutation

Input:            [44, -88, 9, 233, -3, 14, 101, 77, 555, 67]
Output:           [9, -88, 67, 77, 555, 14, 44, 233, -3, 101]

05AB1E, 5 bytes
ΣêR}R

Try it online!
or as a Test suite
Explanation
Σ  }    # sort input by
 ê      # its sorted unique characters
  R     # reversed (to sort descending)
    R   # reverse the result (to sort descending)

Brachylog, 9 bytes
{ȧdṫo₁}ᵒ¹

Note: due to how ordering works in brachylog, it does not work on number correctly. This is fixed by casting the number to a string (ṫ) at the cost of 1 byte.
Try it online!

What do you mean by "Due to how ordering works in brachylog, it does not work as intended."? I've tried all four test cases, and its giving the correct results (unless I accidentally looked past something).

@KevinCruijssen The ṫ (to string) fixes the issue. Ordering digits in a number descending works as follows. Order from smallest to largest then reverse. The problem is that the number 3120 ordered from smallest to largest is 0123 which is equal to 123which reversed is 321and not 3210

Ah ok, so your current code is working due to the added toString (ṫ). As mentioned by @Arnauld, I thought your comment meant your current code doesn't work. It might be better to mention it like: "This could have been 8 bytes by removing the ṫ (toString), but unfortunately it does not work as intended due to how ordering works in Brachylog."

Looking at what I wrote it seems that my brain got distracted midsentence. Fixed it.

Perl 6, 36 34 33 31 bytes
-1 byte thanks to Jo King
-2 bytes thanks to Phil H
*.sort:{sort 1,|set -<<m:g/\d/}

Try it online!
Explanation
       {                      }  # Map each number, e.g. -373
                       m:g/\d/  # Extract digits: (3, 7, 3)
                    -<<  # Negate each digit: (-3, -7, -3)
                set  # Convert to set to remove duplicates
               |  # Pass as list of pairs: (-3 => True, -7 => True)
             1,  # Prepend 1 for "none": (1, -3 => True, -7 => True)
        sort  # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort:  # Sort lexicographically

Nice! -2 bytes for swapping m:g/\d./ for .abs.comb: https://tio.run/##HU1LCsIwEN17ilmIqCSazKSdxM9JVESwdaMorRtRz17fCOU17zuPprvWw@1Fk5a2w3zR37vn6m1I0X365kl@s7mtLsv9efkd1qP@9KJ2Oj7OqL13o11kcZQ0O/IlJEc1q5EArnByKtGRRIZQp8piqoKfqBwc6nA9bEclAGxMGBpHAZXEpnpJBpmtUXAOlNlKdvD/WQVYbMPeRTK8YAVL@4yTxfbFlpCEGAOSqo6qqsKIHoYf

R, 97 95 bytes
function(x)x[rev(order(sapply(Map(sort,Map(unique,strsplit(paste(x),"")),T),Reduce,f=paste0)))]

Try it online!
This challenge seems to have been pessimized for R. Explanation of the original version (start at 1. and work up):
f <- function(x) {
  x[                                                  # 8. Input vector in
    rev(                                              # 7. Reversed
        order(                                        # 6. Lexicographical order
              sapply(                                 # 5. Paste....
                     Map(sort,                        # 4. Sort each using...
                              Map(unique,             # 3. Deduplicate each
                                  strsplit(           # 2. Split each string into characters
                                           paste(x),  # 1. Coerce each number to string
                                           "")),
                         T),                          # 4. ...descending sort.
                     paste,collapse="")               # 5. ...back into strings
              )
        )
    ]
}

Python 2, 60 55 54 bytes
-1 byte thanks to Jonas Ausevicius.
def f(l):l.sort(cmp,lambda n:sorted(set(`n`))[::-1],1)

Try it online!

Ungolfed
def f(l):
  l.sort(        # Sort the list in place
    cmp = cmp,   # ... compare with the builtin function cmp
    key = k,     # ... on the function k
    reverse = 1  # ... in reverse
  )              # As the arguments are used in the right order, no names are necessary.

k = lambda n:sorted( # sort
  set(`n`)           # ... the set of digits
  )[::-1]            # reverse the result
                     # As '-' is smaller than the digits,
                     # it will be sorted to the back and ignored for sorting

Try it online!

None can be replaced with cmp in sort function

The [::-1] can be exchanged for a double negation, I think.

@DonQuiKong that would be quite a bit longer though, as the digits are all strings, and would need to be converted to ints for this.

@JonasAusevicius Thanks a lot.

Python 2, 58 60 bytes
lambda a:sorted(a,key=lambda x:sorted(set(`x`))[::-1])[::-1]

Try it online!

Pyth, 7 6 bytes
-1 byte by @Sok
_o_{S`

Pyth, which uses only printable ASCII, is at a bit of a disadvantage here. Optimally encoded this would be 6*log(95)/log(256) = 4.927 bytes, beating 05AB1E.
Explained:
 o              Sort the implicit input by lambda N:
  _               reversed
   {               uniquified
    S               sorted
     '               string representation [of N]
_               then reverse the result.

Try it here.

The trailing N can be left out to save 1 byte - all lambda-type functions infer the presence of the principle lambda variable if any arguments are missing from the end. Examples include m inferring d, f inferring T, u inferring G...

Jelly, 8 bytes
ADṢUQµÞU

Try it online!
How it works
ADṢUQµÞU  Main link (monad). Input: integer list
     µÞU  Sort by (reversed):
AD        Absolute value converted to decimal digits
  ṢUQ     Sort, reverse, take unique values

I just implemented this then found your post. I went with normal reverses, Ṛ, rather than the upends, U. Note, however, that you do not need the D since sort, Ṣ, is implemented with an iterable(z, make_digits=True) call inside. So that was AṢQṚµÞṚ for 7.

Julia 1.0, 50 47 bytes
x->sort(x,by=y->sort(∪([digits(-abs(y));1])))

Try it online!
-3 bytes by Ashlin Harris.

-3 bytes by swapping ∪ (union) for unique

I think 1Udigits() works for -5 bytes

MathGolf, 7 6 bytes
áÉ░▀zx

Try it online! or as a test suite.
Explanation
After looking at Emigna's 05AB1E solution, I found that I didn't need the absolute operator (and my previous answer was actually incorrect because of that operator). Now the main difference is that I convert to string and get unique characters instead of using the 1-byte operator in 05AB1E.
áÉ      Sort by the value generated from mapping each element using the next 3 instructions
  ░     Convert to string
   ▀    Get unique characters
    z   Sort reversed (last instruction of block)
     x  Reverse list (needed because I don't have a sort-reversed by mapping)

C (gcc), 114 111 109 bytes
a;v(n){n=n<0?-n:n;for(a=0;n;n/=10)a|=1<<n%10;n=a;}c(int*a,int*b){a=v(*a)<v(*b);}f(a,n)int*a;{qsort(a,n,4,c);}

Try it online!
Explanation:
f() uses qsort() to sort provided array in place. Using comparison function c() to compare numbers which evaluates numbers using v().
v() calculates a higher number if bigger digits are present in parameter.
[Edit 1]
Improved by 3 bytes. 2 byte credits to Kevin. Thanks
[Edit 2] 2 more bytes improved. Credits to gastropner. Thanks

You can golf n>0 to n I think in your loop of your method v.

f()'s argument list int*a,n can be shortened to int*a.

Suggest for(a=0;n=abs(n); instead of n=n<0?-n:n;for(a=0;n;

Japt, 12 bytes
ñ_a ì â ñnÃw

All test cases
Explanation:
ñ_        Ãw    :Sort Descending by:
  a             : Get the absolute value
    ì           : Get the digits
      â         : Remove duplicates
        ñn      : Sort the digits in descending order

Haskell, 54 52 bytes
import Data.List
f=r.sortOn(r.sort.nub.show);r=reverse

Try it online!

Defining r=reverse saves two bytes. We also allow anonymous functions, so the f= does not need to ve counted.

I moved the import and f= to the TIO header. Is that OK?

Same byte count, but maybe of some interest: f=r$r id.nub.show;r=(reverse.).sortOn.

The import actually needs to be counted.

i reversed my edit

You may want to have a look at our Guide to golfing rules in Haskell.

Stax, 6 7 bytes
èó≥ü≤♥¥

Run and debug it

This seems to give incorrect results. For example, in the test case of your TIO it outputs -904 8491 478 62778 6458 -7738 -73 373 123 3120 0 instead of the intended 8491 -904 62778 478 -7738 6458 373 -73 3120 123 0 or 8491 -904 62778 478 -7738 6458 -73 373 3120 123 0. This test case is also used in the example, and to explain the rules, so I would take a look at that to understand it better. It seems you are only sorting by the single largest digit once, without any of the other rules?

@KevinCruijssen:  Yes, my apologies.  I mis-read the problem statement.  I've adjusted the program to handle the stated requirements.  This program is accepting the input integers as quoted strings.  That's usually acceptable, but if not I might need to add another byte.

Looks good now, +1 from me. And yes, inputting as strings is completely fine.

APL (Dyalog Extended), 19 bytes
{⍵[⍒∪¨(∨'¯'~⍨⍕)¨⍵]}

Try it online!
Fixed at a cost of +2 bytes thanks to OP.

I think you are missing an 'uniquify' somewhere? If I try the example test case in your TIO for example, ¯7738 is placed before 478, but it should be after it: digits [8,7,4] come before digits [8,7,3].

Thanks, @KevinCruijssen

JavaScript (SpiderMonkey), 68 bytes
Thanks for @Arnauld for reminding me again that SpiderMonkey uses stable sort, so -4 bytes for removing ||-1.
A=>A.sort((x,y,F=n=>[...new Set(""+n)].sort().reverse())=>F(x)<F(y))

Try it online!
JavaScript (Node.js), 72 bytes
A=>A.sort((x,y,F=n=>[...new Set(""+n)].sort().reverse())=>F(x)<F(y)||-1)

Try it online!

Or 68 bytes with SpiderMonkey.

@Arnauld oh stable sort again ;P

Actually, I think V8 is using at least 2 different sort algorithms. It seems like it's stable if the size of the array is less than or equal to $10$.

@Arnauld V8 use quick sort before Chrome 70. The quick sort algorithm perform an insertion sort when array size is small enough. And latest Chrome had changed to stable sort for matching other browsers' (IE/Firefox/Safari) behavior.

J, 17 bytes
{~[:\:~.@\:~@":@|

Try it online!
Explanation:
                @|    - find the absolute value and
             @":      - convert to string and
         @\:~         - sort down and
       ~.             - keep only the unique symbols
    \:                - grade down the entire list of strings
  [:                  - function composition
{~                    - use the graded-down list to index into the input

Java (JDK), 98 bytes
l->l.sort((a,b)->{int r=0,i=58;for(;r==0&i-->48;)r=(b.indexOf(i)>>9)-(a.indexOf(i)>>9);return r;})

Try it online!
Explanation
l->                           // Consumer<List<String>>
 l.sort(                      //  Use the incorporated sort method which uses a...
  (a,b)->{                    //   Comparator of Strings
   int r=0,                   //    define r as the result, initiated to 0
       i=58;                  //           i as the codepoint to test for.
   for(;r==0&i-->48;)         //    for each digit codepoint from '9' to '0',
                              //     and while no difference was found.
    r=                        //     set r as the difference between
     (b.indexOf(i)>>9)-       //      was the digit found in b? then 0 else -1 using the bit-shift operator
     (a.indexOf(i)>>9);       //      and was the digit found in a? then 0 else -1.
   return r;                  //    return the comparison result.
  }
 )

Note:
I needed a way to map numbers to either 0/1 or 0/-1.
indexOf has the nice property that it's consistently returning -1 for characters not found. -1 right-shifted by any number is always -1. Any positive number right-shifted by a big enough number will always produce 0.
So here we are:
input        input.indexOf('9')      input.indexOf('9')>>9
"999"        0                       0
"111119"     5                       0
"123456"     -1                      -1

Ah, yeah, that's what I mean. ;p Nice golf of using >>9 instead of >>32 due to the limited range of the numbers.

Ruby, 55 bytes
->a{a.sort_by{|x|x.abs.digits.sort.reverse|[]}.reverse}

Try it online!

APL(NARS), 366 chars, 732 bytes
_gb←⍬

∇a _s w;t
t←_gb[a]⋄_gb[a]←_gb[w]⋄_gb[w]←t
∇

∇(_f _q)w;l;r;ls;i
(l r)←w⋄→0×⍳l≥r⋄l _s⌊2÷⍨l+r⋄ls←i←l⋄→3
  →3×⍳∼0<_gb[i]_f _gb[l]⋄ls+←1⋄ls _s i
  →2×⍳r≥i+←1
l _s ls⋄_f _q l(ls-1)⋄_f _q(ls+1)r
∇

∇r←(a qsort)w
r←¯1⋄→0×⍳1≠⍴⍴w⋄_gb←w⋄a _q 1(↑⍴w)⋄r←_gb
∇

f←{∪t[⍒t←⍎¨⍕∣⍵]}

∇r←a c b;x;y;i;m
x←f a⋄y←f b⋄r←i←0⋄m←(↑⍴x)⌊(↑⍴y)⋄→3
→0×⍳x[i]<y[i]⋄→3×⍳∼x[i]>y[i]⋄r←1⋄→0
→2×⍳m≥i+←1⋄r←(↑⍴x)>(↑⍴y)
∇

For the qsort operator, it is one traslation in APL of algo page 139 K&R Linguaggio C.
I think in it there is using data as C with pointers...
Test
 c qsort 123, 478, ¯904, 62778, 0, ¯73, 8491, 3120, 6458, ¯7738, 373
8491 ¯904 62778 478 ¯7738 6458 ¯73 373 3120 123 0
 c qsort 11, ¯312, 902, 23, 321, 2132, 34202, ¯34, ¯382
902 ¯382 34202 ¯34 321 ¯312 2132 23 11
 c qsort 9, 44, 2212, 4, 6, 6, 1, 2, 192, 21, 29384, 0
29384 192 9 6 6 4 44 2212 21 2 1 0
 c qsort 44, ¯88, 9, 233, ¯3, 14, 101, 77, 555, 67
9 ¯88 67 77 555 14 44 233 ¯3 101

Powershell, 44 bytes
$args|sort{$_-split'(.)'-ne'-'|sort -u -d}-d

Test script:
$f = {

$args|sort{$_-split'(.)'-ne'-'|sort -u -d}-d

}

@(
    ,( (123, 478, -904, 62778, 0, -73, 8491, 3120, 6458, -7738, 373),
       (8491, -904, 62778, 478, -7738, 6458, 373, -73, 3120, 123, 0),
       (8491, -904, 62778, 478, -7738, 6458, -73, 373, 3120, 123, 0) )

    ,( (11, -312, 902, 23, 321, 2132, 34202, -34, -382),
       (902, -382, 34202, -34, -312, 321, 2132, 23, 11),
       (902, -382, 34202, -34, 2132, -312, 321, 23, 11) )

    ,( (9, 44, 2212, 4, 6, 6, 1, 2, 192, 21, 29384, 0),
       (29384, 192, 9, 6, 6, 4, 44, 2212, 21, 2, 1, 0),
       (29384, 192, 9, 6, 6, 44, 4, 2212, 21, 2, 1, 0),
       (29384, 192, 9, 6, 6, 44, 4, 21, 2212, 2, 1, 0) )

    ,( (44, -88, 9, 233, -3, 14, 101, 77, 555, 67),
       ,(9, -88, 67, 77, 555, 14, 44, 233, -3, 101) )
) | % {
    $a, $expected = $_
    $result = &$f @a
    $true-in($expected|%{"$result"-eq"$_"})
    "$result"
}

Output:
True
8491 -904 62778 478 -7738 6458 -73 373 3120 123 0
True
902 -382 34202 -34 2132 -312 321 23 11
True
29384 192 9 6 6 44 4 21 2212 2 1 0
True
9 -88 67 77 555 14 44 233 -3 101

PHP, 87 86 84 bytes
while(--$argc)$a[_.strrev(count_chars($n=$argv[++$i],3))]=$n;krsort($a);print_r($a);

Run with -nr or try it online.
Replace ++$i with $argc (+1 byte) to suppress the Notice (and render -n obosolete).
breakdown
while(--$argc)  # loop through command line arguments
    $a[                             # key=
        _.                              # 3. prepend non-numeric char for non-numeric sort
        strrev(                         # 2. reverse =^= sort descending
        count_chars($n=$argv[++$i],3)   # 1. get characters used in argument
        )
    ]=$n;                           # value=argument
krsort($a);     # sort by key descending
print_r($a);    # print

- is "smaller" than the digits, so it has no affect on the sorting.

Common Lisp, 88 bytes
(sort(read)'string> :key(lambda(x)(sort(remove-duplicates(format()"~d"(abs x)))'char>)))

Try it online!
Good old verbose Common Lisp!
Explanation:
(sort                   ; sort
 (read)                 ; what to sort: a list of numbers, read on input stream
 'string>               ; comparison predicate (remember: this is a typed language!)
 :key (lambda (x)       ; how to get an element to sort; get a number
       (sort (remove-duplicates  ; then sort the unique digits (characters)
               (format() "~d" (abs x))) ; from its string representation
             'char>)))  ; with the appropriate comparison operator for characters

C# (Visual C# Interactive Compiler), 75 74 bytes
-1 thanks @ASCII-only
x=>x.OrderByDescending(y=>String.Concat((y+"").Distinct().OrderBy(z=>-z)))

Try it online!
In C#, strings are considered "enumerables" of characters. I use this to my advantage by first converting each number to a string. LINQ is then leveraged to get the unique characters (digits) sorted in reverse order. I convert each sorted character array back into a string and use that as the sort key to order the whole list.

Looks like you'll be able to get away with not adding -, looks like order of those doesn't really matter?

Without the -, test case #2 returns ... 321 2132 ... which seems incorrect?

nah, read the example more carefully

OK - I think your right. Thanks for the tip!

Husk, 7 bytes
↔Öö↔Oda

Try it online!

Vyxal 3, 6 bytes
µᵛfG]Ṛ

Try it Online!
need two bytes to reverse the end result otherwise i might have a 4 byter lol

5

@emanresuA thats sorted backwards still, you cant reverse inside the sorting lambda at all

Perl 5 -nl, 68 bytes
$a{eval"9876543210=~y/$_//dcr"}=$_}{say$a{$_}for reverse sort keys%a

Try it online!