text:
Fryer simulator
Your task is to model the effects of batter on pieces of food. Please add three layers of crust.
[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], // in
 [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0],
 [0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
                   |
                   V
[[0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,2,1,2],
 [0,0,2,1,2,2,0,0,0,0,0,0,0,2,2,0,2,0],
 [0,0,2,1,1,1,2,0,0,0,0,0,2,1,1,2,0,0],
 [0,0,0,2,1,2,0,0,0,0,0,2,1,1,2,1,2,0],
 [0,0,0,0,2,0,0,0,0,0,0,0,2,1,1,1,2,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0]]
                   |
                   V
[[0,0,3,2,3,3,0,0,0,0,0,0,0,3,3,2,1,2],
 [0,3,2,1,2,2,3,0,0,0,0,0,3,2,2,3,2,3],
 [0,3,2,1,1,1,2,3,0,0,0,3,2,1,1,2,3,0],
 [0,0,3,2,1,2,3,0,0,0,3,2,1,1,2,1,2,3],
 [0,0,0,3,2,3,0,0,0,0,0,3,2,1,1,1,2,3],
 [0,0,0,0,3,0,0,0,0,0,0,0,3,2,2,2,3,0]]
                   |
                   V
[[0,4,3,2,3,3,4,0,0,0,0,0,4,3,3,2,1,2], // out
 [4,3,2,1,2,2,3,4,0,0,0,4,3,2,2,3,2,3],
 [4,3,2,1,1,1,2,3,4,0,4,3,2,1,1,2,3,4],
 [0,4,3,2,1,2,3,4,0,4,3,2,1,1,2,1,2,3],
 [0,0,4,3,2,3,4,0,0,0,4,3,2,1,1,1,2,3],
 [0,0,0,4,3,4,0,0,0,0,0,4,3,2,2,2,3,4]]

A little visual aid:

body {
   background-color:#222;
   color:lightgray;
}

[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], // in
 [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
 [0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0],
 [0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
                   |
                   V
[[0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,2,1,2],
 [0,0,2,1,2,2,0,0,0,0,0,0,0,2,2,0,2,0],
 [0,0,2,1,1,1,2,0,0,0,0,0,2,1,1,2,0,0],
 [0,0,0,2,1,2,0,0,0,0,0,2,1,1,2,1,2,0],
 [0,0,0,0,2,0,0,0,0,0,0,0,2,1,1,1,2,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,0,0]]
                   |
                   V
[[0,0,3,2,3,3,0,0,0,0,0,0,0,3,3,2,1,2],
 [0,3,2,1,2,2,3,0,0,0,0,0,3,2,2,3,2,3],
 [0,3,2,1,1,1,2,3,0,0,0,3,2,1,1,2,3,0],
 [0,0,3,2,1,2,3,0,0,0,3,2,1,1,2,1,2,3],
 [0,0,0,3,2,3,0,0,0,0,0,3,2,1,1,1,2,3],
 [0,0,0,0,3,0,0,0,0,0,0,0,3,2,2,2,3,0]]
                   |
                   V
[[0,4,3,2,3,3,4,0,0,0,0,0,4,3,3,2,1,2], // out
 [4,3,2,1,2,2,3,4,0,0,0,4,3,2,2,3,2,3],
 [4,3,2,1,1,1,2,3,4,0,4,3,2,1,1,2,3,4],
 [0,4,3,2,1,2,3,4,0,4,3,2,1,1,2,1,2,3],
 [0,0,4,3,2,3,4,0,0,0,4,3,2,1,1,1,2,3],
 [0,0,0,4,3,4,0,0,0,0,0,4,3,2,2,2,3,4]]

The input is a boolean matrix representing the fryer: 0 for the oil, 1 for the food.
Your function or program should add the three layers as 2s, 3s, and 4s around the 1s, thus overwriting some of the 0s. Batter sticks horizontally and vertically (but not diagonally) to food of any shape or size, including donuts (food with holes) and crumbles (isolated food "pixels"), and is restricted to the boundaries of the fryer. Earlier layers of batter turn into crust and are not affected by later ones.
In other words, first you should replace all 0s that are in the von-Neumann neighbourhoods of 1s with 2s, then replace all 0s in the von-Neumann neighbourhoods of 2s with 3s, and finally replace all 0s in the von-Neumann neighbourhoods of 3s with 4s. Thus, the numbers 2,3,4 represent a quantity one greater than the Manhattan distance to the nearest 1-cell.
The fryer will be of size at least 3-by-3 and it will contain at least one piece of food. I/O is flexible - use a matrix format suitable for your language. Extra whitespace is allowed, shorter code desirable, loopholes forbidden.
More tests:
 [[0,0,1], // in
  [0,0,0],
  [0,1,0]]

 [[3,2,1], // out
  [3,2,2],
  [2,1,2]]

 -

 [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], // in
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,0,0,0,0],
  [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,1,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,0],
  [0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0],
  [0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
  [0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
  [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0],
  [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]]

 [[3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,3,3,4,3,3,3,4,4,4,3,2,1], // out
  [2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,4,3,2,2,3,2,2,2,3,3,4,4,3,2],
  [1,2,3,4,0,0,0,0,0,0,0,0,0,0,4,3,2,1,1,2,1,1,1,2,2,3,4,4,3],
  [1,1,2,3,4,4,4,4,0,0,0,0,0,4,3,2,1,1,1,1,1,1,1,1,1,2,3,4,4],
  [2,2,3,4,4,3,3,3,4,0,0,0,4,3,2,1,1,2,1,1,1,1,1,2,2,1,2,3,4],
  [3,3,4,4,3,2,2,2,3,4,0,0,4,3,2,1,2,2,1,1,2,2,1,2,3,2,3,4,4],
  [4,4,4,3,2,1,1,1,2,3,4,0,4,3,2,1,1,2,1,2,3,3,2,2,2,3,4,3,3],
  [0,4,3,2,1,1,2,1,2,3,4,0,0,4,3,2,2,2,1,2,3,3,2,1,1,2,3,2,2],
  [4,3,2,1,1,2,2,1,2,3,4,0,0,0,4,3,3,3,2,3,4,4,3,2,2,3,2,1,1],
  [3,2,1,2,1,1,1,1,2,3,4,0,0,0,0,4,4,3,3,3,4,3,3,3,3,3,2,1,2],
  [4,3,2,1,2,2,1,2,3,4,0,0,0,0,0,4,3,2,2,2,3,2,2,3,4,4,3,2,3],
  [0,4,3,2,1,1,2,3,2,3,4,0,0,0,4,3,2,1,1,1,2,1,1,2,3,4,4,3,4],
  [0,0,4,3,2,2,3,2,1,2,3,4,0,0,0,4,3,2,2,2,3,2,2,3,4,4,3,2,3],
  [0,0,0,4,3,3,4,3,2,3,4,0,0,0,0,0,4,3,3,3,4,3,3,4,4,3,2,1,2],

A little visual aid:

body {
   background-color: #222;
   color:lightgray;
}

[[0,0,1], // in
  [0,0,0],
  [0,1,0]]

 [[3,2,1], // out
  [3,2,2],
  [2,1,2]]

 -

 [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], // in
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,0,0,0,0],
  [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,1,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,0],
  [0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0],
  [0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
  [0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
  [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0],
  [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]]

 [[3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,3,3,4,3,3,3,4,4,4,3,2,1], // out
  [2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,4,3,2,2,3,2,2,2,3,3,4,4,3,2],
  [1,2,3,4,0,0,0,0,0,0,0,0,0,0,4,3,2,1,1,2,1,1,1,2,2,3,4,4,3],
  [1,1,2,3,4,4,4,4,0,0,0,0,0,4,3,2,1,1,1,1,1,1,1,1,1,2,3,4,4],
  [2,2,3,4,4,3,3,3,4,0,0,0,4,3,2,1,1,2,1,1,1,1,1,2,2,1,2,3,4],
  [3,3,4,4,3,2,2,2,3,4,0,0,4,3,2,1,2,2,1,1,2,2,1,2,3,2,3,4,4],
  [4,4,4,3,2,1,1,1,2,3,4,0,4,3,2,1,1,2,1,2,3,3,2,2,2,3,4,3,3],
  [0,4,3,2,1,1,2,1,2,3,4,0,0,4,3,2,2,2,1,2,3,3,2,1,1,2,3,2,2],
  [4,3,2,1,1,2,2,1,2,3,4,0,0,0,4,3,3,3,2,3,4,4,3,2,2,3,2,1,1],
  [3,2,1,2,1,1,1,1,2,3,4,0,0,0,0,4,4,3,3,3,4,3,3,3,3,3,2,1,2],
  [4,3,2,1,2,2,1,2,3,4,0,0,0,0,0,4,3,2,2,2,3,2,2,3,4,4,3,2,3],
  [0,4,3,2,1,1,2,3,2,3,4,0,0,0,4,3,2,1,1,1,2,1,1,2,3,4,4,3,4],
  [0,0,4,3,2,2,3,2,1,2,3,4,0,0,0,4,3,2,2,2,3,2,2,3,4,4,3,2,3],
  [0,0,0,4,3,3,4,3,2,3,4,0,0,0,0,0,4,3,3,3,4,3,3,4,4,3,2,1,2],

Thanks @Tschallacka for the visualizations.

Could you provide a walkthrough example, please? It's not clear to me when or why to use 2, 3 or 4. (I'd VTC as unclear but I have a hammer now and it looks like I'm in a minority)

@Shaggy My understanding is that the numbers identify the "layer". A 1D example: 000010000 → 000212000 → 003212300 → 043212340

Thanks, @georgewatson; it looks like you're right. That's not clear from the spec, though, which mentions that "batter" should only stick to food and earlier layers of batter are not affected by later ones. The only way to determine that is to decipher it from the test cases.

@Shaggy yep, what georgewatson said. I added intermediate steps in the example and a paragraph to describe the algorithm in stricter terms. Please tell me if you think I should change anything to improve clarity.

@Shaggy I believe the hammer only works for closing as a duplicate. Other close votes work as normal.

Your next challenge should be a Friar simulator.

@ngn really? ( ͡° ͜ʖ ͡°)

May base part of a workshop on this challenge?

@Adám i don't know what sort of a workshop you mean, but sure, feel free

Java 8, 271 269 247 210 202 198 193 186 179 177 176 bytes
a->{for(int l=a[0].length,i,t,I,J,n=0;++n<4;)for(i=a.length*l;i-->0;)for(t=4;a[I=i/l][J=i%l]==n&t-->0;)try{a[I-=t-t%3*t>>1][J-=t<2?1-2*t:0]-=a[I][J]<1?~n:0;}finally{continue;}}

Java and index-dependent matrices.. Not a good combination for an already verbose language to begin with..
Modifies the input-matrix instead of returning a new one.
-8 bytes thanks to @ceilingcat.
Try it online.
Explanation:
a->{                            // Method with integer-matrix parameter and no return-type
  for(int l=a[0].length,          //  Amount of columns
      i,t,I,J,                    //  Temp integers
      n=0;++n<4;)                 //  Loop `n` in range [1, 4):
    for(i=a.length*l;i-->0;)      //   Inner loop over the cells:
      for(t=4;a[I=i/l][J=i%l]     //    Set I,J to the current cell
                             ==n& //    If the value of the current cell is the current `n`:
              t-->0;)             //     Loop `t` downwards in the range (4, 0]:
        try{a                     //      Get the cell at a location relative to the current
             [I-=t-t%3*t>>1]      //       If `t` is 3:
                                  //        Take the cell above
                                  //       Else if `t` is 2:
                                  //        Take the cell below
             [J-=t<2?1-2*t:0]     //       Else if `t` is 0:
                                  //        Take the cell left
                                  //       Else if `t` is 1:
                                  //        Take the cell right
              -=a[I][J]<1?        //      And if this cell contains a 0:
                 ~n:0;            //       Fill it with `n+1`
        }finally{continue;}       //      catch and ignore ArrayIndexOutOfBoundsExceptions
                                  //      (saves bytes in comparison to manual checking)

Stencil: 1 + 14 = 15 bytes
Command-line argument: 3
Code: s<×⌈/N:1+⌈/N⋄S
Try it online!
3 repeat the following transformation thrice:
 s if whether the self is non-empty
 < is less than
 × the signum of
 ⌈/N the maximum of the von neumanN neighborhood
 : then the new value becomes
  1+ one plus
  ⌈/N the maximum of the von neumanN neighborhood
 ⋄ else
  S the value stays unmodified (Self)

Shouldn't this be 15 bytes (14+1 for the argument 3)? First time seeing Stencil, but if I understand correctly it's an extension for Dyalog APL to benefit matrices? Also, tiny remark: The capital N at the start of Neumann should be bold instead of the small one at the end in your explanation. :)

Well, newest consensus seems to indicate that various configurations of a single language should be counted as separate languages, but I'll add it

@KevinCruijssen Stencil can be used as a Dyalog APL tool for easy cellular automatons, but it also stands on its own as a golfing language. Indeed, one's code may need modification when moving between tool usage and the golfing language.

@KevinCruijssen No, the bold final N is intentional. See the documentation that Stencil uses the first and last letters of moore and von neumann as mnemonics for with and without self, and uses lowercase and uppercase as mnemonics for the count of non-empties and the actual list of elements.

@KevinCruijssen I should also mention that Stencil is just an interface to Dyalog APL's ⌺ built-in (called Stencil). See also its documentation. A whole golfing language built on a single build-in! Actually, I have made two other golfing languages basing on single Dyalog APL built-ins: QuadR and QuadS.

@Adám Requiring a command-line argument is a bit of stretch. What stops me from defining a family of 256^n "languages" and claiming that the first n bytes of my programs are just "configuration"?

@ngn Nothing. That's basically what MetaGolfScript is about.

@Adám MetaGolfScript is considered a loophole

Actually the newest consensus specifies that the 3 argument shouldn't be counted, but then your language isn't Stencil but Stencil command-line argument 3. (cc @KevinCruijssen) so no, you can't just "count" the argument into your score anymore

@EriktheOutgolfer Really? :S Could you link me to the relevant meta-post. And in that case sorry Adám, since you indeed originally had Stencil command-line argument 3 in your initial version. I can't say I agree with all arguments being ignored in the byte-count. Some default ones ok, but what stops me from inputting the entire or part of my code as argument.. :S In this case I see 3 as something specified in the challenge. It's not asked as input. So I could also add the size of the matrix as argument to reduce bytes (in theory)?

@EriktheOutgolfer Nvm, found it.. So it basically counts as a different programming language in that case? Ok, now I better understand it..

Stencil +CLA: 3, 11 bytes
s:S⋄+∘×⍨⌈/N

Try it online!
-1 thanks to Adám.
-2 thanks to a suggestion on another answer by ngn, which led me to convert this from Stencil to Stencil +CLA: 3.

Python 3, 176 bytes
f=lambda a,i=-2,e=enumerate:a*i or f([[E or int((6*max(len(a)>i>-1<j<len(a[i])and a[i][j]for i,j in((r+1,c),(r-1,c),(r,c+1),(r,c-1))))**.5)for c,E in e(R)]for r,R in e(a)],i+1)

Try it online!
-18 bytes thanks to Mr. Xcoder
-20 bytes thanks to ovs

"When I wake up tomorrow morning and look at this code again I'm probably going to feel very dumb." You'd better be, since I outgolfed you in Java. ;P

@KevinCruijssen what D: not acceptable. must not be beaten by Java :P

Let's beat Java :c – 196 bytes.

@Mr.Xcoder yay thanks :c :D

@ovs oh nice, ty!

Fortran 95, 309 299 294 287 269 bytes
subroutine f(a)
integer::a(:,:),s(2)
integer,allocatable::b(:,:)
s=shape(a)
allocate(b(0:s(1)+1,0:s(2)+1))
do1 k=0,3
do1 i=1,s(1)
do1 j=1,s(2)
b(i,j)=a(i,j)
if(any((/b(i+1,j)==k,b(i-1,j)==k,b(i,j+1)==k,b(i,j-1)==k/)).and.b(i,j)<1.and.k>0)b(i,j)=k+1
1 a(i,j)=b(i,j)
end

Fortran is not a golfing language.

Edit: Saved 10 bytes by using weird old-fashioned do loops.
Edit 2: Saved 5 bytes with any()
Edit 3: Saved 7 bytes by removing an unnecessary if
Edit 4: Saved 18 bytes by shrinking declaration of s

JavaScript (ES6), 107 105 bytes
f=(m,k=1)=>k<4?f(m.map((r,y)=>r.map((v,x)=>v|[-1,0,1,2].every(d=>(m[y+d%2]||0)[x+~-d%2]^k)?v:k+1)),k+1):m

Test cases

f=(m,k=1)=>k<4?f(m.map((r,y)=>r.map((v,x)=>v|[-1,0,1,2].every(d=>(m[y+d%2]||0)[x+~-d%2]^k)?v:k+1)),k+1):m

draw = a => O.innerText += a.map(r => r.join(',')).join('\n')+'\n\n'

draw(f(
 [[0,0,1],
  [0,0,0],
  [0,1,0]]
))

draw(f(
 [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,0,0,0,0],
  [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,1,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,0],
  [0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0],
  [0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
  [0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
  [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0],
  [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]]
))

Commented
f = (m, k = 1) =>                  // given the input matrix m[] and starting with k = 1
  k < 4 ?                          // if this is not the 4th iteration:
    f(                             //   do a recursive call:
      m.map((r, y) =>              //     for each row r[] at position y in m[]:
        r.map((v, x) =>            //       for each cell v at position x in r[]:
          v |                      //         if v is non-zero
          [-1, 0, 1, 2].every(d => //         or each neighbor cell at (x+dx, y+dy), with:
            (m[y + d % 2] || 0)    //           dy = d % 2 --> [-1, 0, 1, 0]
            [x + ~-d % 2]          //           dx = (d - 1) % 2 --> [0, -1, 0, 1]
            ^ k                    //           is different from k
          ) ?                      //         then:
            v                      //           let the cell unchanged
          :                        //         else:
            k + 1                  //           set the cell to k + 1
        )                          //       end of inner map()
      ),                           //     end of outer map()
      k + 1                        //     increment k for the next iteration
    )                              //   end of recursive call
  :                                // else:
    m                              //   stop recursion and return m[]

Python 2, 146 143 bytes
e=enumerate;l=input()
for y,f in e(l):
 for g,h in e(f):x=1+min(abs(y-a)+abs(g-c)for a,b in e(l)for c,d in e(b)if d==1);l[y][g]=x*(x<5)
print l

Try it online!

Wolfram Language (Mathematica), 70 bytes
Mod[-MorphologicalTransform[#,#[[;;,2]]~Max~#[[2]]&,i]~Sum~{i,0,3},5]&

Try it online!

APL (Dyalog Unicode), 34 30 23 bytes (abrudz/SBCS)
5|{5⊃,⍵+×⌊.⌊⍨⍵}⌺3 3⍣3∘-

Try it online!
-4 thanks to ngn.

Let us continue this discussion in chat.

Retina, 93 87 84 bytes
1
4
3{m`(?<=^(.)*)0(?=4|.*¶(?>(?<-1>.)*)4|(?<=40|^(?(1)_)(?<-1>.)*4.*¶.*))
5
T`1-5`d

Try it online! Based on my answer to Kill it With Fire. Edit: Saved 6 9 bytes thanks to @MartinEnder. Explanation:
1
4

Turn all the 1s into 4s.
3{

Repeat the rest of the program (at most) 3 times.
m`(?<=^(.)*)0(?=4|.*¶(?>(?<-1>.)*)4|(?<=40|^(?(1)_)(?<-1>.)*4.*¶.*))
5

Change all 0s adjacent to 4s into 5s.
T`1-5`d

Decrement all digits.
Retina 0.8.2, 100 94 bytes
1
3
{m`(?<=^(.)*)0(?=3|.*¶(?>(?<-1>.)*)3|(?<=30|^(?(1)_)(?<-1>.)*3.*¶.*))
4
T`1-4`d`^[^1]+$

Try it online! Explanation:
1
3

Turn all the 1s into 3s.
{

Repeat until the output does not change.
m`(?<=^(.)*)0(?=3|.*¶(?>(?<-1>.)*)3|(?<=30|^(?(1)_)(?<-1>.)*3.*¶.*))
4

Change all 0s adjacent to 3s into 4s.
T`1-4`d`^[^1]+$

If there are no 1s, decrement all digits.

You can save some bytes by using a character like ! (which can't appear in the input) instead of (?!).

@MartinEnder Thanks, that works for Kill it With Fire too (and I found a separate 2-byte golf while I was there!)

Clean, 157 bytes
import StdEnv,StdLib
t=transpose
z=zipWith
?n=n+sign n
f[0,h:l]=[?h:f[h:l]]
f[h,0:l]=[h,?h:f l]
f[h:l]=[h:f l]
f l=l
$l=z(z max)(t(map f(t l)))(map f l)

$o$o$

Try it online!
As a function literal.

Perl, 63 bytes
Includes +3 for 0ap
perl -0ape 's/0(?=$a|.{@{-}}$a)/$a+1/seg,$_=reverse while($a+=$|-=/
/)<4'

Give the input matrix as a block of digits without final newline., e.g.
001
000
010

for the 3x3 example. The output format is the same, a block of digits without final newline.
You can use a small script like
perl -i -0pe 's/\n*$//' <file>

to conveniently remove the final newlines from a file if that is hard to do in your favorite editor

Ruby, 183 158 146 bytes
->a{3.times{|n|a.size.times{|i|r=a[i];r.size.times{|j|(r[j]<1&&[i>0?a[i-1][j]:0,a[i+1]&.at(j),j>0?r[j-1]:0,r[j+1]].include?(n+1))?r[j]=n+2:0}}};a}

Try it online!
Uses the obvious three-loop algorithm. The fact that Ruby allows negative indexing into arrays means that there is no way (that I can see) around making the bounds checks. Reaching beyond the boundary of an array returns nil, so only the negative bound checks are necessary. The check for a[i+1][j] just needs to use the safe access operator.
I also shaved off a few bytes by using a variable for a[0].
-12 more bytes: Use .times instead of (0...x).map (in three places).
->a{
  3.times{|n|                    # For n from 0 to 2
    a.size.times{|i|             # For each row
      r=a[i];
      r.size.times{|j|           # For each column
        (r[j]<1 && [             # If the current cell is 0, and any of
            i>0 ? a[i-1][j] : 0, #     the cell to the north,
            a[i+1]&.at(j),       #     the cell to the south,
            j>0 ? r[j-1] : 0,    #     the cell to the west,
            r[j+1]               #     or the cell to the east
          ].include?(n+1)        #   are set to the previous value,
        ) ? r[j]=n+2 : 0         # Set this cell to the next value (or 0)
      }
    }
  };
  a                              # Return the modified array
}

C (gcc), 217 bytes
for(w=2;w<=4;w++)for(y=0;y<H;y++)for(x=0;x<W;x++){if(o[y][x].v[w%2])continue;if(o[y][x].v[!(w%2)]){o[y][x].v[w%2]=o[y][x].v[!(w%2)];continue;}for(z=0;z<8;z++)if(o[y][x].a[z]&&o[y][x].a[z]->v[!(w%2)])o[y][x].v[w%2]=w;}

Try it online!

Welcome to the site, and nice first answer! Be sure to check out our Tips for golfing in C page for any golfing tricks!

am I wrong to post util code between header and footer?

Ah, good point. Our site rules on I/O are that you can't assume the input is already stored in a variable, and that you have to include the initialisation of variables in your byte count. For C, answers generally take the form of a function, which you can take input as a function parameter (e.g. f(o)). You don't have to count the code required to run the function (e.g. the int main { ... }). I'm not very familiar with C, so I'm not sure what the code in the header/footer is doing, but  if it is part of the task, rather than the I/O, you should count it in your code

For example, see this C submission, which includes the actual running of the function in the footer

Usually submissions are full functions or full programs. Suggest ~w&1 instead of !(w%2)

172

Python 3, 125 bytes
f=lambda a,n=2,e=enumerate:n//5*a or f([[r[j]or n*any([0,*r][j:j+3]+[0,*c][i:i+3])for j,c in e(zip(*a))]for i,r in e(a)],n+1)

Try it online!
Adaptation of my answer to Calculate COVID spread


text:
Column-wise summation of overlapping slices
Task
Given a list of integers L and another integer s, the goal is to compute the column-wise sums of all s-length (potentially overlapping) slices of L, while pertaining their positions relative to L (see below).
Definitions
The s-length (overlapping) slices of the list L are all the contiguous subsequences (without wrapping) of L that are of length s.
In order to pertain the positions of the slices s relative to L, you can imagine building a "ladder", where each slice si has an offset of i positions from the beginning.

Specs

s is an integer higher than 1 and strictly smaller than the length of L.
L will always contain at least 3 elements.
You can compete in any programming language and can take input and provide output through any standard method, while taking note that these loopholes are forbidden by default. This is code-golf, so the shortest submission (in bytes) for every language wins.

Examples and Test Cases
Here is a worked example:
[1, 2, 3, 4, 5, 6, 7, 8, 9], 3

[1, 2, 3]
   [2, 3, 4]
      [3, 4, 5]
         [4, 5, 6]
            [5, 6, 7]
               [6, 7, 8]
                  [7, 8, 9]
-------------------------------- (+)  | column-wise summation
[1, 4, 9, 12, 15, 18, 21, 16, 9]

And some more test cases:
[1, 3, 12, 100, 23], 4         -> [1, 6, 24, 200, 23]
[3, -6, -9, 19, 2, 0], 2       -> [3, -12, -18, 38, 4, 0]
[5, 6, 7, 8, 2, -4, 7], 3      -> [5, 12, 21, 24, 6, -8, 7]
[1, 2, 3, 4, 5, 6, 7, 8, 9], 3 -> [1, 4, 9, 12, 15, 18, 21, 16, 9]
[1, 1, 1, 1, 1, 1, 1], 6       -> [1, 2, 2, 2, 2, 2, 1]
[1, 2, 3, 4, 5, 6, 7, 8, 9], 6 -> [1, 4, 9, 16, 20, 24, 21, 16, 9]

That first test case is annoying. ;) Simply because s is larger than L/2. Maybe add some more test cases where that is the case [1, 1, 1, 1, 1, 1, 1], 6 -> [1, 2, 2, 2, 2, 2, 1]or[1, 2, 3, 4, 5, 6, 7, 8, 9], 6 -> [1, 4, 9, 16, 20, 24, 21, 16, 9]`?

@KevinCruijssen Can you please edit in for me? Those are some good test cases, but I am on mobile now ;) Thanks!

J, 11, 9 8 bytes
-1 byte thanks to miles!
[:+//.]\

How it works?
The left argument is s, the right one - L
]\ - splits L into sublists with length s
/. - extracts the oblique diagonals (anti-diagonals)
+/ - adds them up
[: - makes a fork from the above verbs
Here's an example J session for the first test case:
   a =. 1 2 3 4 5 6 7 8 9

   ] 3 ]\ a
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9

   ] </. 3 ]\ a
┌─┬───┬─────┬─────┬─────┬─────┬─────┬───┬─┐
│1│2 2│3 3 3│4 4 4│5 5 5│6 6 6│7 7 7│8 8│9│
└─┴───┴─────┴─────┴─────┴─────┴─────┴───┴─┘

   ] +//. 3 ]\ a
1 4 9 12 15 18 21 16 9

Try it online!

Is there any difference between an "oblique diagonal" and a "diagonal”?

@Luis Mendo - I think "oblique" means going from down-left to up-right in the case of the J adverb /., as opposed to the main diagonal going from up-left to down-right.

Ah, thanks. So that's what's usually called anti-diagonals

You could replace ,/\ with ]\

@miles Yes, of course! Thank you!

Haskell, 59 56 bytes
s#n=[x*minimum[n,i,length s+1-max i n]|(i,x)<-zip[1..]s]

Try it online!
Defines a function (#) which takes a list s and and a number n as arguments.
This is based on the observation that for s = [1, 2, 3, 4, 5, 6, 7, 8, 9] and n = 3
[1, 2, 3]
   [2, 3, 4]
      [3, 4, 5]
         [4, 5, 6]
            [5, 6, 7]
               [6, 7, 8]
                  [7, 8, 9]
---------------------------- (+)
[1, 4, 9,12,15,18,21,16, 9]

is the same as
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 2, 3, 3, 3, 3, 3, 2, 1]
---------------------------- (*)
[1, 4, 9,12,15,18,21,16, 9]

To generate this initially increasing, then constant and finally decreasing list, we can start with
[minimum[i, length s + 1 - i] | i<-[1..length s]]

which yields [1, 2, 3, 4, 5, 4, 3, 2, 1]. Adding n as additional constraint into the minimum expression yields the correct list [1, 2, 3, 3, 3, 3, 3, 2, 1]answer for n = 3, though for n = 6 (or in general any n > lengths s/2) the additional constraint length s + 1 - n is needed:
[minimum[i, n, length s + 1 - i, length s + 1 - n] | i<-[1..length s]]

or shorter:
[minimum[i, n, length s + 1 - max i n] | i<-[1..length s]]

For the pairwise multiplication [1..length s] is zipped with s, and because zip truncates the longer list to the length of the shorter one the infinite list [1..] can be used:
[x * minimum[i, n, length s + 1 - max i n] | (i,x)<-zip[1..]s]

JavaScript (ES6), 65 62 58 bytes
Saved 4 bytes thanks to @Shaggy
Takes input in currying syntax (a)(n).
a=>n=>a.map((v,i)=>v*Math.min(++i,n,a.length+1-(n>i?n:i)))

Test cases

let f =

a=>n=>a.map((v,i)=>v*Math.min(++i,n,a.length+1-(n>i?n:i)))

console.log(JSON.stringify(f([1, 3, 12, 100, 23]        )(4))) // [1, 6, 24, 200, 23]
console.log(JSON.stringify(f([3, -6, -9, 19, 2, 0]      )(2))) // [3, -12, -18, 38, 4, 0]
console.log(JSON.stringify(f([5, 6, 7, 8, 2, -4, 7]     )(3))) // [5, 12, 21, 24, 6, -8, 7]
console.log(JSON.stringify(f([1, 2, 3, 4, 5, 6, 7, 8, 9])(3))) // [1, 4, 9, 12, 15, 18, 21, 16, 9]
console.log(JSON.stringify(f([1, 1, 1, 1, 1, 1, 1]      )(6))) // [1, 2, 2, 2, 2, 2, 1]
console.log(JSON.stringify(f([1, 2, 3, 4, 5, 6, 7, 8, 9])(6))) // [1, 4, 9, 16, 20, 24, 21, 16, 9]

Does a=>n=>a.map((v,i)=>v*Math.min(++i,n,a.length+1-(n>i?n:i))) work for 58 bytes?

@Shaggy Somehow, I knew there was something really stupid in my code but couldn't figure it out... Thanks a lot!

Java 8, 83 bytes
L->s->{for(int i=0,l=L.length+1,t,u;++i<l;u=l-(s>i?s:i),L[i-1]*=t<u?t:u)t=i<s?i:s;}

That first test case (and the last two I've added) screwed me over multiple times, but it finally works now.. :D
Modifies the input array instead of returning a new one.
Explanation:
Try it online.
L->s->{                  // Method with int-array and int parameters, and no return-type
  for(int i=0,           //  Index-integer, starting at 0
      l=L.length+1,      //  The length of the input-array + 1
      t,u;               //  Two temp integers
      ++i<l              //  Loop `i` from 1 to the length (inclusive)
      ;                  //    After every iteration:
       u=l               //     Set temp integer `u` to the length plus 1,
          -(s>i?s:i),    //     minus the highest of `s` and `i`
       L[i-1]*=t<u?t:u)  //     And replace the item with the lowest of `t` and `u`
    t=i<s?i:s;}          //   Set temp integer `t` to the lowest of `i` or `s`

APL (Dyalog Unicode), 19 14 bytesSBCS
-5 thanks to ngn.
Anonymous tacit infix function taking s as left argument and L as right argument. Assumes ⎕IO (Index Origin) to be 0 as is default on many systems.
+⌿∘↑((0,⊢)\,/)

Try it online!
Explanation with example case [1,3,12,100,23]
(…) apply the following anonymous tacit function:
 ,/ overlapping windows of that size; [[1,3,12],[3,12,100],[12,100,23]]
 (…)\ cumulatively apply this tacit the following anonymous tacit function:
  ⊢ the right(most) argument
  0, with a zero on the left
Cumulative reduction means that we insert the function into every "space" between successive terms, working our way from right to left. For each "space", the function will discard the left argument but append an additional zero. Effectively, this appends as many zeros to each term as there are "spaces" to its left, so the first term gets zero spaces, the second gets one, and the third gets two: [[1,3,12],[0,3,12,100],[0,0,12,100,23]]
↑ up the rank by combining the lists into a single matrix, padding with zeros;
 ┌             ┐
 │1 3 12   0  0│
 │0 3 12 100  0│
 │0 0 12 100 23│
 └             ┘
∘ then
+⌿ sum vertically; [1,6,36,200,23]

⊢,⍨¨0⍴⍨¨⍳∘≢ -> {0,⍵}\

@ngn You always think of these clever reductions, but you really should post this separately. Btw, I find +⌿∘↑((0,⊢)\,/) more elegant.

oh come on, this is a clear case of simplifying a part of a solution, not a new idea

@ngn Meanwhile, solve this CMC!

I'm not sure this is on-topic in the comments here, but why don't you use "each"? 2{(⊃⌽⍺),⊃⍵}/⊢ -> 2{⊃¨(⌽⍺)⍵}/⊢

@ngn Updated to use your clever scan.

05AB1E, 12 bytes
)IŒIùvyNÅ0ì+

Try it online!

Weird, no zipping? Neat.

MATL, 8 bytes
YCPT&Xds

Try it online! Or verify all test cases.
Explanation
Consider inputs [1, 3, 12, 100, 23] and 4.
YC     % Implicit inputs: row vector L and number s. Create matrix of
       % overlapping blocks of L with length s, where each block is a column
       % STACK: [  1   3;
                   3  12;
                  12 100;
                 100  23]
P      % Flip vertically
       % STACK: [100  23;
                  12 100;
                   3  12;
                   1   3]
&TXd   % Extract all diagonals, starting from bottom-left, and arrange them as
       % columns of a matrix, with zero padding
       % STACK: [1   3  12 100   0;
                 0   3  12 100  23]
s      % Sum of each column. Since s is less than the length of L, there are
       % at least two rows. Thus function `s` can be used instead of `Xs`.
       % Implicit display
       % STACK: [1   6  24 200  23]

Jelly, 6 bytes
JṡṬS×ḷ

Try it online!
How it works
JṡṬS×ḷ  Main link. Left argument: A (array). Right argument: n (integer)

J       Indices; yield [1, ..., len(A)].
 ṡ      Split the indices into overlapping slices of length n.
  Ṭ     Untruth; map each array of indices to a Boolean vector, with 1's at the
        specified indices and 0's elsewhere.
        For example, [3, 4, 5] maps to [0, 0, 1, 1, 1].
   S    Sum the rows, essentially counting how many times each index appears in
        the arrays returned by the ṡ atom.
     ḷ  Left; yield A.
    ×   Multiply the counts to the left with the integers to the right.

Japt, 13 bytes
It took far too long to get this working when s > L/2!
Ë*°EmVUÊÄ-EwV

Try it

Explanation
                 :Implicit input of array U and integer V
Ë                :Map over each element at 0-based index E in U
 *               :  Multiply by
    m            :  The minumum of
  °E             :    E incremented,
     V           :    V,
          EwV    :    and the maximum of E & V
         -       :    subtracted from
      UÊÄ        :    the length of U plus 1

"It took far too long to get this working when s > L/2!" I had exactly the same. The other test cases are easy, but that first one (and the two I've added at the end) were annoying!.. +1 from me!

Husk, 4 bytes
mΣ∂X

Try it online!
Uses the idea from Galen Ivanov's J answer.
Explanation
     -- implicit input number n and list s, e.g. s = [1,2,3,4,5,6] and n = 4
   X -- get sublists of length n of list s           [[1,2,3,4],[2,3,4,5],[3,4,5,6]]
  ∂  -- anti-diagonals                               [[1],[2,2],[3,3,3],[4,4,4],[5,5],[6]]
mΣ   -- get the sum of each of the lists             [1,4,9,12,10,6]

Wolfram Language (Mathematica), 42 bytes
Min[i,#2,l+1-{i,#2}]~Table~{i,l=Tr[1^#]}#&

Try it online!

Julia, 41 bytes
a\n=(a[L=end];a.*min(1:L,L:-1:1,n,L-n+1))

Try it online!

Redefine \ operator.
a[L=end] is a shorter alternative to L=length(a).
Uses Laikoni's method.

Japt, 13 12 bytes
-1 byte thanks to @ETHproductions
ãV
ËEÆÃcDÃyx

Try it online!

R, 52 51 bytes
function(l,s)l*pmin(s,x<-seq(l),y<-rev(x),y[1]+1-s)

Try it online!
This is equivalent to Laikoni's answer.
seq(l) produces the indices 1...length(l) since length(l)>1 (otherwise it would produce 1...l[1]). I save it as x, save its reverse as y, and take the first element of y (length(l)) to neatly port Laikoni's answer and save a byte!
Original answer, 52 bytes
function(l,s,L=sum(l|1)+1)l*pmin(s,x<-2:L-1,L-x,L-s)

Try it online!
The output is l elementwise multiplied by the minimum of s, the 1-based index of the element x, length(l)-x+1, and length(L)-s+1.
This is also equivalent to Laikoni's answer, using L-x instead of rev(x) as it's shorter.

Ruby, 62 bytes
->a,l{a.map.with_index{|x,i|x*[i+1,l,a.size-[l-1,i].max].min}}

Try it online!
Essentially a port of Arnauld's javascript answer, except that needing with_index is a lot more painful.
In the time it took for me to decide to actually submit this, I golfed down from this 70-byte version, which is closer to Dennis's algorithm.
->a,l{c=a.map{0};(0...a.size).each_cons(l){|h|h.map{|i|c[i]+=a[i]}};c}

APL+WIN, 25 bytes
Prompts for screen input of L followed by s
+/(1-⍳⍴z)⌽¨(⍴L)↑¨s←⎕,/L←⎕

Explanation:
L←⎕ prompt for screen input of L

s←⎕,/ prompt for screen input of s and create nested vector of successive s elements of L

(⍴L)↑¨ pad each element of the nested vector with zeros to the length of L

(1-⍳⍴z)⌽¨ incrementally rotate each element of the nested vector

+/ sum the elements of the nested vector

K (oK), 30 bytes
Solution:
{+/t,'(y':x),'|t:(!1-y-#x)#'0}

Try it online!
Example:
{+/t,'(y':x),'|t:(!1-y-#x)#'0}[3 -6 -9 19 2 0;2]
3 -12 -18 38 4 0

Explanation:
Don't think I can compete with J on this one. Generate a list of zeros to be appended and prepended to the sliding-window list, then sum up:
{ t,'(y':x),'|t:(!(#x)+1-y)#'0 }[1 2 3 4 5 6 7 8 9;3]
(1 2 3 0 0 0 0 0 0
 0 2 3 4 0 0 0 0 0
 0 0 3 4 5 0 0 0 0
 0 0 0 4 5 6 0 0 0
 0 0 0 0 5 6 7 0 0
 0 0 0 0 0 6 7 8 0
 0 0 0 0 0 0 7 8 9)

Breakdown is as follows... though this still feels clumsy.
{+/t,'(y':x),'|t:(!1-y-#x)#'0} / the solution
{                            } / lambda taking x and y implicitly
                          #'0  / take (#) each (') zero
                 (       )     / do this together
                       #x      / count (#) length of x
                     y-        / take count away from length y
                   1-          / take that result from 1
                  !            / til, generate range to that number
               t:              / save in variable t
              |                / reverse it
            ,'                 / join with each
      (y':x)                   / sliding window size y over x
    ,'                         / join with each
   t                           / prepend t
 +/                            / sum up

Uiua, 14 bytes
⬚0/+⊐≡(⊂⊚)⇡⧻.◫

Try it!
⬚0/+⊐≡(⊂⊚)⇡⧻.◫
             ◫  # windows
          ⇡⧻.   # range of length
    ⊐≡(  )      # apply function to each row of both arrays, boxing as required
        ⊚       # where (n zeros)
       ⊂        # join
⬚0/+            # sum columns, filling missing elements with zero

Perl, 45 44 bytes
Includes +4 for -ai
Also notice that this code gives 2 perl warnings on startup. You can suppress these at the cost of one stroke by adding the X option
Give the mask length after the -i option and the array on one line on STDIN:
perl -ai4 -E 'say$_*grep$_~~[$^I..@F],$a..$^I+$a++for@F' <<< "1 3 12 100 23"

Just the code:
say$_*grep$_~~[$^I..@F],$a..$^I+$a++for@F

C (gcc), 100 89 bytes, using -lm

Saved eleven bytes thanks to ceilingcat.

j;f(L,l,s)int*L;{for(j=l;j--;L[j]*=j<s&j<l-s?1+j:j>s&j>l-s?l-j:fmin(s<l-j?s:l-j,l+1-s));}

Try it online!

Python 2, 68 66 bytes
-2 bytes thanks to Laikoni
lambda l,n:[v*min(n,i+1,len(l)-max(i,n-1))for i,v in enumerate(l)]

Try it online!

max(i,n-1) instead of [i,n-1][n>i].

C (gcc), 83 81 79 bytes
There are basically three "phases" to the manipulation of the list: ramp-up, sustain, and cool-off. As we go along the list, we will increase our factor until we reached some maximum. If a full run of slices can fit into the list, this maximum will be the same as the length of the slices. Otherwise, it will be the same as the number of slices that fit. At the other end, we will decrease the factor again, to land at 1 on the last element.
The length of the ramp-up and cool-down phases that bookend this plateau is one less than that maximum factor.
The ungolfed loops before combining them hopefully makes it clearer (R = length of ramp-up phase):
for (r = 1; r <= R; r++) L[r - 1] *= r;
for (; r < n - R; r++)   L[r - 1] *= R + 1;
for (; r < n; r++)       L[r - 1] *= n - r + 1;

Three loops is much too much, so deciding the factor based on r gives us the one loop (using s for R to save some bytes):
r;f(L,n,s)int*L;{for(r=0,s=2*s-1>n?n-s:s-1;r++<n;)*L++*=r>s?r<n-s?s+1:n-r+1:r;}

Try it online!

Perl 5, 63 bytes
$b=<>;map{say$_*=$n+$b>@F?$n-$b<0?$i:--$i:$i<$b?++$i:$i;++$n}@F

Try it online!

Clojure, 72 bytes
#(let[R(range 1(inc(count %)))](map *(map min(repeat %2)R(reverse R))%))

Pyt, 106 bytes
ĐŁĐ←⇹řĐ↔Đ04ȘĐ04Ș>Đ04Ș03Ș¬*07ȘážÁ*+04Ș⇹Đ3ȘĐ3Ș-⁺Đ4Ș⇹ŕĐ3Ș<Đ¬3Ș*3Ș*+⇹ĐŁ⑴04Ș3Ș⇹04Ș*Đ04ȘĐ04Ș<Đ04Ș*06ȘážÁ03Ș¬*++*

Takes L on the first line as an array, and takes s on the second line
Explanation:
                     Implicit input (L)
Đ                    Duplicate L
ŁĐ                   Get length of L (len) and push it twice
←                    Get s
⇹ř                   Push [1,2,...,len]
Đ↔Đ                  Push [len,...,2,1] twice
04ȘĐ                 Push 0, flip top 4 on stack, and duplicate top [1,2,...,len]
04Ș>                 Is [len,...,2,1]>[1,2,...,len] (element-wise) [boolean array]
Đ                    Duplicate top of stack
04Ș03Ș¬*             Pushes [1,2,...,ceil(len/2),0,...,0]
07ȘážÁ               Push 0, flip top seven on stack, and remove all 0s from stack
*                    Pushes [0,0,...,0,floor(len/2),floor(len/2)-1,...,1]
+                    Adds top two on stack element-wise

The top of the stack is now:
     [1,2,...,ceil(len/2),floor(len/2),...,2,1] (let's call it z)

04Ș                  Push zero and swap top four on stack
⇹                    Swap top two on stack
Đ3ȘĐ3Ș-⁺Đ4Ș⇹ŕĐ3Ș<Đ¬3Ș*3Ș*+     Pushes min of (len-s+1,s) [let's call it m]
⇹ĐŁ⑴04Ș3Ș⇹04Ș*                Pushes an array [m,m,...,m] with length len
Đ04ȘĐ04Ș<Đ04Ș*06ȘážÁ03Ș¬*++    Pushes element-wise min of [m,m,...,m] and z
*                              Element-wise multiplication of above with L

Try it online!

Python + numpy, 64 bytes
from pylab import *
lambda l,N:convolve(*ones((2,len(l)-N-1)))*l

Call this with l as the list, and N as the length.

source: Stack Exchange

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

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

sort: votes


text:
How many logs can you fit into a number?
Challenge
Given a real number as input, calculate the number of times which the natural logarithm function ln can be applied to it before the resulting number becomes imaginary.
Explanation
Applying ln to a negative number results in a non-real number. This means that, by repeatedly applying ln to a number, you will eventually get an imaginary number. For example, using 10 as input:
ln(10) = 2.303                - 1 time
ln(2.303) = 0.834             - 2 times
ln(0.834) = -0.181            - 3 times
ln(-0.181) = pi*i + ln(0.181) - stop; result is 3

Test cases
10 -> 3
1000000 -> 4
2.4 -> 2
-1 -> 0
0 -> 0

Details

This is code golf, so lowest byte answer wins.
The input number could be negative, so 0 should be returned.
Your solution may be either:

a function, which takes the input number as a parameter and returns the number of times ln can be applied;
or a program, which takes STDIN/command line argument input and prints the result.

Welcome to PPCG! You can use the Sandbox to make sure your (future) challenges are good before posting.

@user202729 Agreed, this is a dupe - I didn't realise that this process actually had a name.

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


text:
Alice's Tea Party
There are n places set around a circular table. Alice is sat on one of them. At each place, there's a cake. Alice eats her cake, but it doesn't taste very nice. Then the Mad Hatter comes in. He gives Alice a list of n-1 numbers, each between 1 and n-1. For each item i in the list, Alice has to move around i places and eat the cake there if there is one. However, Alice will be able to choose whether to move clockwise or anticlockwise for each item in the list. She doesn't like the cakes, so she is trying not to eat them.
Given an integer n, output all the possible lists the Mad Hatter could use to force Alice to eat all the cakes (represented as a tuple/list of tuples/lists of integers or some tuples/lists of integers separated by newlines). Note that it is possible for the Mad Hatter to force Alice to eat all the cakes if and only if n is a power of two, so you may assume that n is a power of two. Make your code as short as possible.
You may also take in x such that 2^x=n if that helps. For example, you may take in 2 instead of 4, 3 instead of 8, etc.
The order in which your program returns the possible lists does not matter.
Test Cases
1 -> [[]]
2 -> [[1]]
4 -> [[2, 1, 2], [2, 3, 2]]
8 -> [[4, 2, 4, 1, 4, 2, 4], [4, 2, 4, 1, 4, 6, 4], [4, 6, 4, 1, 4, 2, 4], [4, 6, 4, 1, 4, 6, 4], [4, 2, 4, 3, 4, 2, 4], [4, 2, 4, 5, 4, 2, 4], [4, 2, 4, 7, 4, 2, 4], [4, 2, 4, 3, 4, 6, 4], [4, 6, 4, 3, 4, 2, 4], [4, 2, 4, 5, 4, 6, 4], [4, 6, 4, 5, 4, 2, 4], [4, 2, 4, 7, 4, 6, 4], [4, 6, 4, 7, 4, 2, 4], [4, 6, 4, 3, 4, 6, 4], [4, 6, 4, 5, 4, 6, 4], [4, 6, 4, 7, 4, 6, 4]]

Related.

Can we return [] instead of [[]] for n = 1?

Can we do this in c#?If yes,can someone explain

@Ourous No. The answer should be [[]] because the Mad Hatter's list has length 0. This means that [] is the only possible list (which works since Alice eats the only cake she has before the Mad Hatter comes in), so [[]] is the list of all lists that work.

Python 3, 235 191 177 136 134 122 119 bytes
lambda n:[*product(*[[*(i==n/2and range(1,n,2)or[[n/4,3*n/4],[n/2]][i%2])]for i in range(1,n)])]
from itertools import*

Try It Online
Thanks To Dennis for -31 bytes and ChasBrown for -14 bytes and Mr.XCoder for -1 byte.
Numbers appear in the decimal form, eg:4.0.

239 bytes (switches to Python 2)

@cairdcoinheringaahing ty. Added that.

Edited and fixed some error

219 bytes

You could do from itertools import* and product(*k) (without the itertools. bit on the beginning). In fact, you could do print([*product(*k)]) instead of print([p for p in product(*k)]).

This (133 bytes) should be equivalent.

Using your same logic, but with a lambda, 120 bytes.

@ChasBrown Thanks, but as per the rules I cannot keep the x=\ in the header, so it would make it 122 bytes.

@Mainsh Kandu: That constraint only applies when the function is recursive; which yours is not - so you can keep those precious 2 bytes :). (Contrast with my solution below, where I cannot put f=\ in the header).

121 bytes. list(...) -> [*(...)]

Perl, 78 75 72 bytes
Includes +1 for n
perl -nE '$"=",";say<@{[map"{@{[map$`*($_-.5)/@z,@z=1..$_&-$_]}}",/$/..$_-1]}\\ >' <<< 8

Prints a space separated sequence of comma separated numbers (replace the final space by \n for a more readable output)
Uses a string substitution inside a string substitution.

Jelly, 18 bytes
żN$Œp+\€%ṬȦ
’ṗ’çÐf

This is a brute-force solution that tests all (n - 1)n - 1 potential solutions one by one.
Try it online!
Verification
$ time jelly eun 'żN$Œp+\€%ṬȦ¶’ṗ’çÐf' 8
[[4, 2, 4, 1, 4, 2, 4], [4, 2, 4, 1, 4, 6, 4], [4, 2, 4, 3, 4, 2, 4], [4, 2, 4, 3, 4, 6, 4], [4, 2, 4, 5, 4, 2, 4], [4, 2, 4, 5, 4, 6, 4], [4, 2, 4, 7, 4, 2, 4], [4, 2, 4, 7, 4, 6, 4], [4, 6, 4, 1, 4, 2, 4], [4, 6, 4, 1, 4, 6, 4], [4, 6, 4, 3, 4, 2, 4], [4, 6, 4, 3, 4, 6, 4], [4, 6, 4, 5, 4, 2, 4], [4, 6, 4, 5, 4, 6, 4], [4, 6, 4, 7, 4, 2, 4], [4, 6, 4, 7, 4, 6, 4]]

real    85m33.780s
user    85m35.903s
sys     0m0.060s

How it works
’ṗ’çÐf       Main link. Argument: n (integer)

’ ’          Yield n-1.
 ṗ           Cartesian power; yield all vector of length n-1 over [1, ..., n-1].
   çÐf       Filter; keep vectors v for which the helper link, called with left
             argument v and right argument n, returns a truthy value.

żN$Œp+\€%ṬȦ  Helper link. Left argument: v (vector). Right argument: n (integer)

żN$          Zip v with -v, mapping [v(1), ... v(n-1)] to
             [[v(1), -v(1)], ..., [v(n-1), -v(n-1)]].
   Œp        Take the Cartesian product of all pairs.
     +\€     Take the cumulative sum of each resulting vector.
        %    Take all cumulative sums modulo n.
             A valid solution results in a permutation of [1, ..., n-1].
         Ṭ   Untruth; map each resulting vector to a Boolean array with 1's at
             the specified indices, 0's elsewhere.
          Ȧ  Test if the resulting array contains only non-zero integers.

Python 2,130 129 127 123 121 bytes
f=lambda n:n>1and(lambda D:[l+[k]+r for l in D for r in D for k in range(1,n,2)])([[i*2for i in a]for a in f(n/2)])or[[]]

Try it online!
Edited: Takes as input n (which must be a power of 2) as the number of seats at the Hatter's table.

Here the input 'n' refers to 2^n ? Please mention that.

@Manish Kundu: quite right.

Python 2, 81 bytes
f=lambda n,i=1,*l:i/n*[l]or sum([f(n,i+1,x,*l)for x in range(n)if x*i%n==n/2],[])

Try it online!

Python 2, 92 bytes
f=lambda n,c=1:[x+[c*y]+z for y in range(1,n,2)for x in f(n/2,c*2)for z in f(n/2,c*2)]or[[]]

Try it online!

Clean, 194 ... 172 bytes
Still in the progress of cutting more off.
import StdEnv

\n=let?_[]_=1>0;?l[i:j]m=all((\e= ?(updateAt e(1<0)l)j e&&l!!e)o\e=e-e/n*n)[m+i,n+m-i]in[k\\k<-iter(n-1)(\e=[[h:t]\\h<-[1..n],t<-e])[[]]| ?[q>1\\q<-[1..n]]k 0]

Try it online!
Lambda function which does a brute-force over every combination of indices up to length n-1.
It still runs in about 5 seconds, because of compiler magic.


text:
Make a Triangularity program valid
Triangularity is a new esolang developed by Mr. Xcoder where code structure has to follow a very specific pattern:

For the nth line of code, there must be exactly 2n-1 characters of the program on  it.  This causes a triangular/pyramid shape, with the first line having only one character and the rest increasing by increments of 2.
Each line must be padded with .s on the left and right, such that the characters are centered on their lines and all lines are padded to the same length. If l is defined as the number of lines in the program, each line in the program must have a length of 2 * l - 1

For example, the program on the left is valid, but the program on the right isn't:
 Valid    |  Invalid
          |
...A...   |  ABCDE
..BCD..   |  FGH
.EFGHI.   |  IJKLMN
JKLMNOP   |  OPQRS

When laid out in the valid structure, the name becomes obvious.
Task
Your task is to take a single line string as input, representing Triangularity code, and output it converted into valid code as described above.
Specifications for I/O:

The input will only contain characters in the range 0x20 - 0x7e
The length of the input always will be a square number and thus paddable nicely.
You must use dots for the output padding, not something else.

You may input and output through any acceptable method. This is a code-golf so the shortest code in bytes wins!
Test cases
input
----
output

g
----
g

PcSa
----
.P.
cSa

DfJ0vCq7G
----
..D..
.fJ0.
vCq7G

7xsB8a1Oqw5fhHX0
----
...7...
..xsB..
.8a1Oq.
w5fhHX0

QNYATbkX2sKZ6IuOmofwhgaef
----
....Q....
...NYA...
..TbkX2..
.sKZ6IuO.
mofwhgaef

ABCDEF"$%& G8"F@
----
...A...
..BCD..
.EF"$%.
& G8"F@

ab.c
----
.a.
b.c

For those who know Triangularity, you'll notice from the last test case that strings don't have to be handled

Sandbox post

I realise this is probably futile, but would the downvoter care to explain their vote? I'd love to improve the challenge in anyway I can.

Are leading or trailing newlines acceptable?

@Arnauld Yes, leading and trailing white space is perfectly fine.

Is a list of lines fine?

@Mr.Xcoder Yes, a list of lines is fine.

Triangularity, 127 bytes
.......).......
......2)1......
...../)IL^.....
....f)rMD@_....
...)2)1/)IL^...
..f+`"'.'*"+E..
.DWReD)2s^)Its.
D+@sh+s+})10cJ.

Try it online!
Explanation
Removing the characters that make up for the padding, we get the following program:
)2)1/)IL^f)rMD@_)2)1/)IL^f+`"'.'*"+EDWReD)2s^)ItsD+@sh+s+})10cJ

... Which is quite length-ish, right? Let's break it down into pieces.
Generating the integers [0 … √len(input))
)2)1/)IL^f)r – Subprogram #1.
)            – Creates a new stack entry, equal to 0. This must precede any integer
               literal, because each character in '0123456789' isn't parsed on its
               own as a literal, but rather they are commands which multiply the ToS
               by 10 and add the value of their digit equivalent.
 2           – ToS * 10 + 2 = 2.           || STACK: [2]
  )1         – The literal 1.              || STACK: [2, 1]
    /        – Division.                   || STACK: [1 / 2] = [0.5]
     )I      – Get the input at index 0.   || STACK: [0.5, input]
       L     – Length.                     || STACK: [0.5, len(input)]
        ^    – Exponentiation.             || STACK: [len(input) ** 0.5]
         f   – Trim decimals.              || STACK: [int(len(input) ** 0.5)]
          )r – Create the list [0 .. ToS). || STACK: [[0 ... int(len(input) ** 0.5))]

Generating the dots
MD@_)2)1/)IL^f+`"'.'*"+E – Subprogram #2.
MD                       – For each integer in the range, run some code on a separate
                           stack, preinitialised to two copies of the argument.
  @_                     – Increment and negate the ToS.
    )2)1/)IL^f           – The square root of the length of the input, again.
              +          – Add the two.
               `         – And cast the integer given to a string.
                "'.'*"+  – Prepends the literal "'.'*" to the string representation.
                       E – Evaluate as a Python expression (basically string repetition).

Trimming the characters at the front
DWReD)2s^)It – Subprogram #3.
D            – Duplicate the result of the expression above.
 W           – Wrap the whole intermediate stack to an array.
  Re         – Reverse the stack and dump the contents separately onto the stack.
    D        – Duplicate the result.
     )2      – Push the literal 2.
       s^    – Swap and perform exponentiation.
         )It – Push the input and trim the characters before that index.

Trimming the characters at the end
sD+@sh+s+ – Subprogram #4.
s         – Swap the top two elements on the stack.
 D+       – Double. Push twice and add.
   @      – Increment.
    sh    – Swap the top two elements and trim the characters after that index.
      +   – Append the first set of dots.
       s+ – And prepend the second set of dots.

Ending the loop and pretty-printing
})10cJ – Subprogram #5.
}      – End the loop.
 )10   – Push the literal 10.
    c  – Convert from code-point to character (yields '\n').
     J – And join the result by newlines.

do you have to score bytes for the "." characters if they are mandated by the intrinsics of the language?

@JDL Yes, the program cannot run correctly without them, so I must include them in the byte count :-)

Do you need to "trim decimals", seeing as the length of the input is guaranteed to be square? You should also be able to get rod of the J at the end and output an array of lines. Don't know if that's going to save you anything, though, if the end of the last line needs to be padded with . to fill the remaining space.

@Shaggy 1) Yes, f is needed because range cannot accept float arguments (even with .0) 2) Getting rid of J doesn’t save any bytes due to the padding, so I chose the prettier output format.

Japt, 15 14 10 bytes
Outputs an array of lines.
ò@°T¬v1Ãû.

Try it | Check all test cases

Explantion
ò@     Ã       :Partition at characters where the following function returns true
  °T           :  Increment T (initially 0)
    ¬          :  Square root
     v1        :  Divisible by 1?
               :(Or, in other words, split after every character with a 1-based index that's a perfect square)
        û.     :Centre pad each element with .s to the length of the longest element

Original Solution
Ê¬ÆsTT±X+°XÃû.

Try it
Ê                  :Length of input
 ¬                 :Square root
  Æ        Ã       :Range [0,Ê¬) and pass each X through a function
   s               :  Slice input
    T              :    from index T, initially 0
     T±X+°X        :    to index T incremented by X plus X incremented
            û.     :Centre pad each element with .s to the length of the longest element

05AB1E, 20 19 18 bytes
Saved a byte thanks to Magic Octopus Urn
ā·<£õKRvy'.N×.ø}r»

Try it online!
Explanation
ā                    # push the list [1 ... len(input)]
 ·<                  # multiply each by 2 and decrement each, making a list of odd numbers
   £                 # split the input into chunks of these sizes
    õK               # remove empty strings
      R              # reverse list
       vy      }     # for each y in the list
             .ø      # surround it with
         '.N×        # "." (dot) repeated N times, where N is the current iteration index
                r    # reverse the stack
                 »   # join stack by newlines

ÅÉ for odds may help?

Something like, g;ÅÉ£Rvy'.N×.ø}r»? But not that because that's not right lol.

@MagicOctopusUrn: ÅÉ would definitely help if we could find out the length of the bottom row in 2 bytes. I don't know if we can though. Might be another way to incorporate it as well.

@MagicOctopusUrn: I had this same solution earlier except I used )R instead of r which didn't save any bytes :/

I was trying to find a way to "reverse the loop" to just print as it occurs, no ideas on that though.

Husk, 15 bytes
Ṡzö`JR2tR'.ṡCİ1

Try it online!
Explanation
Ṡzö`JR2tR'.ṡCİ1  Implicit input, say s = "DfJ0vCq7G".
             İ1  List of odd positive integers: [1,3,5,7,..
            C    Cut s to those lengths: x = ["D","fJ0","vCq7G"]
           ṡ     Reversed indices of x: y = [3,2,1]
Ṡz               Zip x and y using this function:
                  Arguments are a string and a number, e.g. r = "fJ0" and n = 2.
        R'.       n copies of '.': ".."
       t          Drop first element: "."
     R2           Two copies of this: [".","."]
  ö`J             Join by r: ".fJ0."
                 Result is ["..D..",".fJ0.","vCq7G"]; implicitly print on separate lines.

Python 2, 83 bytes
i=input();u=int(len(i)**.5)
for t in range(u):g="."*(u+~t);print g+i[t*t:][:t-~t]+g

Try it online!

JavaScript (ES7), 82 78 bytes
f=(s,k=1-s.length**.5*2,p='')=>s&&f(s.slice(0,k),k+2,p+'.')+`
`+p+s.slice(k)+p

Test cases

f=(s,k=1-s.length**.5*2,p='')=>s&&f(s.slice(0,k),k+2,p+'.')+`
`+p+s.slice(k)+p

console.log(f('g'))
console.log(f('PcSa'))
console.log(f('DfJ0vCq7G'))
console.log(f('7xsB8a1Oqw5fhHX0'))
console.log(f('QNYATbkX2sKZ6IuOmofwhgaef'))
console.log(f('ABCDEF"$%& G8"F@'))

Commented
f = (                       // f = recursive function taking:
  s,                        //   s = input string
  k = 1 - s.length**.5 * 2, //   k = additive inverse of the length of the base
  p = ''                    //   p = padding string
) =>                        //
  s &&                      // if s is not empty:
    f(                      //   do a recursive call with:
      s.slice(0, k),        //     s without the last -k characters
      k + 2,                //     the updated base length (2 less characters)
      p + '.'               //     the updated padding string
    ) +                     //   end of recursive call()
    `\n` +                  //   append a line feed
    p +                     //   append the left padding string
    s.slice(k) +            //   append the last -k characters of s
    p                       //   append the right padding string

[minor] the '/n' symbol became an actual line break in the code block at the top - consider escaping it for clarity :)

@G0BLiN This is the other way around: this is indeed a literal line break in the golfed code, which was replaced with an escaped line break in the ungolfed version for clarity. :)

Ha, joke's on me, then... :-)

Jelly,  22  19 bytes
J²‘Ṭœṗ⁸Ṛz”.Zµṙ"JC$Ṛ

A monadic link returning a list of lists of characters (the lines)
Try it online!
How?
J²‘Ṭœṗ⁸Ṛz”.Zµṙ"JC$Ṛ - Link: list of characters e.g. "DfJ0vCq7G"
J                   - range of length               [1,2,3,4,5,6,7,8,9]
 ²                  - square (vectorises)           [1,4,9,16,25,36,49,64,81]
  ‘                 - increment                     [2,5,10,17,26,37,50,65,82]
   Ṭ                - untruth (1s at those indices) [0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,...]
      ⁸             - chain's left argument         "DfJ0vCq7G"
    œṗ              - partition at indexes          ["D","fJ0","vCq7G"]
       Ṛ            - reverse                       ["vCq7G","fJ0","D"]
         ”.         - literal '.'                   '.'
        z           - transpose with filler         ["vfD","CJ.","q0.","7..","G.."]
           Z        - transpose                     ["vCq7G","fJ0..","D...."]
            µ       - start a new monadic chain
                 $  - last two links as a monad:
               J    -   range of length             [1,2,3]
                C   -   complement (vectorises)     [0,-1,-2]
              "     - zip with:
             ṙ      -   rotate left by              ["vCq7G",".fJ0.","..D.."]
                  Ṛ - reverse                       ["..D..",".fJ0.","vCq7G"]

MATL, 21 bytes
tnX^eRP&1ZvGyg(46y~(!

Try it online!
Explanation
Consider input 'DfJ0vCq7G' as an example. The stack contents are shown separated by commas, with the top element last. Rows in a 2D array use semicolon as separator.
t      % Implicit input: string. Duplicate
       % STACK: 'DfJ0vCq7G',
                'DfJ0vCq7G'
nX^    % Number of elements. Square root
       % STACK: 'DfJ0vCq7G',
                3
e      % Reshape with that many rows (in column major order)
       % STACK: ['D0q';
                 'fv7';
                 'JCG']
R      % Upper triangular part: set elements below diagonal to char(0)
       % (displayed as space)
       % STACK: ['D0q';
                 ' v7';
                 '  G']
P      % Flip vertically
       % STACK: ['  G';
                 ' v7';
                 'D0q']
&1Zv   % Reflect vertically
       % STACK: ['  G';
                 ' v7';
                 'D0q';
                 ' v7';
                 '  G']
G      % Push input again
       % STACK: ['  G';
                 ' v7';
                 'D0q';
                 ' v7';
                 '  G'],
                'DfJ0vCq7G'
yg     % Duplicate from below and convert to logical. This gives true for
       % for nonzero chars (the entries where input chars will be written)
       % STACK: ['  G';
                 ' v7';
                 'D0q';
                 ' v7';
                 '  G'],
                'DfJ0vCq7G',
                [0 0 1;
                 0 1 1;
                 1 1 1;
                 0 1 1;
                 0 0 1]
(      % Assignment indexing: write values at those positions
       % STACK: ['  v';
                 ' fC';
                 'DJq';
                 ' 07';
                 '  G']
46     % Push 46, which is ASCII for '.'
       % STACK: ['  v';
                 ' fC';
                 'DJq';
                 ' 07';
                 '  G'],
                 46
y~     % Duplicate from below and apply logical negate. This gives true
       % for char(0) (the entries where '.' will be written)
       % STACK: ['  G';
                 ' v7';
                 'D0q';
                 ' v7';
                 '  G'],
                46
                [1 1 0;
                 1 0 0;
                 0 0 0;
                 1 0 0;
                 1 1 0]
(      % Assignment indexing: write value at those positions
       % STACK: ['..G';
                 '.v7';
                 'D0q';
                 '.v7';
                 '..G'],
!      % Transpose. Implicit display
       % STACK: ['..D..';
                 '.fJ0.';
                 'vCq7G']

05AB1E, 25 bytes
gÅÉ£õKð'ø‡.c¶¡ζøð'.‡'øð‡»

Try it online!

Clean, 107 94 89 88 bytes
import StdEnv
@s _[]=s
@s n r= @([['.':l]++['.']\\l<-s]++[take n r])(n+2)(drop n r)

@[]1

Try it online! Example usage: @[]1 ['ABCDEF"$%& G8"F@'].

Red, 227 203 bytes
f: func[s][l: to-integer(length? s)** 0.5
n: 0 foreach m parse s[collect[(r: []repeat i l[append r reduce['keep i * 2 - 1
charset[not{Я}]]])r]][v: copy""insert/dup v"."l - n: n + 1 print rejoin[v m v]]]

Try it online!
Ungolfed:
f: func[s][
l: to-integer (length? s) ** 0.5
n: 0
foreach m parse s [
    collect [
        (r: []
        repeat i l [ append r reduce [
            'keep i * 2 - 1 charset [ not{Я} ]]])
    r ]]
    [v: copy ""
    insert/dup v "." l - n: n + 1
    print rejoin [v m v]]
]

Haskell, 84 68 bytes
[]%1
(s%n)[]=s
(s%n)r=(['.':l++"."|l<-s]++[take n r])%(n+2)$drop n r

Try it online!
Example usage: []%1 $ "abcd" yields the list of lines [".a.","bcd"].

Perl, 56 52 bytes
Includes +3 for -p
#!/usr/bin/perl -p
$_=("."x y///c**.5)=~s%.%$'@{[$&x/$`$`./g]}$'
%rg

Give input on STDIN (in principle without final newline, but that only matters for the empty input)

according to PCG rules -p costs only 1 byte

@mik Only if the code doesn't contain '. But this code does, so it needs to be put in a file (or escaping on the commandline) which needs 3 extra characters compared to the normal #! line. So in this case it is +3 (for normal code you will see I indeed only count + for p)

Charcoal, 21 19 bytes
ＵＢ.Ｆ₂Ｌθ«Ｐ✂θＸι²Ｘ⊕ι²↙

Try it online! Link is to verbose version of code. Edit: Saved 2 bytes by discovering SquareRoot. Explanation:
ＵＢ.                 Set the background fill to `.`
      θ             (First) input
     Ｌ              Length
    ₂               Square root
   Ｆ   «            Loop over implicit range
            ι   ι   Current value
               ⊕    Incremented
             ²   ²  Literal 2
           Ｘ  Ｘ     Power
         ✂θ         Slice the (first) input string
        Ｐ           Print without moving the cursor
                  ↙ Move down left

:/ This almost works but it appears Charcoal is a bit buggy. This works though, I think?

@ASCII-only ... what black magic is this?

Fill basically checks for null bytes (i.e. the character used for space where nothing is drawn), so you can just draw a polygon with null bytes (well, if it even works correctly >>) and fill that. Obviously this isn't exactly intended since you can actually see the null bytes even before the fill for some reason >>

this should work properly next pull

Retina, 88 72 71 bytes
S1`
+m`^(.)+¶(?>(?<-1>.)+)..(?!¶)
$&¶
P^'.m`^.(?=(..)*)(?<-1>.)*
P'.`.+

Try it online! Edit: Saved 12 13 bytes thanks to @MartinEnder. Explanation:
S1`

Split first character into its own line to get the ball rolling.
+m`^(.)+¶(?>(?<-1>.)+)..(?!¶)
$&¶

Chop each line two characters longer than the previous one.
P^'.m`^.(?=(..)*)(?<-1>.)*

Left-pad the first half of each line, effectively centring them.
P'.`.+

Right-pad all of the lines.

Python 2, 84 bytes
s=input()
l=int(len(s)**.5)
for i in range(l):print s[i*i:][:i-~i].center(l*2-1,'.')

Try it online!

Clean, 123 bytes
import StdEnv
?n l#(a,b)=splitAt n l
|b>[]=[a: ?(n+2)b]=[a]
$s#s= ?1s
=[c++l++c\\l<-s&i<-[1..],c<-[repeatn(length s-i)'.']]

Try it online!

Some friendly competition.

@Laikoni Ooh, that's my favourite kind of competition!

Ruby, 73 66 bytes
->s{(1..z=s.size**0.5).map{|q|s[q*q-2*q+1...q*q].center 2*z-1,?.}}

Try it online!
-5 bytes: Return an array of strings instead of printing them
-2 bytes: Declare z in place instead of ahead of time
Ungolfed:

->s{
  (1..z=s.size**0.5).map{|q|   # Map the range [1,sqrt(s.size)]
    s[q*q-2*q+1...q*q]         # To the relevant portion of s,
      .center 2*z-1, ?.        #   padded left and right with . characters
  }
}

Declaring a variable r=q-1 so that I can take s[r*r...q*q] saves exactly zero bytes.
Using .center instead of padding manually also saves zero bytes, but I like it better.

Stax, 19 bytes
╚└÷2╬#►o┴X≡¥ΩåV∙¬?♥

Run and debug it
ASCII equivalent:
z;%|q{Hv,:/~]+F|Cm0]'.R


text:
Panfix to parenthesized infix
Quylthulg is a language by Chris Pressey that attempts to solve the problem of infix notation using what it calls panfix:

like postfix, panfix does not require the deployment of arcane contrivances such as parentheses to override a default operator precedence. At the same time, panfix allows terms to be specified in the same order and manner as infix, an unquestionably natural and intuitive notation to those who have become accustomed to it.

How do you get the convenience of infix notation along with the unambiguity of prefix or postfix? Use all three, of course!
=y=+*3*x*+1+=

More formally, let + be an operator, and a and b be expressions. Then (a+b) is a valid (parenthesized) infix expression, the panfix representation of that expression is +a+b+, where juxtaposition represents concatenation.
Your goal is to take a panfix string and convert it to fully parenthesized infix:
(y=((3*x)+1))

For simplicity, we'll make the following changes:

Operators can only consist of two unique characters (you can choose any, but here I'll use * and +).
There is only one literal, which consists of another distinct character (you can choose any, but here I'll use _).
The input will be a well-formed panfix expression.

For complexity, we'll make the following change:

Operators can consist of any positive number of characters, not just one.

This makes the challenge more tricky because you can't necessarily determine how a given substring of operator characters is partitioned without looking at the rest of the string.
Here is a reference implementation for the challenge, courtesy of @user202729.
Test Cases
format: input -> output
+*+_*+_*+++_+*+_*+_*+++ -> ((_*+_)+(_+(_*+_)))
**++*+***++_+_++_+*++*+***_*++*+*****_**_*_*** -> ((((_+_)+_)*++*+***_)*(_*(_*_)))
***_**_***_* -> ((_**_)*_)
+_+_+ -> (_+_)
*+*+++**+***+++++_*+*+++**+***+++++_*+*+++**+***+++++ -> (_*+*+++**+***+++++_)
*++++*+*_*_*+*+++****+_++****+_++****++*+*+++_*+++ -> (((_*_)+*+(_++****+_))*+++_)
+**+_*+_*+*_*+*_*+*_+*_+**+ -> (((_*+_)*_)+(_*(_+*_)))
+**+++++_+++++_+++++*_*+*+_++++++_+++++_+++++++* -> (((_+++++_)*_)+*(_+(_+++++_)))
+*+*+_+*+_+*+*_*+*_*+*+_+*+_+*+*+ -> (((_+*+_)*_)+(_*(_+*+_)))
**_**_**_*_****_* -> ((_*(_*(_*_)))*_)

I used this program to generate infix strings for this challenge (converting to panfix was trivial, but reversing is not).

The inverse

Shouldn't the last example have an extra layer of () around the whole result ?

@TonHospel Fixed.

Related

Suggested test case: **_**_**_*_****_*.  The answers I've tested have all failed this one.

Can I have extra spaces in my output, e.g. (_ + _) ?

@TonHospel Sure.

Prolog (SWI), 194 163 bytes
Saved a whopping 31 bytes using this tip from 0 '!
[C|T]/O/R:-C\=x,(T/P/R,concat(C,P,O);O=C,R=T).
[x|R]-x-R.
L-X-R:-L/O/A,A-Y-B,B/O/C,C-Z-D,D/O/R,atomics_to_string(['(',Y,O,Z,')'],X).
X^P:-string_chars(X,L),L-P-[].

The operator ^ takes for its left argument a string containing a panfix expression and sets its right argument to a string containing the corresponding parenthesized infix expression. It uses x as the literal in place of _.
Try it online!
Explanation
Since Prolog is a declarative language, we just have to describe the relation between a panfix and a parenthesized expression.
The explanation uses this slightly ungolfed version:
oper([C|T],O,R) :- C\=x, oper(T,P,R), concat(C,P,O).
oper([C|T],C,T).

expr([x|R],x,R).
expr(L,X,R) :- oper(L,O,A), expr(A,Y,B), oper(B,O,C), expr(C,Z,D), oper(D,O,R),
               atomics_to_string(['(',Y,O,Z,')'],X).

parenthesize(X,P) :- string_chars(X,L), expr(L,P,[]).

Our main production is parenthesize, which takes in a panfix expression X as a string and sends out the corresponding parenthesized infix expression P as a string. It uses string_chars to convert the input string into a list of characters and then simply passes it on to expr.
expr takes in a list of characters L, parses the first panfix expression it finds in L, and sends out the parenthesized equivalent X and the remainder of the list of characters R. There are two possible kinds of expressions:

If the first character of L is x, then the expression is x and the remainder is everything after the x.
Otherwise, parse an operator O (see oper below); parse an expression Y; parse O again; parse another expression Z; and parse O a third time. The remainder is everything after the third instance of O. The expression is the result of joining Y, O, and Z, surrounded by parentheses, into a string.

oper takes in a list of characters, where the first character is C and the rest are T; it parses an operator (i.e. a run of one or more operator characters) and sends out the operator O and the remainder of the list of characters R. To form an operator, the character C must be something other than x; also, either

an operator P must be parseable from T, with remainder R; in this case, O is the concatenation of C and P; or,
O is the single character C; in this case, R is just T.

A worked example
Let's take the input +*+x+x++*x+* for an example.

We want to parse an expression from +*+x+x++*x+*. This doesn't start with x, so we parse an operator from the beginning.
oper will parse as big of an operator as possible, so we try +*+.

Next we parse an expression from x+x++*x+*. This has to be x.
Now we try to parse the same operator, +*+, from +x++*x+*. However, this fails.

So we backtrack and try parsing the operator +* instead.

We parse an expression from +x+x++*x+*. This doesn't start with x, so we need to parse an operator.
The only possibility is +.
Now parse a subexpression from x+x++*x+*. This has to be x.
Now parse + again from +x++*x+*.
Now parse another subexpression from x++*x+*. This has to be x.
Finally, parse + again from ++*x+*.
The expression has been successfully parsed. We return the string (x+x).

Back at the previous recursion level, we parse the operator +* again from +*x+*.
Now parse another subexpression from x+*. This has to be x.
Finally, parse +* again from +*.
The expression has been successfully parsed. We return the string ((x+x)+*x).

Since there are no more characters left, we have successfully translated the expression.

Perl, 78 60 58 57 50 bytes
Includes +1 for p
Uses 1 for + and 2 for * (or in fact any digit works for any operator)
perl -pe 's/\b((\d+)((?1)|_)\2((?3))\2)\b/($3 $2 $4)/&&redo' <<< 22_22_22_2_2222_2

For convenient testing versus the given examples you can use this which does the translations and space removal for you:
perl -pe 'y/+*/12/;s/\b((\d+)((?1)|_)\2((?3))\2)\b/($3 $2 $4)/&&redo;y/ //d;y/12/+*/' <<< "**_**_**_*_****_*"

Retina 0.8.2, 138 134 bytes
.+
($&)
+`\((\d+)(_|((?<i>(?<i>\d+))|_(?<-i>\k<i>)+)+(?(i)$.))\1(_|((?<i>(?<i>\d+))|_(?<-i>\k<i>)+)+(?(i)$.))\1\)
(($2)$1($4))
\(_\)
_

Try it online! Link includes the faster test cases. Explanation: The regex engine uses backtracking to split the string up into tokens which are then pushed on or popped from the i balancing group. There is a run of always at least one operator pushed at the start before the first variable. After a variable, at least one operator is popped, at which point either a pushed operator run or another variable is legal. Operators get pushed to the group in duplicate so that they can be popped correctly. Example:
Input           Stack
Push *          * *
Push *++*+***   * * *++*+*** *++*+***
Push +          * * *++*+*** *++*+*** + +
Push +          * * *++*+*** *++*+*** + + + +
Variable _
Pop +           * * *++*+*** *++*+*** + + +
Variable _
Pop +           * * *++*+*** *++*+*** + +
Pop +           * * *++*+*** *++*+*** +
Variable _
Pop +           * * *++*+*** *++*+***
Pop *++*+***    * * *++*+***
Variable _
Pop *++*+***    * *
Pop *           *
Push *          * * *
Variable _
Pop *           * *
Push *          * * * *
Variable _
Pop *           * * *
Variable _
Pop *           * *
Pop *           *
Pop *

Unfortunately this doesn't help us capture the results in order to bracket them, so the outer operator is matched manually. The brackets are added outside-in, so the first stage wraps the entire expression in brackets and the last stage removes them now that they have propagated down to the variables.

This also fails for **_**_**_*_****_*.

@user202729 Working now?

@Neil It's working now, yes.

Clean, 200 192 189 bytes
import StdEnv,Text
f"_"=["_"]
f l=["("+a+p+b+")"\\p<-[l%(0,i)\\i<-[0..indexOf"_"l]|endsWith(l%(0,i))l],t<-[tl(init(split p l))],n<-indexList t,a<-f(join p(take n t))&b<-f(join p(drop n t))]

Try it online!
Defines the function f, taking String, and returning a singleton [String] with the result inside.
Some neat stuff:

Doesn't use regex
Works with any character for operators except _

Haskell, 167 166 bytes
head.e
e('_':r)=["_",r]
e(x:r)=[x]%r
e _=[]
o%t@(c:r)|[x,u]<-e t,n<-length o,[y,v]<-e$drop n u,all((==o).take n)[u,v]=['(':x++o++y++")",drop n v]|p<-o++[c]=p%r
o%_=[]

Try it online! Example usage: head.e "**_**_**_*_****_*" yields ((_*(_*(_*_)))*_). All characters except _ are interpreted as operators, _ itself denotes an identifier.

Python 3, 226 bytes
from re import*
P=r'([*+]+)'+r'(\(.+?\)|_)\1'*2;R=lambda i,J=lambda i,o:i[:o]+sub(P,lambda o:'('+o[2]+o[1]+o[3]+')',i[o:],1),s=search:s(P,i)and R([J(i,o)for o in range(len(i))if s(P,J(i,o))or J(i,o)[0]+J(i,o)[-1]=='()'][0])or i

Defines an anonymous function named R.
Try it Online!

Note that you can use any characters other than _*+; those were just what were used in the example. You might be able to use this to golf your regexes (e.g. by using \d instead of [*+]).

Tamsin, 135 bytes
e="_"|o->O&{!(e&m(O)&e&m(O))&o->E&O<-[O,E]}&e->L&m(O)&e->R&m(O)->O&'('+L+O+R+')'.o="+"|"*".m([X,Y])=m(X)->X&<<Y>>->Y&''+X+Y.m(X)=<<X>>.

Try it online!

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


text:
Infer geometric sequences
Haskell has this neat(-looking) feature where you can give it three numbers and it can infer an arithmetic sequence from them. For example, [1, 3..27] is equivalent to [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27].
That's cool and all but arithmetic sequences are fairly limiting. Addition, pfft. Multiplication's where it's at. Wouldn't it be cooler if it did geometric sequences like [1, 3..27] returning [1, 3, 9, 27]?
Challenge
Write a program/function that takes three positive integers a, b, and c and outputs [a, b, b × (b ÷ a), b × (b ÷ a)2, ..., x] where x is the greatest integer ≤ c that can be represented as b × (b ÷ a)n where n is a positive integer.
That is, the output should be r, such that:
r0 = a
r1 = b
rn = b × (b ÷ a)n-1
rlast = greatest integer ≤ c that can be represented as b × (b ÷ a)n
         where n is a positive integer
Specifications

Standard I/O rules apply.
Standard loopholes are forbidden.
b will always be divisible by a.
a < b ≤ c
This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
Built-in functions (Mathematica might have one :P) that compute this sequence are allowed but including a solution that doesn't rely on a built-in is encouraged.
Explanations, even for "practical" languages, are encouraged.

Test cases
a   b   c     r

1   2   11    [1, 2, 4, 8]
2   6   100   [2, 6, 18, 54]
3   12  57    [3, 12, 48]
4   20  253   [4, 20, 100]
5   25  625   [5, 25, 125, 625]
6   42  42    [6, 42]
In a few better formats:
1 2 11
2 6 100
3 12 57
4 20 253
5 25 625
6 42 42

1, 2, 11
2, 6, 100
3, 12, 57
4, 20, 253
5, 25, 625
6, 42, 42

@Adám No. (see the first test case)

Note that the formula is simply b^n/a^n-1. Starting at n=0

Of course Mathematica has a built-in...

is it acceptable if the results are not exactly integers due to floating point errors?

@LuisMendo Yes.

Husk, 8 bytes
~↑≤Ṡ¡o//

Input is in order b, c, a.
Try it online!
Explanation
~↑≤Ṡ¡o//  Implicit inputs.
       /  a/b as exact rational number.
     o/   Divide by a/b (so multiply by b/a).
    ¡     Iterate that function
   Ṡ      on a. Result is the infinite list [a, b, b^2/a, b^3/a^2, ..
 ↑        Take elements from it while
~ ≤       they are at most c.

The control flow in this program is a bit hard to follow.
First, b is fed to the rightmost /, producing a function /b that divides by b.
Next, ~ splits the remaining program into three parts: ~(↑)(≤)(Ṡ¡o//b).
This feeds c to ≤ and a to Ṡ¡o//b, and combines the results with ↑.
The result of ≤c is a function that checks if its argument is at most c, and ↑≤c takes the longest prefix of elements for which this holds.
It remains to show how (Ṡ¡o//b)a evaluates to the desired infinite list.
The part in parentheses is split into Ṡ(¡)(o//b).
Then Ṡ feeds a to o//b, feeds the result to ¡, and then gives a to its second argument.
The expression (o//b)a gives a function that takes a number and divides it by a/b, and ¡ iterates this function on its second argument, which is a.
Here is a series of transformations that visualize the explanation:
  (~↑≤Ṡ¡o//) b c a
= (~↑≤Ṡ¡o/(/b)) c a
= ~(↑)(≤)(Ṡ¡o/(/b)) c a
= ↑(≤c)((Ṡ¡o/(/b)) a)
= ↑(≤c)(Ṡ(¡)(o/(/b)) a)
= ↑(≤c)(¡(o/(/b)a) a)
= ↑(≤c)(¡(/(/ba))a)
Last line in English: takeWhile (atMost c) (iterate (divideBy (divideBy b a)) a)

Alternative solution using explicit variables in order a, b, c:
↑≤⁰¡*/⁵²

Python 2, 42 bytes
a,b,c=input()
x=b/a
while c/a:print a;a*=x

Try it online!
Recursive approach, 42 41 bytes
-1 byte thanks to ovs
f=lambda a,b,c:c/a*[a]and[a]+f(b,b*b/a,c)

Try it online!

Proton, 35 bytes
f=(a,b,c)=>c//a?[a]+f(b,b*b/a,c):[]

Try it online!

people actually remember this language? :D

@HyperNeutrino I actively use it :)

I know that I am probably not going to receive any answer, but why the downvote?

JavaScript (ES6), 41 37 bytes
Saved 4 bytes thanks to @Neil
Takes input as (b,c)(a).
(b,c)=>g=a=>a>c?[]:[a,...g(b,b*=b/a)]

Test cases

let f =

(b,c)=>g=a=>a>c?[]:[a,...g(b,b*=b/a)]

console.log(JSON.stringify(f(2,11)(1)))
console.log(JSON.stringify(f(6,100)(2)))
console.log(JSON.stringify(f(12,57)(3)))
console.log(JSON.stringify(f(20,253)(4)))
console.log(JSON.stringify(f(42,42)(6)))

Commented
(b, c) =>                 // main function taking b and c
  g = a =>                // g = recursive function taking a
    a > c ?               //   if a is greater than c:
      []                  //     stop recursion and return an empty array
    :                     //   else:
      [ a,                //     return an array consisting of a, followed by
        ...g(             //     the expanded result of a recursive call to g()
          b,              //       with a = b
          b *= b / a      //       and b = b * ratio
        ) ]               //     end of recursive call

Rearranging the arguments gives me (b,c)=>g=a=>a>c?[]:[a,...g(b,b*=b/a)].

Wolfram Language (Mathematica), 22 bytes
PowerRange[#,#3,#2/#]&

Try it online!

Pari/GP, 38 bytes
f(a,b,c)=powers(b/a,logint(c\a,b/a),a)

Try it online!

 Python 3, 93 90 74 73 bytes
x=lambda a,b,c,i=0,q=[]:a*(b/a)**i>c and q or x(a,b,c,i+1,q+[a*(b/a)**i])

Try It Online
Thanks to Rod and user202729 for helping me reduce quite some bytes!

def + return -> lambda. Python tips.

Also you can import*.

you can use while i<=c:i++ (instead list comprehension+log) to save a lot of bytes

@Rod How should I use the while loop without the log? idk how long to iterate

You can use while a*(b/a)**i<=c (this is what I meant to write on the other comment, idk what happened)

All suggestions considered. Thanks for -19 bytes.

-1 byte.

Octave, 38 35 bytes
@(a,b,c)exp(log(a):log(b/a):log(c))

Try it online!
Turns out @LuisMendo's MATL approach also saves 3 bytes in Octave, despite repeating log three times.

Perl 6, 26 24 bytes
{$^a,$^b,$b²/$a...^*>$^c}
{$^a,*×$^b/$a...^*>$^c}

Try it online!
Perl 6's sequence operator ... can infer geometric series natively.
Update:  ...It can, but in this situation not inferring it is a bit shorter.

05AB1E, 12 bytes
Input in the order c,b,a
ÝmI¹Ý<m/ʒ¹›_

Try it online!
Explanation
Ý              # push the range [0 ... c]
 m             # raise b to the power of each
  I            # push a
   ¹Ý          # push the range [0 ... c]
     <         # decrement each
      m        # push a to the power of each
       /       # elementwise division of ranges
        ʒ      # filter, keep only elements that are
         ¹›_   # not greater than c

MATL, 17 bytes
t:,qtiw^w]x/tb>~)

Try it online!
Just to get the ball rolling in MATL. I can't imagine there isn't a less verbose way of solving this.

... No triple negation please.

@user202729 I don't see how you could not have gotten that that wasn't an accident.:)

Don't you mean "I don't see how you could not have gotten that that wasn't done unintentionally" :P

@HyperNeutrino No.

Keep the ball rolling

MATL, 12 bytes
y/ivZlZ}3$:W

Try it online! Or verify all test cases.
Explanation
y     % Implicitly take two inputs, and duplicate the first onto the top
/     % Divide
i     % Take third input
v     % Vertically concatenate the three numbers into a column vector
Zl    % Binary logarithm, element-wise
Z}    % Split the vector into its three components
3$:   % Three-input range. Arguments are start, step, upper limit
W     % 2 raised to that, element-wise. Implicit display

This is really nice. I was struggling with reusing a and c (I have many failed attempts starting with y/i), but using this method, you neatly keep everything together.

this approach was actually 3 bytes shorter in Octave too.

Haskell, 35 bytes
(a#b)c|a>c=[]|d<-div b a*b=a:(b#d)c

Try it online!

34 bytes. (more "in the spirit of the challenge", terrible floating point error)

@user202729: please post it as a separate answer (but save a byte: exp<$>[...])

Perl, 38 bytes
Include +3 for -n (the use 5.10.0 to unlock the perl 5.10 features is free)
#!/usr/bin/perl -n
use 5.10.0;
/ \d+/;say,$_*=$&/$`until($_+=0)>$'

Then run as:
geosequence.pl <<< "1 3 26"

Red, 50 bytes
g: func[a b c][if a <= c[print a g b b * b / a c]]

Try it online!

Japt, 14 bytes
ÆWpX zVpXÉÃf§U

Try it

Explanation
                    :Implicit input of integers U=c, V=a & W=b
Æ         Ã         :Range [0,U) and pass each X through a function
 WpX                :  W to the power of X
     z              :  Floor divide by
      VpXÉ          :  V to the power of X-1
           f§U      :Filter elements less than or equal to U

Clean, 63 bytes
import StdEnv
$a b c=takeWhile((>=)c)[a:map(\n=b*b^n/a^n)[0..]]

Try it online!

TI-BASIC, 31 bytes
Takes input from user and outputs in Ans.  I solved for n in c = bn / an-1, getting n = 1 + ln(c/b) / ln(b/a).  That's the same as n = 1 + logb/a(c/b).  For the purposes of golfing, I start my sequence at -1 and end it at n-1 rather than 0 to n.
Prompt A,B,C
seq(B(B/A)^N,N,-1,logBASE(C/B,B/A

APL (Dyalog Unicode), 38 bytes
{(g≤⊃⌽⍵)⊆g←f,(⍵[1]*p+1)÷(f←⊃⍵)*p←⍳⊃⌽⍵}

Try it online!
Prefix Dfn. Takes input in order a b c, and uses ⎕IO←0 (Index Origin)
Thanks to @ErikTheOutgolfer for shaving 6 bytes out of this before I even posted it.
How?
{(g≤⊃⌽⍵)⊆g←f,(⍵[1]*p+1)÷(f←⊃⍵)*p←⍳⊃⌽⍵} ⍝ Prefix Dfn. Input ⍵ is a vector
                                    ⌽⍵  ⍝ Reverse ⍵. Yields c b a
                                   ⊃    ⍝ Pick the first element (c)
                                  ⍳     ⍝ Index. Yields the integers 0..c-1
                                p←      ⍝ Assign to the variable p
                               *        ⍝ Exponentiate
                         (f←⊃⍵)         ⍝ Pick the first element of ⍵ (a) and assign to f
                                        ⍝ This yields the vector (a^0, a^1, ..., a^c-1)
                        ÷               ⍝ Element-wise division
                    p+1)                ⍝ The vector 1..c
                   *                    ⍝ Exponentiate
              (⍵[1]                     ⍝ Second element (because of ⎕IO←0) of ⍵ (b)
                                        ⍝ This yields the vector (b^1, b^2, ..., b^c)
            f,                          ⍝ Prepend f (a). This yields the vector
                                        ⍝ (a, b^1/a^0, b^2/a^1, ...)
          g←                            ⍝ Assign the vector to g
         ⊆                              ⍝ Partition. This takes a boolean vector as left
                                        ⍝ argument and drops falsy elements of the right argument.
     ⊃⌽⍵)                               ⍝ Pick the last element of ⍵ (c)
  (g≤                                   ⍝ Check if each element of g≤c. Yields the boolean
                                        ⍝ vector that is the left argument for ⊆

APL (Dyalog), 23 bytes (SBCS)
This takes arguments a b on the left and c on the right,
{⊃(⍵∘≥⊆⊢)⊣/⍵2⍴⍺,÷\⍵⍴⌽⍺}

Try it online!
There is likely a shorter way, but I thought that ÷\ was cute.
Explained:
{...} Anonomous function ⍺ is a b, ⍵ is c. Lets say a b c = 2 6 100
⌽⍺ Reverse ⍺: 6 2
⍵⍴ Repeat ⍵ times: 6 2 6 2 6 2 6 2 ...
÷\ Reduce by division on prefixes: 6 (6÷2) (6÷(2÷6)) (6÷(2÷(6÷2))).. = 6 3 18 9 54 ..
⍺, Prepend ⍺: 2 6 6 3 18 9 54 27 162 81 ...
⊣/⍵2⍴ Get every other element (plus some trailing repeats):
  ⍵2⍴ Make an ⍵ row, 2 column matrix from 2 6 6 3 18 9 54 ...
  ⊣/ Get the first column
⊆⊢ Split the array into blocks where
⍵∘≥ ⍵ is greater than or equal to all the elements
⊃ Take the first such block

Stax, 14 bytesCP437
ü╞¥ß¥║/,5å╘⌂åº

16 bytes when unpacked,
E~Y/y{;^<}{[*gfm

Run and debug online!
Takes input in the form of [b, a, c].
Pretty sure @recursive has better solutions.
Explanation
E~                              Parse  input, put `c` on input stack
  Y/                            Store `a` in register `y` and calculate `b`/`a`
    y                           Put `y` back to main stack, stack now (from top to bottom): [`a`, `b`/`a`]
     {   }{  gf                 generator
      ;^<                       Condition: if the generated number is smaller than the top of input stack (i.e. `c`)
           [*                   duplicate the second item in main stack and multiply it with the item at the top
                                   i.e. multiply last generated value by `b/a` and generate the value
              m                 Output array, one element on each line

S.I.L.O.S, 73 bytes
readIO
k=i
readIO
j=i
readIO
r=j/k
a=k
lbla
printInt a
a*r
b=i-a+1
if b a

Try it online!
We read the three numbers. Calculate the common ratio by the second number/ first one. Then we run through the series until we are greater than the upper bound.

C (gcc), 82 bytes
n;f(a,b,c){float r=0;for(n=0;r<=c;)(r=pow(b,n)/pow(a,n++-1))<=c&&printf("%f ",r);}

Try it online!
Calculates and prints r_n = b^n/a^(n-1) until r_n > c.
Must be compiled with -lm!

69 bytes n;f(a,b,c){for(float r=n=0;r=pow(b/a,n++)*a,r<=c&&printf("%f ",r););}


text:
The Keyboard Shift Cipher
Given the following input:

An integer n where n > 0.
A string s where s is not empty and s~=[0-9A-Z]+ (alpha-numeric capitals only).

Using a standard, simplified QWERTY keyboard (as shown below):
1234567890
QWERTYUIOP
ASDFGHJKL
ZXCVBNM

Perform the following operation:

Find the original row that each character is in on the keyboard.
Replace the letter with the correct shifted equivalent for n based on its original position + n.

E.G. s="AB" and n=2: A would become D and B would become M.

If keyboard_row[position + n] > keyboard_row.length, wrap back to the start.

E.G. s="0P" and n=2: 0 would become 2 and P would become W.

Examples:
f("0PLM",1)    = 1QAZ
f("ZXCVB",2)   = CVBNM
f("HELLO",3)   = LYDDW
f("0PLM",11)   = 1QSV
f("0PLM",2130) = 0PHX

Rules

This is code-golf, lowest byte-count wins.

This is slightly more difficult than it seems at first glance.

Are we allowed to take the input as character-array instead of string? Currently assumed we, but forgot to ask..

@KevinCruijssen shrug sure, it's not too outlandish. Unless it saves you a byte to break a tie I'm not complaining.

Jelly, 13 bytes
ØQØDṭ,ṙ€¥⁸F€y

Try it online!
How it works
ØQØDṭ,ṙ€¥⁸F€y  Main link. Left argument: n (integer). Right argument: s (string)

ØQ             Qwerty; set the return value to
               ["QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM"].
  ØD           Digits; yield "0123456789".
    ṭ          Tack, yielding ["QWERTYUIOP", "ASDFGHJKL", "ZXCVBNM", "0123456789"].
        ¥⁸     Call the two links to the left as a dyadic chain, with right
               argument n.
      ṙ€       Rotate each string in the array n units to the left.
     ,         Yield the pair of the unmodified and the rotated string array.
          F€   Flatten each, mapping, e.g., ["QWERTYUIOP", ..., "0123456789"] to
               "QWERTYUIOPASDFGHJKLZXCVBNM0123456789".
            y  Translate s according to the mapping we've built.

Jelly has keyboard-layout built-ins eh?

@MagicOctopusUrn No, only QWERTY right now :-P

13 bytes? Which character set is that supposed to be? In UTF-8 it's 26 bytes!

@Cephalopod Jelly uses the Jelly code page.

I'm not going to complain about regex anymore

Python 2, 110 bytes
lambda s,n,y='1234567890'*99+'QWERTYUIOP'*99+'ASDFGHJKL'*99+'ZXCVBNM'*99:''.join(y[y.find(c)+n%630]for c in s)

Try it online!
This uses a big enough string (99 copies of each row) and the LCM between the rows lengths (630) to find the correct substitution avoiding individual correction between each row.

Java 8, 159 158 bytes
n->s->{for(int i=s.length,j;i-->0;)for(String x:"1234567890;QWERTYUIOP;ASDFGHJKL;ZXCVBNM".split(";"))if((j=x.indexOf(s[i])+n)>=n)s[i]=x.charAt(j%x.length());}

-1 byte thanks to @OlivierGrégoire modifying the input-array instead of printing directly.
Explanation:
Try it online.
n->s->{  // Method with integer and character-array parameters, and no return-type
  for(int i=s.length,j;i-->0;)
         //  Loop over the input character-array with index
    for(String x:"1234567890;QWERTYUIOP;ASDFGHJKL;ZXCVBNM".split(";"))
         //   Inner loop over the qwerty-lines
      if((j=x.indexOf(s[i])+n)>=n)
         //    If the current qwerty-line contains the character
         //     Set `j` to the index of this character on that line + input `n`
        s[i]=x.charAt(j%x.length());}
         //     Replace the character at index `i`
         //     with the new character (at index `j` modulo length_of_qwerty_line)

158 bytes, at the cost of input-outputting the char[].

Retina, 49 bytes
"$&"+T`9o`dQW\ERTYUI\OPQASDFG\HJK\LAZXC\VBNMZ
0A`

Try it online! Takes input n and s on separate lines. Explanation:
"$&"+

Repeat n times.
T`9o`dQW\ERTYUI\OPQASDFG\HJK\LAZXC\VBNMZ

Shift all the characters one key to the right.
0A`

Delete n.

JavaScript (ES6), 101 99 bytes
Takes input in currying syntax (s)(n). Works with arrays of characters.
s=>n=>s.map(c=>(S='1QAZ2WSX3EDC4RFV5TGB6YHN7UJM8IK_9OL_0P')[(p=S.search(c)+n*4)%(-~'9986'[p%4]*4)])

Test cases

let f =

s=>n=>s.map(c=>(S='1QAZ2WSX3EDC4RFV5TGB6YHN7UJM8IK_9OL_0P')[(p=S.search(c)+n*4)%(-~'9986'[p%4]*4)])

console.log(JSON.stringify(f([..."0PLM"])(1)))    // 1QAZ
console.log(JSON.stringify(f([..."ZXCVB"])(2)))   // CVBNM
console.log(JSON.stringify(f([..."HELLO"])(3)))   // LYDDW
console.log(JSON.stringify(f([..."0PLM"])(11)))   // 1QSV
console.log(JSON.stringify(f([..."0PLM"])(2130))) // 0PHX

How?
We look for the position p of each character of the input within a string S where the keyboard rows are interleaved: the first 4 characters are '1QAZ' (first column of the keyboard), the next 4 characters are '2WSX' (second column of the keyboard) and so on. Unused positions are padded with underscores and the last ones are simply discarded.
col # | 0    | 1    | 2    | 3    | 4    | 5    | 6    | 7    | 8    | 9
------+------+------+------+------+------+------+------+------+------+---
row # | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 0123 | 01
------+------+------+------+------+------+------+------+------+------+---
char. | 1QAZ | 2WSX | 3EDC | 4RFV | 5TGB | 6YHN | 7UJM | 8IK_ | 9OL_ | 0P

This allows us to easily identify the row with p mod 4 and eliminates the need for explicit separators between the rows.
We advance by 4n positions, apply the correct modulo for this row (40, 40, 36 and 28 respectively) and pick the replacement character found at this new position in S.

Jelly, 18 bytes
ØQØDṭẋ€‘}Ẏ©iÐ€⁸+ị®

Try it online!

C,  152  149 bytes
Thanks to @gastropner for saving three bytes!
j,l;f(S,n){for(char*s=S,*k;*s;++s)for(k="1234567890\0QWERTYUIOP\0ASDFGHJKL\0ZXCVBNM\0";l=strlen(k);k+=l+1)for(j=l;j--;)k[j]-*s||putchar(k[(j+n)%l]);}

Try it online!
Unrolled:
j,l;
f(S,n)
{
    for (char*s=S, *k; *s; ++s)
        for (k="1234567890\0QWERTYUIOP\0ASDFGHJKL\0ZXCVBNM\0"; l=strlen(k); k+=l+1)
            for (j=l; j--;)
                k[j]-*s || putchar(k[(j+n)%l]);
}

Either I'm hallucinating, or the inner loop can be changed to for(j=l;j--;) but I don't know why without any other changed. Still, should get you to 149.

@gastropner Ah, yes, the search order doesn't matter, so it works. Thanks!

Red, 152 bytes
f: func[s n][foreach c s[foreach[t l]["1234567890"10"QWERTYUIOP"10"ASDFGHJKL"9"ZXCVBNM"7][if p: find t c[if(i:(index? p)+ n // l)= 0[i: l]prin t/(i)]]]]

Try it online!
Ungolfed:
f: func [s n][1
    foreach c s [
        foreach [t l] ["1234567890"10"QWERTYUIOP"10"ASDFGHJKL"9"ZXCVBNM"7][
            p: find t c
            if p [
                i: (index? p) + n // l
                if i = 0 [i: l]
                prin t/(i) ]]]]

Haskell, 99 bytes
f(s,n)=[dropWhile(/=c)(cycle r)!!n|c<-s,r<-words"1234567890 QWERTYUIOP ASDFGHJKL ZXCVBNM",elem c r]

Try it online!

You can use s#n= ... instead of f(s,n)= ... which is only an example notation used for the examples.

Perl 5, 94 + 1 (-p) = 95 bytes
$s=<>;for$i(1234567890,QWERTYUIOP,ASDFGHJKL,ZXCVBNM){eval"y/$i/".(substr$i,$s%length$i)."$i/"}

Try it online!

Damn, I didn't see your answer. They're basically the same, feel free to use my optimisations and I'll remove my answer. Let me know, if not, I'll just remove this comment :)

@DomHastings They are different enough. Please keep both. I like to see variations in approach. I learn from all of them...

Japt, 20 bytes
Running out the door to dinner so more golfing and an explanation to follow.
;£=D·i9òs)æøX)gV+UbX

Try it

Perl, 59 58 57 56 bytes
Includes + for -p
Give input on STDIN as 2 lines, first the string, then the repeat
(echo 0PLM; echo 2130) | perl -pe '$a="OPQWERTYUILASDF-MZXCVBNM0-90";eval"y/HI$a/J$a/;"x<>'

Wow, I can't believe you got 29 bytes off mine! I was pretty happy with it originally...

Ruby, 101 bytes
->s,n{n.times{s.tr! '1234567890QWERTYUIOPASDFGHJKLZXCVBNM','2345678901WERTYUIOPQSDFGHJKLAXCVBNMZ'};s}

Try it online!
I'm honestly a little disappointed that I couldn't do better with 'cleverer' methods. The closest I got was along the lines of
a=%w{1234567890 QWERTYUIOP ASDFGHJKL ZXCVBNM}
b=a.map{|r|r[1..-1]<<r[0]}*''
a*=''
n.times{s.tr! a,b}

for a net gain of 7 characters.

Perl 5, 85 bytes
84 bytes code + 1 for -p.
eval join"",map"y/$_/@{[/./&&$'.$&]}/;",(1234567890,QWERTYUIOP,ASDFGHJKL,ZXCVBNM)x<>

Try it online!

Clean, 144 119 bytes
import StdEnv

\n s=[l.[(i+n)rem(size l)]\\c<-s,l<-["1234567890","QWERTYUIOP","ASDFGHJKL","ZXCVBNM"],i<-[0..]&j<-:l|j==c]

Try it online!
Lambda function with the signature Int ![Char] -> [Char]