text:
Max power of 2 such that 2^m divides n. (The ruler sequence)
Input:
A positive integer N.
Challenge:
Suppose you have a list of integers n = 1, 2 ... N. Output a list of integers, where each number is the maximum power of 2, m, such that 2^m divides each number of n.

Test cases:
1
0

15
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0

100
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2

This is OEIS A007814.

Possible duplicate of this or this (although both ask for more than just the sequence).

Using the sandbox helps too :)

Also related

@StewieGriffin Is returning floats allowed? E.g.: [0.0, 1.0, 0.0, 2.0, 0.0, 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 2.0, 0.0, 1.0, 0.0]

@Mr.Xcoder no the question specifies integers. It doesn't matter what datatype the numbers have, as long as they're displayed as integers. (Relevant for MATLAB / Octave since they treat all numbers as doubles by default).

Can I print each integer on a new line?

@RobertoGraham I am almost 100% sure Stewie will say yes - most code-golf challenges have flexible IO unless there is good reason to restrict it, any easily parsable and consistent delimitation in your output should be fine.

@RobertoGraham yes, optional output format. :-)

Python 2, 46 bytes
Saved a couple of bytes thanks to nwellnhof.
lambda k:[len(bin(t+1&~t))-3for t in range(k)]

Try it online!

Python 2, 51 bytes
lambda k:[len(bin(t-~-(t&-~t)))-3for t in range(k)]

Try it online!
How?
The formula for a(k) is log2(k - (k & (k - 1))). That's quite fluffy, but fortunately it can be shortened significantly. In Python, floor(log2(N)) = len(bin(N)) - 3, because bin() appends 0b to the binary representation of an integer. As a side note, len(bin(N))-3 can be replaced by N.bit_length()-1, but that is not really beneficial for golfing purposes. That gives us the opportunity to get rid of the import math and the use of math.log. Another part that can be shortened is k & (k-1). Using more bitwise operations, we get k&~-k instead, and then we subtract this from the actual k. But that would make us iterate over the range [1, k], which would waste bytes because Python lacks inclusive ranges. In order to save a few bytes, we iterate over the integers in [0, k) instead and modify the formula, obtaining k+1-(k&-~k) = k-~-(k&-~k). However, than can be simplified further to k+1&~k (as  @nwellnhof pointed out).

FWIW t+1-(t&-~t) is the same length with less tadpoles.

@JonathanAllan Heh, I wonder how I missed that. I still like tildes and I will keep it that way though.

Or simply bin(t+1&~t).

Pyth, 6 bytes
m/Pd2S

Try it online: Demonstration
Explanation:
m/Pd2S
     S   range [1, 2, ..., input]
m        map each number to
 /  2       the count of two in
  Pd        its prime factorization

Mathematica, 29 bytes
#~IntegerExponent~2&~Array~#&

Try it online!

R, 60 59 55 40 bytes
n=1:scan();cat(log2(n-(bitwAnd(n,n-1))))

Reads from stdin, writes to stdout. Implements the formula referenced in Mr.
Xcoder's solution, which fortunately vectorizes nicely in R.
Try it online!

Haskell, 29 bytes
($l).take
l=0:do x<-l;[x+1,0]

Try it online!
Recursively generate the infinite list l.

JavaScript (ES6), 42 39 bytes
Saved 3 bytes thanks to @Shaggy
A straight-forward version using Math.clz32(). Returns a comma-delimited string.
f=n=>--n&&f(n)+[,31-Math.clz32(++n&-n)]

Test cases

f=n=>--n&&f(n)+[,31-Math.clz32(++n&-n)]

console.log(f(1))
console.log(f(15))
console.log(f(100))

Alternate version, 42 41 bytes
Saved 1 byte thanks to @Shaggy
f=n=>--n&&f(n)+[,(g=n=>n&1&&1+g(n/2))(n)]

How?
This is based on the recursive formula:
a(n) =
  0 if n is odd
  a(n / 2) + 1 if n is even

For golfing purposes, the function g is actually doing almost the opposite:
g(n) =
  g(n / 2) + 1 if the least significant bit of n is set
  0 if the least significant bit of n is clear

We do it that way because n has already been decremented when g is invoked, so it's off by 1. This generates floats, but testing the LSB rather than computing a modulo ensures that the decimal part is ignored.
The function f is just a wrapper that invokes g for all values from n - 1 to 1, appending the results in reverse order, and eventually appending a leading 0 when the recursion stops.
Test cases

f=n=>--n&&f(n)+[,(g=n=>n&1&&1+g(n/2))(n)]

console.log(f(1))
console.log(f(15))
console.log(f(100))

This should work for 41 bytes: f=n=>--n&&f(n)+[,(g=n=>n&1&&1+g(n/2))(n)] and applying the same trick to your alt. reduces it to 39 bytes: f=n=>--n&&f(n)+[,31-Math.clz32(++n&-n)].

C (gcc), 49 44 bytes
f(n){n-1&&f(n-1);printf("%.f ",log2(n&-n));}

Try it online!

x86 Machine Code, 10 bytes
0F BC C1
49
89 04 8A
75 F7
C3

The above bytes of machine code define a function that takes an array of length n as input, and then replaces the value at each index with the maximum power of 2, m, such that 2m divides each number of n. each number is the maximum power of 2, m, such that 2^m divides each number of n.
It follows the __fastcall register-based calling convention, passing the first parameter (the length of the array, n) in the ECX register and the second parameter (a pointer to the beginning of the array) in the EDX register. I posit that this is legal because, like C, arrays/lists are represented at the machine-code level as a pointer to the first element and a length.
As stipulated in the challenge, n is assumed to be a strictly positive integer.
Ungolfed assembly mnemonics:
                ; void RulerSequence(unsigned len, unsigned * pSequence);
                ;                                     ECX  = len
                ;                                     EDX  = pSequence
             Top:
0F BC C1        bsf   eax, ecx                      ; EAX  = log2(ECX)
49              dec   ecx                           ; ECX -= 1
89 04 8A        mov   DWORD PTR [edx+ecx*4], eax    ; pSequence[ECX] = EAX
75 F7           jnz   Top                           ; loop to 'Top' if ECX != 0
C3              ret

As you can see, the logic is embarrassingly simple. The only thing even slightly tricky is the use of the BSF instruction, which obtains the index of the least-significant set bit. This is the shortest and fastest way to compute log2(n).
Try it online!

Bonus alternate solution, also 10 bytes
                ; void RulerSequence_Alt(unsigned len, unsigned * pSequence);
                ;     ECX = len
                ;     EDX = pSequence
             Top:
0F BC C1        bsf   eax, ecx
89 44 8A FC     mov   DWORD PTR [edx+ecx*4-4], eax
E2 F7           loop  Top
C3              ret

Instead of separate DEC+JNZ instructions, we use the long-obsolete CISC-style LOOP instruction, which decrements ECX and loops to the specified label as long as ECX != 0. LOOP takes the same 2 bytes to encode as JNZ, so this saves us 1 byte from DEC. However, to compensate for the decrement being done after the array offset calculation, we need to add an additional subtraction to the indexing, which costs us an additional byte. So it's a wash.

Jelly, 5 bytes
RÆEḢ€

Try it online!
*Saved 1 byte thanks to miles!
Definitely not as short as the built-in answer with Order, multiplicity, valuation, but I think it's worth it posting.
How?

RÆEḢ€  - Full program.

R      - The range [1, input].
 ÆE    - Compute the array of exponents of the prime factorization, including 0's.
    €  - For €ach.
   Ḣ   - Head.
       - Implicitly output the result.

There's also an atom ÆE which gives the exponent of each prime factor, making RÆEḢ€

@miles Cool, thanks

Husk, 6 bytes
†#2†pḣ

Try it online!
How?
It's my first "non-trivial" attempt in Husk, so patient with me :-)

†#2†pḣ   - Full program.

     ḣ   - The range [1, input].
   †p    - Map with prime factorisation.
†#2      - Count the 2's in each.
         - Implicitly output.

Alternative, suggested by Erik the Outgolfer: m#2mpḣ.

Seems optimal to me, had m#2mpḣ.

Or mo#2pḣ. Two ms seems wasteful

@H.PWiz o is confusing though, you're probably lucky it works there...

@EriktheOutgolfer, not lucky. It's fairly standard function composition

C, 48 bytes
Using GCC's builtin to count trailing zeros:
f(v,n)int*v;{while(n--)v[n]=__builtin_ctz(n+1);}

Input in integer n, and output to the supplied array v (which must be at least n long).
Test program:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
    while (*++argv) {
        int n = atoi(*argv);
        if (n>0) {
            int *v = malloc(sizeof *v * n);
            if (!v) continue;
            f(v,n);
            printf("\n%d:\n", n);
            for (int i = 0;  i < n;  ++i)
                printf("%d ", v[i]);
            free(v);
            puts("");
        }
    }
}

+1. Using an array is better than my printf approach. Combined with my new log2 solution, you could get this to 40 bytes.

Was that link supposed to point at some code?  Or are we supposed to follow one of the links (which one?).  It would probably be simpler to show what you meant in a comment...

I have doubts about log2() - it needs to be passed a double, or to be declared, both of which cost more bytes than would be saved.

Yes, this only works because log2 is a gcc builtin. Also the predecrement is technically undefined behavior. But the general rule for code golf is that the language implementation counts, not the spec.

I forgot that log2 is builtin in GCC - that really helps!  Where's the predecrement you're referring to?  I have a postdecrement (n--).

I mean the predecrement in my TIO code.

Where's the code? tryitonline.github.io gitter.im/tryitonline talk.tryitonline.net @Try_It_Online Try It Online 1TryittLK3yAScCKavr5pg1eCZgpTdqYH direct link Linode doesn't mean much to GCC, and there's nothing else visible.

Let us continue this discussion in chat.

Jelly, 3 bytes
ọ€2

Try it online!

Java 8, 86 + 26 75 81 79 77 76 74 bytes
n->{for(int i=0;i<n;System.out.println(n.toString(++i&-i,2).length()-1));}

Try it online!

Apparently you aren't allowed to output floats/doubles and have to output integers, so Math.log(i&-i++)/Math.log(2) should be (int)(Math.log(i&-i++)/Math.log(2)) instead. One thing you can golf however: i<n+1 can be i<=n.

Octave, 42 37 bytes
5 bytes removed thanks to @StewieGriffin!
@(n)([~,y]=max(mod(x=1:n,2.^x')>0))-1

Try it online!
Explanation
Let n be the input. The code computes each number k in the range 1, ..., n modulo each number d in 1, 2, 4, ..., 2^n. This gives an n×n matrix, where k is the column index and each d corresponds to a row.
This matrix is compared for inequality with 0. As a result, nonzeros are transformed into 1, and zeros remain as 0.
For each column k, finding the (1-based) row index of the maximum value and subtracting 1 gives the solution. In other words, the number of initial zeros in each column is the desired m for each k.

37

@StewieGriffin Huh, I didn't know that could be done. Thanks!

Pari/GP, 29 bytes
n->[valuation(x,2)|x<-[1..n]]

Try it online!

05AB1E, 5 bytes
Patched a bug thanks to Emigna (Ý -> L).
LÒε2¢

Try it online!
How?

LÒε2¢   - Full program.

L       - The range [1, input].
 Ò      - Prime factors with duplicates.
  ε     - For εach.
   2¢   - Count the 2's.
        - Output (implicitly).

Alternative:
LεÒ2¢

Japt, 7 bytes
A port of Jakube's solution.
õ_k è¶2

Try it

Explanation
Implicit input of integer U.
õ_

Generate an array of integers from 1 to U and pass each through a function.
k

Get an array of the prime factors of the current element.
è¶2

Count (è) the number of elements that are strictly equal to (¶) 2.

õ_k +1 for cute faces.

Retina, 34 bytes
.+
$*
\B1
¶$`1
+`(1+)\1
$+0
%r`0\G

Try it online! Explanation:
.+
$*

Convert to unary.
\B1
¶$`1

Create a triangle.
+`(1+)\1
$+0

Start converting each row to base 2...
%r`0\G

...but instead of completing the conversion, just count the trailing zeros.

Perl 6, 27 17 15 bytes
-2 bytes thanks to Brad Gilbert b2gills
{(1..$_)».lsb}

Try it online!

{(1..$_)».lsb} / {(1..$_)>>.lsb}

@BradGilbertb2gills Thanks!

Haskell, 36 bytes
a 0=[0]
a n|q<-a$n-1=q++n:q
take<*>a

An adaption of my answer from a similar challenge.
Try it online!

Pyth, 9 bytes
msl-hd.&h

Verify the test cases.
If returning as floats was allowed, then 8 bytes:
ml-hd.&h

Explanation

msl-hd.&h  - Full program. Q means input.

m          - Map over the implicit range [0, Q) with a variable d.
 sl        - The integer part of logarithm base 2 of...
   -hd.&h  - ... The Logical OR between d and d + 1, subtracted from d + 1.
           - Output implicitly.

The formula for a(k) is log2(k - (k & (k - 1))), if we were to work with [1, Q]. By mapping over [0, Q) instead, we modify the formula accordingly, log2(k + 1 - (k & (k + 1)). This allows us to abuse implicit ranges at the end of the program.
Pyth, 6 bytes
/R2PMS

An alternative to Jakube's approach.

/R2PMS   - Full program. Q means input.

     S   - The range [1, Q].
   PM    - Get prime factors of each.
/R2      - Count the number of 2's.

Pyth, 10 bytes
mlec.Bd\1S

Try it here.

Pyke, 5 bytes
Port of Jakube's Pyth answer, and my 05AB1E answer.
SFP2/

Try it here!
How?
S     - The range [1, input]
 F    - For each.
  P   - Prime factors.
   2/ - Count the number of 2's.
      - Output implicitly.

J, 10 bytes
_{.@q:1+i.

Try it online!
Explanation
_{.@q:1+i.  Input: n
        i.  Range, [0, n)
      1+    Add 1
_   q:      Exponents of each prime in the factorization of each
 {.@        Head each (Get the exponent of 2)

Perl 50 + 2 bytes
perl -E'say+sprintf("%b",$_)=~s/.*1//r=~y===c for 1..shift'

50 bytes for the program proper, and 2 for the command line switch.
The largest m such that 2^m divides n is just the number of trailing 0s in the binary representation of n. We get the latter by removing everything up to the last 1 of the binary representation, and taking the length of that. y===c happens to do that (it replaces every character by itself, returning the number characters it replaced).


text:
Implement Anyfix Notation!
In prefix notation, the operator comes before the arguments, so you can kind of imagine that the operator calls next() which is recursively called. In infix notation, the operator goes between the arguments, so you can imagine it simply as a parse tree. In postfix notation, the operator comes after the arguments, so you can just imagine it as stack-based.
In anyfix notation, the operator can go anywhere*. If an operator shows up and there aren't enough arguments, then the operator waits until there are enough arguments. For this challenge, you are to implement a very basic anyfix evaluator. (Note that anyfix is a recreational language that I abandoned that you can play around with here or check out here)
You will need to support the following commands:
(Arity 1)

duplicate
negative

(Arity 2)

addition
multiplication
equality: returns 0 or 1.

You may choose to use any five non-whitespace symbols for these commands. For demonstrational purposes, I will use " as duplicate, × as multiplication, and + as addition.
For literals, you only need to support non-negative integers, but your interpreter must be able to contain all integers (within your language's (reasonable) integer range).
Let's take a look at an example: 10+5. The storage should behave as a stack, not a queue. So first, the stack starts at [], and the queued operator list starts at []. Then, the literal 10 is evaluated which makes the stack [10]. Next, the operator + is evaluated, which requires two arguments. However, there is only one argument on the stack, so the queued operator list becomes ['+']. Then, the literal 5 is evaluated which makes the stack [10, 5]. At this point, the operator '+' can be evaluated so it is, making the stack [15] and the queue [].
The final result should be [15] for + 10 5, 10 + 5, and 10 5 +.
Let's take a look at a harder example: 10+". The stack and queue start as [] and []. 10 is evaluated first which makes the stack [10]. Next, + is evaluated, which doesn't change the stack (because there are not enough arguments) and makes the queue ['+']. Then, " is evaluated. This can run immediately so it is, making the stack [10, 10]. + can now be evaluated so the stack becomes [20] and the queue []. The final result is [20].
What about order of operations?
Let's take a look at ×+"10 10. The stack and queue start both as []:

×: The stack is unchanged and the queue becomes ['×'].
+: The stack is unchanged and the queue becomes ['×', '+'].
": The stack is unchanged and the queue becomes ['×', '+', '"'].
10: The stack becomes [10]. Even though × should be the first operator to be evaluated since it appears first, " can run immediately and none of the operators before it can, so it is evaluated. The stack becomes [10, 10] and the queue ['×', '+']. × can now be evaluated, which makes the stack [100] and the queue ['+'].
10: The stack becomes [100, 10], which allows + to be evaluated. The stack becomes [110] and the queue [].

The final result is [110].
The commands used in these demonstrations are consistent with that of the anyfix language; however, the last example will not work due to a bug in my interpreter. (Disclaimer: Your submissions will not be used in the anyfix interpreter)
Challenge
Select a set of 5 non-whitespace non-digit characters and create an anyfix interpreter according to the specifications above. Your program can either output the singular array or the value contained by it; it is guaranteed that the stack of values will only contain a single value at the end of execution and that the queue of operators will be empty at the end of execution.
This is code-golf so the shortest code in bytes wins.
Test Cases
For these test cases, duplicate is ", negative is -, addition is +, multiplication is ×, and equality is =.
Input -> Output
1+2×3 -> 9
1"+"+ -> 4
2"××" -> 16
3"×+" -> 18
3"+×" -> 36
123"= -> 1 ("= always gives 1)
1+2=3 -> 1
1"=2+ -> 3
1-2-+ -> -3
-1-2+ -> 3 (hehe, the `-1` becomes `+1` at the `-` rather than making the `2` a `-1`)
+×"10 10 -> 200 (after the 10 is duplicated (duplication is delayed), 10 + 10 is performed and then 20 * 10, giving 200)

Rules

Standard Loopholes Apply
You may take the anyfix official interpreter and golf it if you would like. Expect to lose horribly.

Input will be given as a string and output as an array, a single integer, out the string representation of either. You may assume that the input will only contain spaces, digits, and the 5 characters you choose.
* not actually

Go anywhere*™.

What's the result of the equality operator? 0 and 1?

@JonathanAllan lol

@FelixPalmen Yes, sorry, I forgot to specify that. It's 0/1.

@geokavel whoops I removed subtraction

@JonathanAllan see above; I removed a command rip

What is the input format? Can I take a list of tokens? Can I take a string and require each number and operator be separated by a space? Ultimately, I'm trying to not special case multi-digit integer input.

@BrianJ Input is as a string. Tokenization is part of the challenge.

@HyperNeutrino May we assume that the input contains only digits, whitespace, and our 5 characters?

@BrianJ Input is as a string. Tokenization is part of the challenge.

@L3viathan Yes you may, thanks.

@RickHitchcock Sure.

You probably should include ×+"10 10 in the test cases, or any other examples that are 1) using a whitespace and 2) delaying the use of the duplicate operator (two things that I missed entirely).

@Arnauld Yup, I'll include that, thanks.

JavaScript (ES6), 204 203 200 bytes
Returns an integer.
e=>e.replace(/\d+|\S/g,v=>{for((1/v?s:v>','?u:b)[U='unshift'](v);!!u[0]/s[0]?s[U](u.pop()>'c'?s[0]:-S()):!!b[0]/s[1]?s[U](+eval(S(o=b.pop())+(o<'$'?'==':o)+S())):0;);},s=[],u=[],b=[],S=_=>s.shift())|s

Characters used:

+: addition
*: multiplication
#: equality
d: duplicate
-: negative

Test cases

let f =

e=>e.replace(/\d+|\S/g,v=>{for((1/v?s:v>','?u:b)[U='unshift'](v);!!u[0]/s[0]?s[U](u.pop()>'c'?s[0]:-S()):!!b[0]/s[1]?s[U](+eval(S(o=b.pop())+(o<'$'?'==':o)+S())):0;);},s=[],u=[],b=[],S=_=>s.shift())|s

;[ '10+5', '10+d', '*+d10 10', '1+2*3', '1d+d+', '2d**d', '3d*+d', '3d+*d', '123d#', '1+2#3', '1d#2+', '1-2-+', '-1-2+' ]
.forEach(e => console.log(e, '-->', f(e)))

Formatted and commented
e => e.replace(                     // given an expression e, for each value v matching
  /\d+|\S/g, v => {                 // a group of digits or any other non-whitespace char.
    for(                            //   this loop processes as many operators as possible
      (                             //   insert v at the beginning of the relevant stack:
        1 / v ? s : v > ',' ? u : b //     either value, unary operator or binary operator
      )[U = 'unshift'](v);          //     (s[], u[] or b[] respectively)
      !!u[0] / s[0] ?               //   if there's at least 1 value and 1 unary operator:
        s[U](                       //     unshift into s[]:
          u.pop() > 'c' ?           //       for the duplicate operator:
            s[0]                    //         a copy of the last value
          :                         //       else, for the negative operator:
            -S()                    //         the opposite of the last value
        ) :                         //     end of unshift()
      !!b[0] / s[1] ?               //   if there's at least 2 values and 1 binary operator:
        s[U](                       //     unshift into s[]:
          +eval(                    //       the result of the following expression:
            S(o = b.pop()) +        //         the last value, followed by the
            (o < '$' ? '==' : o) +  //         binary operator o with '#' replaced by '=='
            S()                     //         followed by the penultimate value
          )                         //       end of eval()
        ) : 0;                      //     end of unshift()
    );                              //   end of for()
  },                                // end of replace() callback
  s = [],                           // initialize the value stack s[]
  u = [],                           // initialize the unary operator stack u[]
  b = [],                           // initialize the binary operator stack b[]
  S = _ => s.shift()                // S = helper function to shift from s[]
) | s                               // return the final result

Don't think this works for -1+-2.  Returns 3 instead of -3.

@RickHitchcock My understanding is that the 2nd - must be applied to -1 immediately.

I would think the 2nd - would go with the 2 since it comes after another operator.  Perhaps @HyperNeutrino can clarify.  The negative operator may be ambiguous in some situations.

JavaScript (ES6), 162 152 143 150 bytes
(s,N=s.replace(/(-?\d+)-|-(-)/g,'- $1 ').match(/(- ?)*?\d+|R/g))=>+eval(`R=${N[0]>'9'?N[1]:N[0]},${s.match(/[+*=]/g).map((o,i)=>'R=R'+o+'='+N[i+1])}`)

Slightly ungolfed:
(s,
 N=s.replace(/(-?\d+)-|-(-)/g,'- $1 ').      //change postfix negatives to prefix,
                                             //and change "--" to "- - "
     match(/(- ?)*?\d+|R/g)                  //grab numbers and duplicates
)=>+eval(`R=${N[0] > '9' ?  N[1] : N[0]},    //handle a delayed duplicate
          ${s.match(/[+*=]/g).               //grab the operators
              map((o,i)=>'R=R'+o+'='+N[i+1]) //create a comma-separated list of assignments
           }
         `)

Explanation
I'm using * for multiplication and R for duplicate.  The other operators are the same as in the question.
N becomes the array of the numbers (including the duplicates).
The replace handles the case where the negative sign comes after the number.  For example, it will change 1- to - 1  and -1- to - -1 .
Within the eval, s.match creates the array of binary operators.  Note that this will always have one fewer elements than N.
The result of the function is the eval of the mapping of the numbers and operators.
Here is what is evaled for each of the test cases:
0+2*3        R=0,R=R+=2,R=R*=3        = 6
1+2*3        R=1,R=R+=2,R=R*=3        = 9
1R+R+        R=1,R=R+=R,R=R+=R        = 4
2R**R        R=2,R=R*=R,R=R*=R        = 16
3R*+R        R=3,R=R*=R,R=R+=R        = 18
3R+*R        R=3,R=R+=R,R=R*=R        = 36
123R=        R=123,R=R==R             = 1
1+2=3        R=1,R=R+=2,R=R==3        = 1
1R=2+        R=1,R=R==R,R=R+=2        = 3
1-2-+        R=- 1,R=R+=- 2           = -3
-1-2+        R=1,R=R+=2               = 3
*+R10 10     R=10,R=R*=10,R=R+=10     = 110
+*R10 10     R=10,R=R+=10,R=R*=10     = 200
-1+--2       R=-1,R=R+=- -2           = 1
-1+-2        R=-1,R=R+=-2             = -3

The comma operator in a JavaScript expression returns the result of its last expression, so the map automatically returns a usable expression.
The + sign is needed before the eval to change true to 1 and false to 0.
Using R as both the variable and the duplicate operator greatly simplifies the map's sub-expressions.
Test cases:

let f=

(s,N=s.replace(/(-?\d+)-|-(-)/g,'- $1 ').match(/(- ?)*?\d+|R/g))=>+eval(`R=${N[0]>'9'?N[1]:N[0]},${s.match(/[+*=]/g).map((o,i)=>'R=R'+o+'='+N[i+1])}`)

console.log(f('1+2*3'))    // 9
console.log(f('1R+R+'))    // 4
console.log(f('2R**R'))    // 16
console.log(f('3R*+R'))    // 18
console.log(f('3R+*R'))    // 36
console.log(f('123R='))    // 1
console.log(f('1+2=3'))    // 1
console.log(f('1R=2+'))    // 3
console.log(f('1-2-+'))    // -3
console.log(f('-1-2+'))    // 3
console.log(f('*+R10 10')) //110
console.log(f('+*R10 10')) //200
console.log(f('-1+--2'));  // 1
console.log(f('-1+-2'));  // -3

I don't think the replace works as intended. This returns 3 for -1+--2 and I think 1 would be correct (the 1 changes sign three times before there's a second argument for the + available, resulting in -1 + 2).

Great catch, @FelixPalmen.  Now fixed.

JavaScript, 321 311 bytes
_="f=a=>(a.replace(/\\d+|./g,mq!~(b='+*=\"- '.indexOf(a))|b>2j3j4j5&&o+aw1/y?(y*=-1wcz:1/y?oywcz:hz,rql.map(z=>m(lki,1)[0],i)),hq1/s[1]?sk0,2,+eval(`y${a=='='?a+a:a}s[1]`)):cz,cqlki,0,a),s=[],l=[],e='splice'),s)z(a,i)ys[0]w)^r``:q=z=>os.unshift(k[e](j?b-";for(i of"jkoqwyz")with(_.split(i))_=join(pop());eval(_)

Try it online!
The five characters are the same as in the question, except * is for multiplication.
The script is compressed using RegPack. The original script is stored in the variable _ after evaluation.

Don't think this works for -1+-2.  Returns 3 instead of -3.

@RickHitchcock. Why do you believe it should return -3 instead of 3?

I may be misunderstanding the negative operator.  Generally, -1 + -2 is -3, but should it be parsed as --1 + 2 instead?

@RickHitchcock. I am pretty sure the result is 3. Before 2 even come on the stack, the second - is evaluated, and therefore we have 1 2 + which is indeed 3. Ah, and probably you have to edit your answer too.

You're probably right.  You and Arnauld get the same answer, and I've asked the OP for clarification.  Would vote you up again if I could.

6502 machine code (C64), 697 bytes
00 C0 A2 00 86 29 86 26 86 27 86 28 86 4B 86 4C 86 CC 20 E4 FF F0 FB C9 0D F0
10 C9 20 30 F3 A6 27 9D B7 C2 20 D2 FF E6 27 D0 E7 C6 CC A9 20 20 1C EA A9 0D
20 D2 FF 20 95 C0 20 09 C1 20 95 C0 A6 26 E4 27 F0 4E BD B7 C2 E6 26 C9 20 F0
E8 C9 2D D0 09 A6 4C A9 01 9D B7 C3 D0 32 C9 22 D0 09 A6 4C A9 02 9D B7 C3 D0
25 C9 2B D0 09 A6 4C A9 81 9D B7 C3 D0 18 C9 2A D0 09 A6 4C A9 82 9D B7 C3 D0
0B C9 3D D0 0D A6 4C A9 83 9D B7 C3 E6 28 E6 4C D0 A3 4C 8A C2 A6 29 F0 6F A4
28 F0 6B CA F0 4B C6 28 A6 4B E6 4B BD B7 C3 F0 F5 30 14 AA CA D0 0B 20 7B C2
20 E1 C1 20 4D C2 D0 D9 20 5C C2 D0 D4 29 0F AA CA D0 0B 20 6D C2 20 08 C2 20
4D C2 D0 C3 CA D0 0B 20 6D C2 20 16 C2 20 4D C2 D0 B5 20 6D C2 20 F4 C1 20 4D
C2 D0 AA A4 4B B9 B7 C3 F0 02 10 AC C8 C4 4C F0 0F B9 B7 C3 F0 F6 30 F4 AA A9
00 99 B7 C3 F0 A6 60 A0 00 A6 26 E4 27 F0 15 BD B7 C2 C9 30 30 0E C9 3A 10 0A
E6 26 99 37 C4 C8 C0 05 D0 E5 C0 00 F0 08 A9 00 99 37 C4 20 39 C2 60 A2 FF E8
BD 37 C4 D0 FA A0 06 88 CA 30 0A BD 37 C4 29 0F 99 37 C4 10 F2 A9 00 99 37 C4
88 10 F8 A9 00 8D 3D C4 8D 3E C4 A2 10 A0 7B 18 B9 BD C3 90 02 09 10 4A 99 BD
C3 C8 10 F2 6E 3E C4 6E 3D C4 CA D0 01 60 A0 04 B9 38 C4 C9 08 30 05 E9 03 99
38 C4 88 10 F1 30 D2 A2 06 A9 00 9D 36 C4 CA D0 FA A2 10 A0 04 B9 38 C4 C9 05
30 05 69 02 99 38 C4 88 10 F1 A0 04 0E 3D C4 2E 3E C4 B9 38 C4 2A C9 10 29 0F
99 38 C4 88 10 F2 CA D0 D6 C0 05 F0 06 C8 B9 37 C4 F0 F6 09 30 9D 37 C4 E8 C8
C0 06 F0 05 B9 37 C4 90 F0 A9 00 9D 37 C4 60 A9 FF 45 FC 85 9F A9 FF 45 FB 85
9E E6 9E D0 02 E6 9F 60 A2 00 86 9F A5 FB C5 FD D0 07 A5 FC C5 FE D0 01 E8 86
9E 60 A5 FB 18 65 FD 85 9E A5 FC 65 FE 85 9F 60 A9 00 85 9E 85 9F A2 10 46 FC
66 FB 90 0D A5 FD 18 65 9E 85 9E A5 FE 65 9F 85 9F 06 FD 26 FE CA 10 E6 60 20
33 C1 A6 29 AD 3D C4 9D 3F C4 AD 3E C4 9D 3F C5 E6 29 60 A6 29 A5 9E 9D 3F C4
A5 9F 9D 3F C5 E6 29 60 A6 29 BD 3E C4 9D 3F C4 BD 3E C5 9D 3F C5 E6 29 60 C6
29 A6 29 BD 3F C4 85 FD BD 3F C5 85 FE C6 29 A6 29 BD 3F C4 85 FB BD 3F C5 85
FC 60 A6 29 BD 3E C5 10 13 20 7B C2 20 E1 C1 20 4D C2 A9 2D 20 D2 FF A6 29 BD
3E C5 8D 3E C4 BD 3E C4 8D 3D C4 20 8B C1 A9 37 A0 C4 4C 1E AB

Online demo
Usage sys49152, then enter the anyfix expression and press return.

close to no error checking, so expect funny outputs on invalid expressions.
the symbol for multiplication is *, all others as suggested.
maximum input length is 256 characters, there can be no more than 127 operators queued.
The input routine doesn't handle control characters, so don't mistype ;)
integers are 16bit signed, overflow will silently wrap around.
byte count is a bit large because this CPU doesn't even know multiplication and the C64 OS / ROM doesn't give you any integer arithmetics or conversions to/from decimal strings.

Here's the readable ca65-style assembler source code.

Haskell, 251 bytes
(#([],[]))
(x:r)#(o,n)|x>'9'=r#h(o++[x],n)|[(a,t)]<-lex$x:r=t#h(o,read a:n)
_#(o,n:_)=n
h=e.e
e(o:s,n:m:r)|o>'N'=e(s,g[o]n m:r)
e(o:s,n:r)|o=='D'=e(s,n:n:r)|o=='N'=e(s,-n:r)
e(o:s,n)|(p,m)<-e(s,n)=(o:p,m)
e t=t
g"a"=(+)
g"m"=(*)
g"q"=(((0^).abs).).(-)

Try it online! Uses the following characters: a for addition, m for multiplication, q for equality, D for duplicate and N for negation. (I wanted to use e for equality, but ran into the problem that lex parses 2e3 as a number.) Example usage: (#([],[])) "2a3 4m" yields 20.

VB.NET (.NET 4.5) 615 576 bytes
-39 bytes thanks to Felix Palmen by changing \r\n to \n
Requires Imports System.Collections.Generic (included in byte count)
Dim s=New Stack(Of Long),q=New List(Of String),i=Nothing,t=0,c=0
Function A(n)
For Each c In n
If Long.TryParse(c,t)Then
i=i &"0"+t
Else
If c<>" "Then q.Add(c)
If i<>A Then s.Push(i)
i=A
End If
If i=A Then E
Next
If i<>A Then s.Push(i)
E
A=s
End Function
Sub E()
c=s.Count
If c=0Then Exit Sub
For Each op In q
If op="-"Or op="d"Or c>1Then
Select Case op
Case"*"
s.Push(s.Pop*s.Pop)
Case"+"
s.Push(s.Pop+s.Pop)
Case"="
s.Push(-(s.Pop=s.Pop))
Case"-"
s.Push(-s.Pop)
Case"d"
s.Push(s.Peek)
End Select
q.Remove(op)
E
Exit Sub
End If
Next
End Sub

The entry point is Function A, which takes a string as input and returns a Stack(Of Long).
Symbols:

Addition - +
Multiplication - *
Equality - =
Negation - -
Duplication - d

Overview:
Function A takes the input and tokenizes it. It uses a Long? to do a running total for multi-digit integers, which Nothing signifying we are not currently reading an integer.
Subroutine E takes the stack of integers and queue of operators, and evaluates the anyfix notation. It calls itself recursively until there are no actions left.
I declare global params all at once to save bytes on both declaration and parameter passing.
The return value from A is set by assigning a value to the matching variable A.
VB True is equivalent to -1, so that operation has to negate the result to get the correct value.
Try it online!

suggest to add Try it online!

btw, with the Imports, I get a byte count of only 576 -- could you have miscounted?

@FelixPalmen I counted with \r\n instead of \n, so that's where the discrepancy is.

@FelixPalmen Added TIO, thanks for reminding me! :) (Oh, I didn't realize you made it for this post already)

source: Stack Exchange

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

sort: votes


text:
Totalling Troublesome T's
Given a "T" shape on an x * y number grid, with length W on the top bar and H on the stem of the T, with the bottom of the T on the square numbered n: calculate the total of all of the numbers in the T shape. W must be an odd number and all must be positive integers.
Here are some examples of valid T's on a 9*9 grid:

Looking at the T where n=32, W=3 & H=4, you can see that the total is:4 + 5 + 6 + 14 + 23 + 32 = 84.
The Challenge
Your challenge is to create a program which, when given five positive integers, x, y, W, H and n, output the total of the T with those values (W must be odd, given an even number the program can output anything or even crash). The numbers may be inputted in any reasonable format. If the T does not fit on the given grid, then any output is acceptable.
Example Code (Python 3.6.2)
x = int(input())
y = int(input())
W = int(input())
H = int(input())
n = int(input())

total = 0

#"Stem" of the T
for i in range(H - 1):
    total += n - (x * i) #Decrease increment by length of row each time

#Top of the T
for i in range(-W//2 + 1, W//2 + 1): #Iterate over the width offset so that the center is zero
    total += (n - (x * (H - 1))) + i #Add the top squares on the T, one less to the left and one more to the right

print(total)

As with most challenges here this is code-golf, so the answer with the shortest code in bytes wins.

Isn't y redundant information?

@JonathanAllan I'm presuming it needn't be a square grid in which case y would not be redundant. x & y together would define the grid, n defines the bottom of the T shape, and W & H together define the T shape's size.

Better quality image

Oh, someone already edited. nvm...

@EngineerToast we are told n and x and told "If the T does not fit on the given grid, then any output is acceptable." so y may be inferred.

@JonathanAllan How do you know if T fits in the grid if you don't know what the grid is? Ah, I see now. You're saying we can just assume it fits because any output is allowed if it doesn't fit so outputting what the correct answer would be if it did fit is a valid output. Gotchya.

Is this challenge just asking to golf the formula (2n-(h-1)y)h/2+(n-(h-1)y)(w-1)?

There could be many ways to approach the challenge, there's probably a builtin for it in Mathematical.

In the example, is H equal to 3 or 4? That is, does it include the top bar?

H is equal to 4

Can you add some test cases, please?

Jelly, 10 bytes
A construction technique, which ends up much like Luis Mendo's MATL answer
Ḷ×ạ⁵µṪ×⁶+S

A full program taking H, x, n, W in that order (y may be appended if one so wishes).
Try it online!
How?
Ḷ×ạ⁵µṪ×⁶+S - Main link: H, x
Ḷ          - lowered range                         [0,1,2,...,H-2,H-1]
 ×         - multiply (vectorises)                 [0,x,2x,...,(H-2)x,(H-1)x]
   ⁵       - program's 5th argument (3rd input)    n
  ạ        - absolute difference (vectorises)      [n,n-x,n-2x,...,n-(H-2)x,n-(H-1)x]
           -  (note: for an in-range T n>(H-1)x)   (cells of the stem)
    µ      - monadic chain separation (call this stem)
     Ṫ     - tail (pop from AND modify stem)       n-(H-1)x
           -                                       (cell at intersection of stem and top)
       ⁶   - program's 6th argument (4th input)    W
      ×    - multiply                              Wn-W(H-1)x
           -                                       (total value of the top)
         S - sum (the modified stem)               n+n-x+n-2x+...+n-(H-2)x
           -                                       (total value of the stem w/o top cell)
        +  - add (add top to the stem w.o top cell)

JavaScript (ES6), 32 30 bytes
Saved 2 bytes thanks to @Shaggy
(w,h,x)=>Q=n=>--h?n+Q(n-x):n*w

Takes input in a curried format: f(W,H,x,y)(n)

let f =
(w,h,x)=>Q=n=>--h?n+Q(n-x):n*w;

console.log(
  f(3, 4, 9, 9)(32)
);

How?
First we note that the sum of the T starting at n with height H can be broken down into two sums:

n
The sum of the T starting one row higher with height H - 1

By repeatedly adding n to the total, moving one row up, and subtracting 1 from H until it reaches 1, we end up summing the vertical stem of the T. Moving one row up is accomplished by subtracting x from n, since it can be observed that the difference between any cell and the one above is x.
When H reaches 1, we now have only the crossbar of width W left to sum. At this point n represents the center of the crossbar. We could sum the crossbar recursively as we did with the stem, but instead we take advantage of a fairly simple formula:
sum(n - a : n + a) = (n - a) + (n - (a-1)) + ... + n + ... + (n + (a-1)) + (n + a)
                   = (n - a) + (n + a) + (n - (a-1)) + (n + (a-1)) + ... + n
                   = 2n + 2n + ... + n
                   = n * (2a + 1)

In this case, our a is (W - 1) / 2, which makes
n * (2a + 1) = n * (((W - 1) / 2) * 2 + 1)
             = n * ((W - 1) + 1)
             = n * W

which is the sum of the crossbar.

Seeing as you don't use y you just go with (x,w,h)=>Q=n=> and then call it using f(x,w,h)(n,y)? Seem to remember this coming up on Meta recently but can't remember the outcome.

@Shaggy Thank you, found a better format for that trick :-)

C# (Visual C# Compiler), 64 52 bytes
(x,y,W,H,n)=>{for(y=0;H-->1;n-=x)y+=n;return y+W*n;}

Try it online!
The non-recursive answer did indeed turn out significantly shorter. Gross misuse of for loops and the fact that y is officially a mandatory input even though it's not used.

Should return y+3*n; be return y+W*n? Otherwise you wouldn't need to pass in W.

@Ayb4btu ... You know, I've actually had to fix that mistake multiple times along the way. I don't know how it keeps getting back in.

Python 3, 38 bytes
lambda x,W,H,n:~-H*(x*(1-H/2-W)+n)+W*n

Try it online!
-4 bytes thanks to Jonathan Allan
-4 bytes thanks to Kevin Cruijssen/Ayb4btu

EDIT: four bytes ...Save two bytes with our old friend tilde lambda x,W,H,n:n*H-x*H*~-H/2+~-W*(n-H*x+x) (FYI the TIO link has too many args in the call to f)

@JonathanAllan Oh whoops thanks. And yay thanks! :D

@LuisMendo Wait whoops I fixed that but forgot to update the link and then un-fixed it when golfing. Thanks!

lambda x,W,H,n:~-H*(x*(1-H/2-W)+n)+W*n is 4 bytes shorter. (Credit goes to @Ayb4btu's C# .NET answer.)

@KevinCruijssen Oh cool, thanks!

MATL, 12 bytes
:q*-t0)iq*hs

Inputs are: H, x, n, W.
Try it online!
Explanation
:     % Implicit input: H. Push [1, 2, ..., H]
q     % Subtract 1. Gives [0, 1, ..., H-1]
*     % Implicit input: x. Multiply. Gives [0, x, ..., x*(H-1)]
-     % Implicit input: n. Subtract. Gives [n-0, n-x, ..., n-x*(H-1)]. This is
      % the stem, bottom to top
t     % Duplicate
0)    % Get last element, that is, n-x*(H-1). This is the center top of the "T"
i     % Input: W
q     % Subtract 1
*     % Multiply. Gives n-x*(H-1)*(w-1). This is the sum of the vertical bar
      % excluding its center, which is already accounted for in the stem
h     % Concatenate into a row vector
s     % Sum of vector. Implicit display

Jelly,  18 16  15 bytes
-1 byte thanks to Erik the Outgolfer (use of chain separator)
S’×⁵_ðc2Ḣ+⁸’P¤×

A full program taking [H,W], x, n in that order (you can add y to the arguments if you like, it's not used).
Try it online!
How?
The total is:

n multiplied by the number of squares used in the T (which is W+H-1)
minus the width of the grid, x, times the triangle number of the
height (1+2+3+...+h) to account for the lack as we go up the stem
minus the width of the grid, x, times one less that the height (H-1)
times one less that the width (W-1) to account for the lack at the
top of the T, excluding the lack we already accounted for at the top of the stem.

That is:
(W + H - 1) * n - ((H - 1) * (W - 1) + Triangle(H)) * x

The triangle number of H is its binomial with 2 A.K.A. H-choose-2.
c2Ḣ+⁸’P¤× - Link 1: the x * (Triangle(H) + (H-1)*(W-1)): [H,W]; x
S’×⁵_ðc2Ḣ+⁸’P¤× - Main link: [H,W], x
S               - sum                                    H+W
 ’              - decrement                              H+W-1
   ⁵            - program's fifth argument (3rd input)   n
  ×             - multiply                               (H+W-1)*n
     ð          - dyadic chain separation
      c2        - choose-2 (vectorises)                  [Triangle(H), Triangle(W)]
        Ḣ       - head                                   Triangle(H)
             ¤  - nilad followed by link(s) as a nilad:
           ⁸    -    chain's left argument               [H,W]
           ’    -    decrement (vectorises)              [H-1,W-1]
            P   -    product                             (H-1)*(W-1)
         +      - add                                    (H-1)*(W-1)+Triangle(H)
              × - multiply (by chain's right arg, x)     ((H-1)*(W-1)+Triangle(H))*x
    _           - subtract                               (H+W-1)*n-((H-1)*(W-1)+Triangle(H))*x

Perl 5, 52 bytes
($x,$y,$w,$h,$n)=<>;say$h*($n+$x*(.5-$h/2-$w))+$w*$n

Try it online!

Do yoy need to take y as input, seeing as you're not using it?

Not really, but it was part of the input spec, so I included it.

Python 3, 38 bytes
lambda x,W,H,n:~-H*(n-x*(W-1+H/2))+n*W

Try it online!
HyperNeutrino's arithmetic expression with improved grouping.

C# (.NET Core), 49 37 bytes
(x,y,W,H,n)=>~-H*(x*(1-H/2d-W)+n)+W*n

Try it online!
A direct formula avoiding the need for looping or recursion. Unfortunately I had to use 2d otherwise it was going to do integer division and truncate the fractional component. The y param is completely redundant and could be removed.
Explanation
(n-x*(H-1))*W             // Calculates the Top of the T

(n-x*(H-1)) gets the cell index by subtracting from n the number of rows to go up multiplied by the grid width. Multiplying this by W gets the sum of the top bar of the T.
n*(H-1)-x*(H-2)*(H-1)/2   // Calculates the Stem of the T

I got this by using mathematical induction by trying to calculate the sum of 1, 10, 19, 28 where n=28, H=4, x=9. Which can be written as:
28 + (28-9) + (28-9-9) + (28-9-9-9)
28-9*0 + 28-9*1 + 28-9*2 + 28-9*3
28*4 -9*(0+1+2+3)
n*H -x*(1+2+3)
n*H -x*(3*(3+1)/2)
n*H -x*((H-1)*((H-1)+1)/2)
n*H -x*((H-1)*H/2)

but because we don't want to include the top cell of the stem (included in the formula for the Top of the T), H needs to be H-1. Making the formula
n*(H-1)-x*((H-2)*(H-1)/2)

Combining these two formulas gives
(n-x*(H-1))*W + n*(H-1)-x*((H-2)*(H-1)/2)

and simplifying it gives the formula used for the answer (though how it is rearranged can change how it looks).
Acknowledgements
Saved 12 bytes thanks to Kevin Cruijssen. Though I'm not sure if the ; should be included or not.

You can golf some things: =>{return ...} can be =>...; and (H-1) can be ~-H. So in total: (x,y,W,H,n)=>~-H*(x*(1-H/2d-W)+n)+W*n - 37 bytes

@KevinCruijssen Thanks, that's a huge saving, I'm not sure how I missed them...

Pyth, 23 bytes
+-*KEQ**JEQctQ2*tE-K*Jt

Try it here! (note the order of the inputs)
How?

+-*KEQ**JEQctQ2*tE-K*Jt    Full program. Q is input, E is evaluated input (reads a new line)

  *KEQ                     The second input * the first input.
       *JEQ                The third input * the first input.
           ctQ2            Float division of the the first input decremented by 1, by 2.
      *                    Product.
 -                         Difference.
                tE         The fourth input.
                    *Jt    The product of the third input and the first input decremented by 1...
                 -K        ... Subtracted from the second input
               *           Product.
+                          Sum.
                           Output implicitly.

Japt, 14 bytes
I tried a few different solutions based on ETH's observations but the shortest I've come up with (so far) is a straight port.
Takes input in the order n,H,W,x.
´V©ßXnU)+UªU*W

Try it

Java 8, 35 bytes
(x,W,H,n)->~-H*(x*(1-H/2d-W)+n)+W*n

Port of @Ayb4btu .Net C# answer, after I golfed it a bit.
Try it here.

If y is a mandatory input-parameter, it will be 37 bytes instead (Try it here):
(x,y,W,H,n)->~-H*(x*(1-H/2d-W)+n)+W*n

If outputting a double isn't allowed, it will be 40 bytes instead (Try it here):
(x,W,H,n)->~-H*(x*(int)(1-H/2d-W)+n)+W*n

If having a function instead of a full program isn't allowed, it will be 160 bytes instead (Try it here):
interface M{static void main(String[]a){Integer W=new Integer(a[2]),H=W.decode(a[3]),n=W.decode(a[4]);System.out.print(~-H*(W.decode(a[0])*(1-H/2d-W)+n)+W*n);}}

Java (OpenJDK 8), 100 99 96 91 bytes
x->W->H->n->{int t=n,i=0,j=-W/2;for(;++i<H;t+=n-x*i);for(;j<W/2;t+=n-x*~-H+j++);return-~t;}

Try it online!

When using two parameters currying is shorter; when using three parameters currying is the same length; but when using four or more parameters currying is actually longer. So you can replace x->W->H->n-> with (x,W,H,n)->, like this.

Also, you can save some additional bytes by changing t+=(n-x*(H-1))+j++ to t+=n-x*~-H+j++ so you don't need the four parenthesis. And return t+1; can be return-~t; so you don't need the space. Here is the relevant codegolfing tip post for using -~ and ~- with more information.

@KevinCruijssen Thank you, I'm just using currying because I don't know if the bytes of the functional interface are counted

QBIC, 32 bytes
[0,:-1|i=:-(a*:)┘g=g+i}?i*:+g-i

This takes parameters in the order h, n, x, w, and y is ignored.
Explanation
Each time a variable is read from the cmd line in QBIC, using the : command, it is assigned a letter (a-z). For clarity, I will use h, n, x, w in the explanation instead of the b,c,d,e they would be assigned (a gets taken by the FOR-loop).
First, we want to know the total of the stem
[0,h-1|     FOR a = 0 to the height - 1
  i=n-(a*x)     helper i holds an increment value: this is n, minus the
                grid-width once for every row we go up.
  g=g+i         helper g is incremented by i for each row
  }         NEXT
  ?         PRINT
   i*w          the center on the top bar times the width (ie the average)
   -i           corrected for that ione i we already counted in the stem
   +g           plus the stem itself

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


text:
Count edits accounting for grace period
When you edit a post on SE, any further edits within a 5-minute grace period are merged into it. Given a list of times you edit a post, count the edits not in a grace period.
Say you edit at minutes [0,3,4,7,9,10,11,12]. This results in 3 edits at times [0,7,12], with the rest happening in their grace periods.
0:  [3,4]
7:  [9,10,11]
12: []

The first edit is at minute 0. The edits at minutes 3 and 4 are within its 5-minute grace period, and so don't count.
The second edit is at minute 7. The edits at minutes 9, 10, 11 are within its grace period.
The third edit at minute 12 is just past the edge of the 5-minute grace period starting at minute 7.

So, the output is 3.
The list of times in minutes will be an list of increasing integers. The first number will always be 0 for the initial posting, which we count as an edit.
Test cases:
[0]
[0,3,5,7]
[0,3,4,7,9,10,11,12]
[0,30,120]
[0,4,8,12,16]
[0,4,8,12,16,20]
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
[0,5,10,15,20]
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
[0,1,4,5,9,11,12,14,16,18,23,24,26,28,29,30]

Outputs:
1
2
3
3
3
3
4
5
5
6

For ease of copying, here are the inputs, outputs, and input/output pairs:
[[0], [0, 3, 5, 7], [0, 3, 4, 7, 9, 10, 11, 12], [0, 30, 120], [0, 4, 8, 12, 16], [0, 4, 8, 12, 16, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [0, 5, 10, 15, 20], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [0, 1, 4, 5, 9, 11, 12, 14, 16, 18, 23, 24, 26, 28, 29, 30]]
[1, 2, 3, 3, 3, 3, 4, 5, 5, 6]
[([0], 1), ([0, 3, 5, 7], 2), ([0, 3, 4, 7, 9, 10, 11, 12], 3), ([0, 30, 120], 3), ([0, 4, 8, 12, 16], 3), ([0, 4, 8, 12, 16, 20], 3), ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], 4), ([0, 5, 10, 15, 20], 5), ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 5), ([0, 1, 4, 5, 9, 11, 12, 14, 16, 18, 23, 24, 26, 28, 29, 30], 6)]

Leaderboard:

var QUESTION_ID=141949,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/141949/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Although it's really annoying if your edit doesn't make the grace period, because then you have to use your new grace period to make it look as if you meant to edit it that way all along...

JavaScript, 36 bytes
f=$=>$>f&&1+f($.filter(b=>b-$[0]>4))

Try it online!
How it works
In each recursive call we delete all elements from the array which are more than 4 minutes distant from the first element.
There is a little trick with variable name $. The check $>f firstly converts the array to a string and then compare it to the string representation of the function f and then compares them lexicographically. The first character of stringified array is a digit and therefore only one-char variable name whose ascii index is smaller than indices of all digits is $. Replacing $ with any other variable name will always return false.

I love this site because of answers like these.

Very nice trick!

Oh, now, that is a great trick!

Mathematica, 46 40 37 33 bytes
(i=1;j=0;#-j<5||(i++;j=#)&/@#;i)&

Explanation
i=1;j=0

Set i to 1 and j to 0.
... /@#

Map onto all elements of the input...
#-j<5||(i++;j=#)&

If (element) - j < 5 is false, then increment i and set j to the element (short-circuit evaluation).
;i

Output i.

(i++;j=#)->i++(j=#)

Husk, 8 bytes
Γ(→₀f>+4

Try it online!
Explanation
Γ(→₀f>+4  Implicit input, a list of numbers.
Γ(        Deconstruct into head n and tail x (if empty, return 0).
    f>+4  Keep those elements of x that are greater than n+4.
   ₀      Call main function recursively on the result.
  →       Increment.

Husk, 6 bytes
Lüo<+5

Try it online!
  o<+5        a function that takes two arguments and checks if
              the second is less than the the first plus 5
 ü            remove equal elements from the input list using the above
              function as the equality test
L             return the length of the remaining list

Whoa, I didn't realize ü works like that! That's very handy.

@Zgarb: I first tried ġ but it doesn't work, whereas Haskell's groupBy works: length.groupBy((>).(+5)). Then I found ü which also leads to a shorter Haskell equivalent: nubBy.

Python 2, 58 bytes
a=input()
x=[0]
for k in a:x+=[k]*(k-x[-1]>4)
print len(x)

Try it online!

Saved 2 bytes thanks to @Mr. Xcoder.

49 bytes
f=lambda a:a>[]and-~f([x for x in a if x-a[0]>4])

Using the recursive method shown in @ThePirateBay's solution.

Saved a byte thanks to @Mr. Xcoder.
Saved 2 bytes thanks to @Halvard Hummel.

Try it online!

and 1+f(...) can be replaced by and-~f(...) for 49 bytes

@Mr.Xcoder Oh, can't forget all those bitwise tricks.

x=a[:1] is equivalent to x=[0], since the question explicitly states that the first element is always 0 (62 bytes)

47 bytes recursive

MATLAB, 34 bytes
@(x)nnz(uniquetol(x+1,4/max(x+1)))

Anonymous function that inputs an array and outputs a number.
This uses the uniquetol function, specifically its form y = uniquetol(x, t), which gives y containing unique elements of x with tolerance t. In doing so, the function seems to follow a "lazy" approach: sort x, pick its first entry, and keep skipping entries for as long as they are within tolerance of the latest picked entry. That is exactly what is needed here.
The uniquetol function automatically scales the specified tolerance by the maximum absolute value in a. This is why we need the division here. x+1 is used instead of x to avoid division by 0.
Verification of test cases:
>> f = @(x)nnz(uniquetol(x+1,4/max(x+1)));
>> inputs = {...
       [0] ...
       [0,3,5,7] ...
       [0,3,4,7,9,10,11,12] ...
       [0,30,120] ...
       [0,4,8,12,16] ...
       [0,4,8,12,16,20] ...
       [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] ...
       [0,5,10,15,20] ...
       [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] ...
       [0,1,4,5,9,11,12,14,16,18,23,24,26,28,29,30] ...
   };
>> outputs = cellfun(f, inputs)
outputs =
     1     2     3     3     3     3     4     5     5     6

TIL about uniquetol... Introduced in R2015a. I have R2014b :( Nice answer :)

@Stewie I knew it existed, but I think this is the first time I use it

J, 20 bytes
[:#(,}.~5>(-{.))/@|.

Try it online!
Explanation
[:#(,}.~5>(-{.))/@|.  Input: array A
                  |.  Reverse
                /@    Reduce from right-to-left
            {.          Head of RHS
           -            Subtract with LHS
        5>              Less than 5
     }.~                Drop that many from
    ,                   Join
[:#                   Length

Haskell, 31 30 bytes
f(x:y)=f[z|z<-y,z-4>x]+1
f x=0

Try it online!
Saved 1 byte thanks to Zgarb

z-4>x should save a byte.

@Zgarb What was I thinking??? Thanks! :)

05AB1E, 20 19 18 15 14 11 bytes
v®y‹iy4+©\¼

Explanation:
v          # loop on input
 ®          # push register_c, start at -1
  y‹i         # if current item greater than last item
   y4+         # push new max on stack
    ©\          # push new max on register_c, and pop it from stack
     ¼           # increment counter_variable
                  # implicit print of counter_variable

Try it online!
Edit

-3 bytes thanks to Riley and the usage of counter_variable
no need for counter_variable after all
-3 bytes again thanks to Riley and the usage of register_c

You can use the counter variable to save 3 bytes: ¼4¹vDy‹i¼y4+}}¾

oooooh, there is a counter variable, that's handy! Thank you!!

11 bytes: v®y‹iy4+©\¼

Perl 5, 54 bytes
52 bytes of code +2 for -ap
{$_++;$p=shift@F;1while$F[0]<$p+5&&shift@F;@F&&redo}

Try it online!

Pyth, 14 bytes
L&lbhyfg-Thb5b

This is a recursive function. Call it with y[0 1 2 3 4 5 6 7 8), where [...) is your list.
Alternatively, Try it here! or Verify all the test cases.

Explanation
This is roughly equivalent to the Python solution. A translation would give the following results:
def y(b):
 return (len(b) and y(filter(lambda T:T>=b[0]+5,b)) + 1)

Code Breakdown
L&lbhyfg-Thb5b   - Function called y that accepts a list parameter b.

L                - Define the function.
  lb             - The length of b...
 &               - ... Logical AND ...
    h            - Increment by 1.
     y           - The result given by calling the function recursively on the following:
      f      b     - b filtered...
        -Thb       - ... For the elements whose difference compared to the first element...
       g    5      - ... Is greater than or equal to 5.

I am trying to find a workaround with .U. Suggestions are welcome

05AB1E, 14 bytes
æʒ¬s¥4›Ps_*}θg

Try it online!

That's insane, æ for superset, that's a great trick!

@CyrilGandon æ means "powerset".

Retina, 32 26 bytes
.+
$*11
(1+)(¶1{1,4}\1)*\b

Try it online! Explanation:
.+
$*11

Convert to unary, but add 1, because 0 is a tricky concept in Retina.
(1+)(¶1{1,4}\1)*\b

Count the number of edits, but include all the grace edits in each match.

Ly, 29 bytes
&nr5+sp[[lL[pp2$]p5+sp>`<]]>`

Try it online!
It took a long time to get here.

Java 8, 78 61 60 59 56 bytes
Port of @JungHwanMin's answer
a->{int i=0;for(int l:a)if(l-a[i]>4)a[++i]=l;return-~i;}

Try it online!

You can save 4 bytes like this: a->{int i=0;for(int l:a)if(l-a[i]>4)a[++i]=l;return-~i;}

MATL, 13 12 bytes
`ttX<4+>)t}@

Try it online! Or verify all test cases.
Explanation
`        % Do..while
  t      %   Duplicate. Takes input (implicitly) the first time
  tX<    %   Duplicate and get minimum, i.e the first entry
  4+     %   Add 4
  >      %   Greater than? Element-wise
  )      %   Keep entries that fulfill that
  t      %   Duplicate. This is used as loop condition
}        % Finally (execute at the end of the loop)
  @      %   Push number of iterations. This is the output
         % End (implicit). A new iteration is run if top of the stack is truthy

C# .NET, 63 bytes
a=>{int e=0;foreach(int l in a)if(l-a[e]>4)a[++e]=l;return-~e;}

Explanation:
Try it here.
a=>{                   // Method with integer-array parameter and integer return-type
  int e=0;             //  Amount of edits (starting at 0)
  foreach(int l in a)  //  Loop over the input-array
    if(l-a[e]>4)       //   If the current value minus the current edit is larger than 4:
      a[++e]=l;        //    Raise the edit-count by 1 first,
                       //    and set the current value to this next current edit
                       //  End of loop (implicit / single-line body)
  return-~e;           //  Return the amount of edits + 1
}                      // End of method

Pip, 20 bytes
Fxg{Ix>i+4{++oi:x}}o

Attempt This Online!
Explanation
Fxg{Ix>i+4{++oi:x}}o  # Implicit input on the command line
Fxg{              }   # for x in input:
    Ix>i+4{      }    #  if x > i+4:
           ++o        #   increment o (defaults to 1)
              i:x     #   i = x
                   o  # print o

Jelly, 11 bytes
+4Ḣ<x@µÐĿL’

Try it online!
Explanation
+4Ḣ<x@µÐĿL’  Input: array A
      µÐĿ    Repeat until the results converge
+4             Add 4
  Ḣ            Head
   <           Greater than
    x@         Copy only the true values
         L   Length
          ’  Decrement

12 bytes
;I4<1;x@;ð/L

Try it online!
Explanation
;I4<1;x@;ð/L  Input: array A
         ð/   Reduce A from left-to-right using
;               Concatenate
 I              Increment
  4<            Greater than 4
    1;          Prepend 1
      x@        Times each of
        ;       Concatenate
           L  Length

Pyth, 25 bytes
J1K5FN.+Q=-KNIg0K=hJ=K5;J

Try it here: http://pyth.herokuapp.com

Keeping it as a full program, you can get 21 bytes.

Proton, 40 bytes
Heavily inspired by the Python solution.
f=a=>len(a)and-~f(filter(x=>x>a[0]+4,a))

Try it online!

Kotlin, 52 bytes
Posting as a function, if this is not acceptable I will change it to a method
Submission
{var x=it[0]
var o=1
it.map{if(it>x+4){o++
x=it}}
o}

Beautified
{
    // Last counted edit
    var x=it[0]
    // Current edit total
    var o = 1
    // For each edit
    it.map{
        // If it was 5 or more minutes ago
        if (it>x+4) {
            // Increase edit count
            o++
            // Make it the last counted edit
            x=it
        }
    }
    // Return the edit count
    o
}

Test
var r:(IntArray)->Int=
{var x=it[0]
var o=1
it.map{if(it>x+4){o++
x=it}}
o}

fun main(args: Array<String>) {
    println(r(intArrayOf(0)))
    println(r(intArrayOf(0,3,5,7)))
    println(r(intArrayOf(0,3,4,7,9,10,11,12)))
    println(r(intArrayOf(0,30,120)))
    println(r(intArrayOf(0,4,8,12,16)))
    println(r(intArrayOf(0,4,8,12,16,20)))
    println(r(intArrayOf(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19)))
    println(r(intArrayOf(0,5,10,15,20)))
    println(r(intArrayOf(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)))
    println(r(intArrayOf(0,1,4,5,9,11,12,14,16,18,23,24,26,28,29,30)))
}

TryItOnline

PowerShell, 74 bytes
for($x,$y=$args[0];$y;$x,$y=$y){if($l-le$x-5){$i++;$l=$x}}$i+1+($l-le$x-5)

Iterative solution. Lengthy because of fenceposting on the for loop requiring an additional check on the end. Golfing suggestions welcome.
We take input $args[0] as a literal array, peel off the first element into $x and the remaining into $y. Then, so long as there are elements still in $y, we loop.
Each iteration, we check whether the current timestamp $x is 5 or more away from the $last edit timestamp. If so, we increment our counter $i++ and set our timestamp to be current. Then, on the iteration of the loop, we peel off the next element into $x and leave the remaining in $y.
Once we're out of the loop, we output $i, plus 1 for the initial edit, plus whether the final timestamp is more than five away from the last edit (with the Boolean value implicitly cast to integer). That result is left on the pipeline and output is implicit.
Try it online!

R, 52 bytes
function(l){while(sum(l|1)){l=l[l-l[1]>=5]
F=F+1}
F}

Try it online!
Simple anonymous function that iteratively removes elements from the list that are less than 5 away from the first element until the list is empty, then returns the counter.

Clojure, 53 bytes
#(count(set(reductions(fn[r v](if(<(- v r)5)r v))%)))

This keeps track of the "edit starting times", and then returns their distinct count.

Japt, 14 12 bytes
Ê©ÒßUfÈ-UÎ¨5

Try it

C (gcc), 62 61 bytes
-1 byte thanks to @ceilingcat
f(v,t,c)int*v;{for(t=c=0;*++v;)*v-t>4&&(t=*v)&++c;return-~c;}

Try it online!

Nekomata, 7 bytes
ˡ{C4+>‼

Attempt This Online!
A port of @Zgarb's Husk answer.
ˡ{C4+>‼N
ˡ{          Iterate the following block until it fails, and counts the number of iterations
  C           Split the list into its head and tail
   4+         Add 4 to the head
     >‼       Filter the tail by whether it is greater than the head + 4

Scala, 51 bytes
Modified from @Roberto Graham's Java answer.
Golfed version. Try it online!
a=>{var i=0;for(l<-a)if(l-a(i)>4)a({i+=1;i})=l;i+1}

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


text:
Measuring a pile of logs
Introduction
This is a log of length 5:
#####

I want to pile a bunch of these logs on top of each other.
How I do this is that I slide a new log onto the topmost one from the right, and stop sliding when their left or right ends align (don't ask why).
If the new log is longer, it slides all the way to the left end of the topmost log:
########  <-
#####

If it is shorter, it only slides until their right ends align:
  ######  <-
########
#####

As I slide more logs into the pile, their positions are determined by the current topmost log:
           ##
       ######
       ###
      ####
      ##
  ######
########
#####

This looks physically impossible, but let's pretend it works.
The task
Your input shall be a non-empty list of positive integers, representing the lengths of my logs.
The leftmost number is the first log I put to the pile, so it ends up at the bottom.
In the above example, the input would be [5,8,6,2,4,3,6,2].
Your output shall be, for each column of the resulting pile, the number of logs that cross that column.
In the above example, the correct output would be [2,2,3,3,3,2,4,6,3,3,1,2,2].
Rules and scoring
Input and output can be in any reasonable format.
The output can only contain positive integers, i.e. it must not have leading or trailing 0s.
Normal code-golf rules apply: you can write a full program or a function, the lowest byte count wins, and standard loopholes are forbidden.
Test cases
[1] -> [1]
[4] -> [1,1,1,1]
[3,2] -> [1,2,2]
[2,3] -> [2,2,1]
[2,2,2] -> [3,3]
[2,3,2] -> [2,3,2]
[3,2,3] -> [1,3,3,1]
[1,3,2,2,1,3,1] -> [2,3,5,1,2]
[4,3,4,2,4,3,4,2] -> [1,3,3,5,5,3,4,2]
[5,8,6,2,4,3,6,2] -> [2,2,3,3,3,2,4,6,3,3,1,2,2]
[5,10,15,1,1,1,1,1,2] -> [3,3,3,3,3,2,2,2,2,2,1,1,1,1,7,1]
[13,12,2,10,14,12] -> [1,2,2,2,2,2,2,2,2,2,2,5,5,3,3,3,3,3,3,3,3,2,2,2,2]
[12,14,3,6,13,1,1] -> [2,2,2,2,2,2,2,2,2,2,2,5,4,4,2,2,2,1,1,1,1,1,1,3]
[7,5,12,5,1,10,14,5] -> [1,1,3,3,3,3,3,1,1,2,2,2,2,5,2,2,2,2,2,2,2,2,3,2,2,2,2]
[14,5,1,3,12,6,2,2,1,7,9,15] -> [1,1,1,1,1,1,1,1,1,2,2,2,2,5,2,2,1,1,1,2,2,2,2,4,8,3,3,3,3,3,3,2,2,1,1,1,1,1,1]

We can easily "pretend" it works, by just having them all on the ground rather than stacking them up into the air (sliding them next to each other).

That last test case looks like Norway!

Jelly, 19 13 bytes
IN0»0;+\+"RṬS

Try it online!
Saved 2 bytes thanks to @Jonathan Allan.
Explanation
IN0»0;+\+"RṬS  Input: array A
I              Increments
 N             Negate
  0»           Max with 0
    0;         Prepend 0
      +\       Cumulative sum
        +"     Vectorized add with
          R    Range, vectorizes over each integer
           Ṭ   Create a list with 1's at the specified indices
            S  Sum

Jelly,  18  16 bytes
-2 bytes prompted by help from miles
Maybe there is a quicker way using mathematics rather than construction like this does?
IN0;»0+\0ẋ;"1ẋ$S

Try it online! or see the test-suite.
How?
IN0;»0+\0ẋ;"1ẋ$S - Link: list of positive integers, logLengths  e.g. [4, 3, 3, 1, 4, 3]
I                - incremental differences                            [-1, 0,-2, 3,-1]
 N               - negate (vectorises)                                [ 1, 0, 2,-3, 1]
  0;             - zero concatenated with that                      [0, 1, 0, 2,-3, 1]
    »0           - maximum (vectorises) of that and zero            [0, 1, 0, 2, 0, 1]
      +\         - cumulative reduce with addition                  [0, 1, 1, 3, 3, 4]
        0ẋ       - zero repeated (vectorises)    [[],[0],[0],[0,0,0],[0,0,0],[0,0,0,0]]
              $  - last two links as a monad (right is implicitly logLengths):
            1ẋ   -   one repeated     [[1,1,1,1],[1,1,1],[1,1,1],[1],[1,1,1,1],[1,1,1]]
           "     - zip with:
          ;      -   concatenation
              [[1,1,1,1],[0,1,1,1],[0,1,1,1],[0,0,0,1],[0,0,0,1,1,1,1],[0,0,0,0,1,1,1]]
              ... this is an upside-down version of the logs like those in the OP
                  with 0 for spaces and 1 for # with any right-hand-side spaces missing.
               S - sum                                           [1, 3, 3, 5, 2, 2, 2]

We can get to 17 bytes if we combine our solutions: IN»0+\0;;"x@€0,1S

Husk, 16 bytes
Fż+Ṡzo`Ṙ↔ḋ2eo∫Ẋ<

Try it online!
Explanation
              Ẋ    For all adjacent pairs, x y
               <   return max(0,x-y)
            o∫     Cumulative sum, with an extra 0 at the start
   Ṡz              Zip the input list and ^ with ...
           e         Make a two element list
        ↔ḋ2          The list [0,1]
     o`Ṙ             Repeat each in ^ by ^^
Fż+               Sum the columns

Python 3, 114 109 bytes
Edit: Saved 5 bytes thanks to @Mr.Xcoder
f=lambda x,i=1:x[i:]and x[i]>=x[~-i]and f(x,i+1)or[i]+f([q-(e<i)for e,q in enumerate(x)if(e<i)<q])if x else[]

Try it online!

109 bytes

Perl 5, 64 + 1 (-a) = 65 bytes
for(@F){$e<$s+--$_?$e=$s+$_:($s=$e-$_);$_++for@r[$s..$e]}say"@r"

Try it online!

Mathematica, 76 60 58 57 bytes
#2&@@@Tally[l=j=0;##&@@(Range@#+(j+=Ramp[l-(l=#)]))&/@#]&

Try it on Wolfram Sandbox

Kotlin 1.1, 113 103 bytes
{var l=0
var r=0
it.flatMap{l=maxOf(l,r-it+1)
r=l+it-1
(l..r).toList()}.groupBy{it}.map{it.value.size}}

Beautified
{
    // Current row leftmost value
    var l = 0
    // Current row rightmost value
    var r = 0
    // For each log
    it.flatMap {
        // Work out the new leftmost point
        l = maxOf(
                l,
                r - it+1)
        // Use it to work out the new rightmost point
        r = l + it-1
        // Record the used columns
        (l..r).toList()}
            // Group the column numbers together
            .groupBy { it }
            // Count the amount of times each column is used
            // Put the results into a list
            .map { it.value.size }
}

Test
var z:(List<Int>)->List<Int> =
{var l=0
var r=0
it.flatMap{l=maxOf(l,r-it+1)
r=l+it-1
(l..r).toList()}.groupBy{it}.map{it.value.size}}

fun main(args: Array<String>) {
    println(z(listOf(5, 8, 6, 2, 4, 3, 6, 2)))
    println(listOf(2,2,3,3,3,2,4,6,3,3,1,2,2))
}


text:
Implement the Fibonacci sequence... Shifted to the right
Background
We all know the famous Fibonacci sequence, where each term is the sum of the previous two, with the first term being 0 and the second one being 1. The first few elements are:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765

What we are going to implement today is a similar sequence, starting at 0 and 1 as well, and each term is the sum of the previous two, but the sum's digits are shifted by one place to the right. What does "shifted" mean? – A digit shifted to the right is basically that digit + 1, unless it equals 9, which maps to 0 instead. Just as a reference, here is the full list of mappings:
0 -> 1;  1 -> 2;  2 -> 3;  3 -> 4;  4 -> 5;  5 -> 6;  6 -> 7;  7 -> 8;  8 -> 9;  9 -> 0

With all that being said, these are the first terms of our Fibonacci-shifted sequence:
0, 1, 2, 4, 7, 22, 30, 63, 4, 78, 93, 282, 486, 879, 2476, 4466, 7053, 22620, 30784, 64515

Given an integer N (non-negative if 0-indexed and positive if 1-indexed), finds the Nth term of the Fibonacci-shifted sequence.
Rules

The output may contain leading zero(es), in case 9 is the first (few) digit(s).

Input and output can be handled using any default mean.

Take note that Loopholes are forbidden.

This is code-golf, hence your program will be scored in bytes, with less bytes being better.

A useless sequence that's not on OEIS..?

@StewieGriffin Exactly.

On reflection, this should be a duplicate of Fibonacci... it's literally just digit + 1 mod 10 for each digit after the sum is performed. I have a hammer so I'm not voting, yet.

I'd agree with you (though I also have a hammer)

@ConorO'Brien I'd agree too...also have hammer.

@ConorO'Brien "Hammered" it myself.

Rotating the sum's digits left has a period of 59.

Python 2, 78 72 bytes
f=lambda n:n>1and int(''.join(`-~int(i)%10`for i in`f(n-1)+f(n-2)`))or n

Try it online!
Saved 6 bytes thanks to Halvard Hummel.

72 bytes

Hello and welcome to PPCG! Great first answer! Also, mind if I ask whether you have anything to do with this user?

@Mr.Xcoder I don't know them, but my name was inspired by theirs. Is that a problem? EDIT: Never mind, might as well change my name.

@VoteToReopen No, that is not a problem. I was just asking out of cheer curiosity :)

Jelly, 9 bytes
ð+D‘%⁵Ḍø¡

Try it online!
-2 thanks to Dennis.
Explanation:
ð+D‘%⁵Ḍø¡ Full program. Takes input through STDIN.
ð         Start new dyadic chain
 +        Add the left (f(n - 1)) and right (f(n - 2)) arguments
  D       Get list of decimal digits
   ‘      Increment each
    %⁵    Modulo ⁵ (10)
      Ḍ   Convert from decimal to integer
       ø  Start new niladic chain
        ¡ Repeat previous chain z times (where z is taken from STDIN as there are no arguments)

This is a repost of my answer on the old deleted question.

If you take input from STDIN, you can eliminate both 0.

@Dennis I was expecting Jelly-related action of yours after seeing your comment :p EDIT: There was a comment on the question that now got deleted.

JavaScript (ES6), 63 62 bytes
This is what I'd come up with before the challenge was deleted, don't have time to golf it further now.
Returns the nth number in the sequence, 0-indexed.
f=(n,x=0,y=1)=>n?f(--n,y,+[...x+y+""].map(z=>++z%10).join``):x

1 byte saved thanks to Conor.

Try it online

Alternative, 55 bytes
A quick port of VoteToReopen's excellent Python solution.
f=n=>n>1?+[...f(--n)+f(--n)+""].map(x=>++x%10).join``:n

Try it online

-1 byte: change ~~ to +

Oh, yeah. Thanks, @ConorO'Brien; the ~~ snuck back in there when I rewrote this on my phone.

J, 40 bytes
[`(-&2(10|>:)&.(10&#.inv)@+&$:<:)@.(1&<)

Try it online!
Highlighted following is the standard Fibonacci husk:
[`(-&2                    +&$:<:)@.(1&<)

Then, we compose the following function with the result of adding the previous two terms:
      (10|>:)&.(10&#.inv)@

This, in turn, is the function 10|>: atop 10&#.inv, which gets the digits of a number. That is to say, the digits are obtained, then the function 10|>: is applied, then the digits are combined to make a number again. 10|>: is a fork that is equivalent to (y + 1) % 10 in a conventional language for input y.


text:
Matrix with 1 to L(n), in all n columns
Challenge:
Take a list, L containing positive integers as input:
3 5 2 1 6

and create a matrix where the n'th column contains the vector 1:L(n), where shorter rows are padded with zeros.
Test cases:
3   5   2   1   6
-----------------
1   1   1   1   1
2   2   2   0   2
3   3   0   0   3
0   4   0   0   4
0   5   0   0   5
0   0   0   0   6

1
-
1

1   2   3   4   3   2   1
-------------------------
1   1   1   1   1   1   1
0   2   2   2   2   2   0
0   0   3   3   3   0   0
0   0   0   4   0   0   0

Rules:

Optional input and output formats

List of lists is an acceptable output format

The matrix must be as small as possible (you may not pad it with more zeros than needed)
Shortest code in each language wins
Explanations are highly encouraged

May we distribute the ranges horizontally instead?

No, they should be vertical. If you use a language where the words horizontal/vertical doesn't have any meaning then it's optional. (Could be relevant for languages where lists of lists aren't associated with either horizontal/vertical directions)

@StewieGriffin What sane language doesn't associate dimensions with nested lists?

@EriktheOutgolfer, How many insane languages are used on this site?

@StewieGriffin It depends on how you define insane, but if your language doesn't have any concept of dimensionality at all, I'm not sure how sane it is.

@EriktheOutgolfer R for one doesn't see matrices as nested list, but rather one long list, which wraps around row-wise.

R, 40 38 bytes
function(l)outer(m<-1:max(l),l,"<=")*m

Try it online!
Explanation:
outer applies its third argument (the function) to all combinations of elements of its first two arguments, generating a matrix of TRUE and FALSE where each column has TRUE where 1:max(l) is less than or equal to the corresponding element of l, for the example where l=c(3,5,2,1,6):
      [,1]  [,2]  [,3]  [,4] [,5]
[1,]  TRUE  TRUE  TRUE  TRUE TRUE
[2,]  TRUE  TRUE  TRUE FALSE TRUE
[3,]  TRUE  TRUE FALSE FALSE TRUE
[4,] FALSE  TRUE FALSE FALSE TRUE
[5,] FALSE  TRUE FALSE FALSE TRUE
[6,] FALSE FALSE FALSE FALSE TRUE

Then supposing the resultant matrix is A, then A*m -> A[i,j]=A[i,j]*i which coerces TRUE to 1 and FALSE to 0, producing the desired result.

I think - you can save 2 bytes, by replacing function(l) with l=scan();

@AndriusZ but then I'd have to wrap everything in a print so I would lose those bytes.

I think, you don't need to wrap everything - TOI

@AndriusZ we've definitely talked about this before. The only answer to this meta question gives a +4 penalty for using source(...,echo=TRUE) and reading from stdin as a full program, if you have an alternative suggestion, by all means weigh in there, but as far as I'm aware that's the closest we have to an R consensus on full programs and it stands for the time being.

Late to the game: save two bytes using [this tip] (https://codegolf.stackexchange.com/a/111578/80010)

@JayCe yeah, that would make this an R + pryr answer rather than a pure R answer, which technically counts as a separate language.

@Giuseppe Didn't know that - I've seen this used in so many answers. Thanks for clarifying!

MATL, 8 bytes
"@:]Xho!

Try it online!
Explanation
"      % Implicit input, L. For each k in L
  @    %   Push k
  :    %   Range [1 2 ... k]
]      % End
Xh     % Collect all stack contents in a cell array
o      % Convert to double matrix. The content of each cell is
       % right-padded with zeros if needed
!      % Transpose. Implicitly display

Python 3, 54 bytes
lambda x:[[-~i*(i<a)for a in x]for i in range(max(x))]

Try it online!

Mathematica, 20 bytes
PadRight@Range@#&

Contains U+F3C7 (Mathematica's builtin Transpose function)
Try it on Wolfram Sandbox
Usage
PadRight@Range@#&[{3, 5, 2, 1, 6}]

{
 {1, 1, 1, 1, 1},
 {2, 2, 2, 0, 2},
 {3, 3, 0, 0, 3},
 {0, 4, 0, 0, 4},
 {0, 5, 0, 0, 5},
 {0, 0, 0, 0, 6}
}

Explanation
PadRight@Range@#&

         Range@#    (* Generate {1..n} for all elements of input *)
PadRight@           (* Right-pad 0s so that all lists are equal length *)
                   (* Transpose the result *)

@downvoters why the downvotes? Could y'all explain?

I didn't downvote, but I suspect it is because you are lacking the function signature or an input of arguments, which causes your code snippet not to be a black box!

Octave, 26 bytes
@(x)((y=1:max(x))'<=x).*y'

Anonymous function that inputs a row vector and outputs a matrix.
Try it online!
Explanation
Consider input x = [3 5 2 1 6]. This is a row vector of size 1×5.
1:max(x) gives the row vector [1 2 3 4 5 6], which is assigned to variable y.
The transpose of that, i.e. the column vector [1; 2; 3; 4; 5; 6], is <=-compared (element-wise with broadcast) with the input [3 5 2 1 6]. The result is the 6×5 matrix
[1 1 1 1 1;
 1 1 1 0 1;
 1 1 0 0 1;
 0 1 0 0 1;
 0 1 0 0 1;
 0 0 0 0 1]

Finally, multiplying (element-wise with broadcast) by the column vector [1; 2; 3; 4; 5; 6], obtained as y transposed, gives the desired result:
[1 1 1 1 1;
 2 2 2 0 2;
 3 3 0 0 3;
 0 4 0 0 4;
 0 5 0 0 5;
 0 0 0 0 6]

I was hoping to see a MATLAB/Octave submission. I implemented this without putting any thought into it, so it was probably more than 40 bytes. Very nice solution :)

05AB1E, 4 bytes
€L0ζ

Try it online! or as a nicely formatted test suite
€L   # For each: get the range 1..input
  0ζ # zip, padding with 0s

Husk, 4 bytes
Returns a list of lists
T0mḣ

Try it online!
Explanation
  m    Map over the input
   ḣ   Range from 1 to n
T0     Transpose, padding with 0s

Jelly, 3 bytes
Rz0

Try it online!
Explanation
Rz0  Input: array A
R    Range, vectorizes to each integer
 z0  Transpose and fill with 0

Pyth, 6 bytes
.tSMQZ

Try it here! or Verify all the test cases (with pretty-print)!

Explanation

.tSMQZ   - Full program.

  SMQ    - Get the inclusive unary ranges for each.
.t       - Transpose, padding with copies of...
     Z   - ... Zero.
         - Implicit print.

A non-built-in transpose version would be:
mm*hd<dkQeS

This works as follows:
mm*hd<dkQeS   - Full program.

m        eS   - Map over [0, max(input)) with a variable d.
 m      Q     - Map over the input with a variable k.
   hd         - d + 1.
  *           - Multiplied by 1 if...
     <dk      - ... d is smaller than k, else 0.
              - Output implicitly.

Actually, 17 bytes
;M╗♂R⌠╜;0@α(+H⌡M┬

Try it online!
Explanation:
;M╗♂R⌠╜;0@α(+H⌡M┬
;M╗                store the maximal element (M) of the input in register 0
   ♂R              range(1, n+1) for each n in input
     ⌠╜;0@α(+H⌡M   for each range:
      ╜;0@α          push a list containing M 0s
           (+        append to range
             H       take first M elements
                ┬  transpose

Yeah, Actually actually needs zip with padding support...

Pyke, 3 bytes
This uses the new feature of Pyke, hex encodings... The best part is that we tie Jelly! Raw bytes:
4D 53 AC

Try it here!
The ASCII-Pyke equivalent would be 4 bytes:
MS.,

How?

4D 53 AC   - Full program.

4D         - Map.
   53      - Inclusive range.
      AC   - Transpose with zeroes.
           - Output implicitly.

-------------------------------------

MS.,   - Full program.

M      - Map.
 S     - Inclusive range.
  .,   - Transpose with zeroes.
       - Output implicitly.

Here is a pretty-print version with ASCII, and here is one with hex encodings.

Perl 5, 62 57 + 1 (-a) = 58 bytes
$,=$";say map$i*($_-->0),@F while++$i&&(sort{$b-$a}@F)[0]

Try it online!

Nice answer! You can save 1 byte with this too by moving to "@{[...]}" instead of setting $, and (I'm sure you probably don't want to but...) you can replace the sort call with an additional flag -MList::Util+(max) and call max instead.

@DomHastings Under the rules of the time, the -M flag would have been added to the byte count, significantly increasing it.

Perl 6, 39 bytes
{zip (1 X..$_).map:{|@_,|(0 xx.max-1)}}

Try it
Expanded:
{                # bare block lambda with implicit parameter ｢$_｣

  zip

    (1 X.. $_)   # turn each input into a Range that starts with 1

    .map:        # map each of those Ranges using the following code

    {            # bare block lambda with implicit parameter ｢@_｣
                 # (｢@_｣ takes precedence over ｢$_｣ when it is seen)

      |@_,       # slip the input into a new list

      |(         # slip this into the list

        0        # a ｢0｣
        xx       # list repeated by

          .max   # the max of ｢$_｣ (implicit method call)
          - 1    # minus 1 (so that zip doesn't add an extra row)
      )
    }
}

Note that zip terminates once the shortest input list is exhausted.

C#, 136 bytes

Data

Input Int32[] i An array of ints
Output Int32[,] A bidimentional array.

Golfed
i=>{int m=System.Linq.Enumerable.Max(i),l=i.Length,x,y;var o=new int[m,l];for(y=0;y<m;y++)for(x=0;x<l;)o[y,x]=i[x++]>y?y+1:0;return o;};

Ungolfed
i => {
    int
        m = System.Linq.Enumerable.Max( i ),
        l = i.Length,
        x, y;

    var o = new int[ m, l ];

    for( y = 0; y < m; y++ )
        for( x = 0; x < l; )
            o[ y, x ] = i[ x++ ] > y ? y + 1 : 0;

    return o;
};

Ungolfed readable
// Take an array of Int32
i => {

    // Store the max value of the array, the length and declare some vars to save some bytes
    int
        m = System.Linq.Enumerable.Max( i ),
        l = i.Length,
        x, y;

    // Create the bidimensional array to output
    var o = new int[ m, l ];

    // Cycle line by line...
    for( y = 0; y < m; y++ )

        // ... and column by column...
        for( x = 0; x < l; )

            // And set the value of the line in the array if it's lower than the the value at the index of the input array
            o[ y, x ] = i[ x++ ] > y ? y + 1 : 0;

    // Return the bidimentional array.
    return o;
};

Full code
using System;
using System.Collections.Generic;

namespace TestBench {
    public class Program {
        // Methods
        static void Main( string[] args ) {
            Func<Int32[], Int32[,]> f = i => {
                int
                    m = System.Linq.Enumerable.Max( i ),
                    l = i.Length,
                    x, y;
                var o = new int[ m, l ];
                for( y = 0; y < m; y++ )
                    for( x = 0; x < l; )
                        o[ y, x ] = i[ x++ ] > y ? y + 1 : 0;
                return o;
            };

            List<Int32[]>
                testCases = new List<Int32[]>() {
                    new[] { 1, 2, 5, 6, 4 },
                    new[] { 3, 5, 2, 1, 6 },
                    new[] { 1, 2, 3, 4, 3, 2, 1 },
                };

            foreach( Int32[] testCase in testCases ) {
                Console.WriteLine( " INPUT: " );
                PrintArray( testCase );

                Console.WriteLine( "OUTPUT: " );
                PrintMatrix( f( testCase ) );
            }

            Console.ReadLine();
        }

        public static void PrintArray<TSource>( TSource[] array ) {
            PrintArray( array, o => o.ToString() );
        }
        public static void PrintArray<TSource>( TSource[] array, Func<TSource, String> valueFetcher ) {
            List<String>
                output = new List<String>();

            for( Int32 index = 0; index < array.Length; index++ ) {
                output.Add( valueFetcher( array[ index ] ) );
            }

            Console.WriteLine( $"[ {String.Join( ", ", output )} ]" );
        }

        public static void PrintMatrix<TSource>( TSource[,] array ) {
            PrintMatrix( array, o => o.ToString() );
        }
        public static void PrintMatrix<TSource>( TSource[,] array, Func<TSource, String> valueFetcher ) {
            List<String>
                output = new List<String>();

            for( Int32 xIndex = 0; xIndex < array.GetLength( 0 ); xIndex++ ) {
                List<String>
                    inner = new List<String>();

                for( Int32 yIndex = 0; yIndex < array.GetLength( 1 ); yIndex++ ) {
                    inner.Add( valueFetcher( array[ xIndex, yIndex ] ) );
                }

                output.Add( $"[ {String.Join( ", ", inner )} ]" );
            }

            Console.WriteLine( $"[\n   {String.Join( ",\n   ", output )}\n]" );
        }
    }
}

Releases

v1.0 - 136 bytes - Initial solution.

Notes

None

K (ngn/k), 17 bytes
{a*~x</:a:1+!|/x}

Try it online!

C (gcc), 142 bytes
i,j,k;main(c,v)char**v;{for(;++i<c;k=k<*v[i]?*v[i]:k)printf("%c ",*v[i]);for(i=48;puts(""),i++<k;)for(j=1;j<c;)printf("%c ",i<=*v[j++]?i:48);}

Try it online!

137 bytes

Proton, 38 bytes
a=>[[i<j?-~i:0for j:a]for i:0..max(a)]

Try it online!

Let me guess, the bug is the space after it?

@cairdcoinheringaahing Yes. The question mark will consume the character after it to make sure it's not another question mark but I forgot to compensate for the extra character resulting in it being skipped.

Seems you got a pull, you can now remove the notice :)

Add++, 37 bytes
D,g,@@*,bL_1+0XA$p$+bUp
L~*,€RAbM€gBc

Try it online!

JavaScript (Node.js), 55 bytes
x=>f=(t=1,s,e=x.map(y=>y<t?0:s|=t))=>s?[e,...f(++t)]:[]

Try it online!
JavaScript (Node.js), 63 bytes
x=>[...Array(Math.max(...x,t=0))].map(_=>x.map(y=>y<t?0:t,++t))

Try it online!

Java 10, 115 bytes
a->{int l=a.length,m=0;for(int j:a)m=j>m?j:m;var r=new int[m][l];for(;l-->0;)for(m=0;m<a[l];r[m][l]=++m);return r;}

Explanation:
Try it online.
a->{                  // Method with integer-array parameter and integer-matrix return-type
  int l=a.length,     //  Length of the array
      m=0;            //  Largest integer in the array, 0 for now
  for(int j:a)        //  Loop over the array
    m=j>m?            //   If the current item is larger than `m`:
       j              //    Set `m` to this item as new max
      :               //   Else:
       m;             //    Leave `m` the same
  var r=new int[m][l];//  Result-matrix of size `m` by `l`, filled with zeroes by default
  for(;l-->0;)        //  Loop over the columns
    for(m=0;m<a[l];   //   Inner loop over the rows
      r[m][l]=++m);   //    Set the cell at position `m,l` to `m+1`
  return r;}          //  Return the result-matrix

Uiua, 8 bytes
+1⍉⬚¯1∵⇡

Try it!
+1⍉⬚¯1∵⇡
      ∵⇡  # range of each
   ⬚¯1    # filling with -1
  ⍉       # transpose
+1        # increment

Japt, 6 bytes
Would be 4 if Japt's transpose padded with 0 instead of null.
mõ zÔÕ

Try it

TI-Basic, 48 bytes
Ans→A
List►matr(1 or Ans,[A]
[A]
For(I,2,max(ʟA
List►matr(I(I≤ʟA),[B]
augment(Ans,[B]
End
Ansᵀ

Takes input in Ans. Similar method to this answer.

Scala, 76 bytes
Golfed version. Try it online!
l=>l.flatMap(v=>(1 to l.max).map(i=>if(i<=v)i else 0)).grouped(l.max).toList

Ungolfed version. Try it online!
object Main {
  def f(l: List[Int]): List[List[Int]] = {
    val m = (1 to l.max).toList
    l.flatMap { value =>
      m.map { i =>
        if (i <= value) i else 0
      }
    }.grouped(m.size).toList
  }

  def main(args: Array[String]): Unit = {
    println(f(List(3, 5, 2, 1, 6)))
  }
}

J, 10 bytes
0|:>:@i."0

No surprises
Attempt This Online!
0|:>:@i."0
      i."0   NB. create 0..n-1 range for each atom
   >:@       NB. then increment
0|:          NB. transpose

Nekomata, 8 bytes
ṀR$ᵒ{≤0I

Attempt This Online!
Longer than other answers, because Nekomata doesn't have a padding builtin yet. I'll add one in some future version.
ṀR$ᵒ{≤0I
Ṁ           Maximum
 R          Range from 1 to that
  $         Swap
   ᵒ{       Make a 2D array by the following function
     ≤      If left <= right, return left
      0I    Otherwise, return 0

Nekomata, 8 bytes
R:∑0*ᵚ+Ť

Attempt This Online!
R:∑0*ᵚ+Ť
R           Range from 1 to input
 :          Duplicate
  ∑         Sum
   0*       Multiply by 0
     ᵚ+     Add this to each element of the other array
       Ť    Transpose

K (ngn/k), 20 bytes
{+(1+!'x),'&'-x-|/x}

Try it online!

APL (Dyalog Classic), 5 bytes
⍉∘↑⍳¨

Anonymous tacit function.
Did you know that APL's Mix function automatically pads with zeros?
Try it online!


text:
Fabricate Frequently Factored Functions
In  one of this question's bonuses I asked you to design a permutation on the natural numbers such that the probability of a random term being odd was \$1\$.  Now let's kick it up a notch.  I want you to design and implement a permutation, \$f\$, on the natural numbers such that, for every integer \$n\$ greater than 0, the probability on \$f\$ of a member being divisible by \$n\$ is \$1\$.
Definition of Probability
To avoid confusion or ambiguity I am going to clearly lay out what is meant by probability in this question.  This is adapted directly from my original question.
Let us say we have a function \$f\$ and a predicate \$P\$.  The probability of a number fulfilling \$P\$ will be defined as the limit of the number of members of \$f\{1..n\}\$ fulfilling the predicate \$P\$ divided by \$n\$.
Here it is in a nice Latex formula
$$
  \lim_{n\to\infty} \dfrac{\left|\left\{x : x\in \left\{1\dots n\right\}\right\},P(f(x))\right|}{n}
$$

In order to have a probability of something being \$1\$ you don't need every member to satisfy the predicate, you just need the ones that don't to get farther apart the bigger they are.
This is code-golf so answers will be scored in bytes with less bytes being better.
You may take the natural numbers to either include or exclude 0.  Both are fine.

Husk, 11 bytes
!uΣz:NCNmΠN

Try it online! Or showing the stats for the first 100 n in the first 5000 terms
Explanation
        mΠ     Map factorial over
          N    the Natural numbers
      CN       Cut into lists of lengths corresponding to the natural numbers
   z:N         ZipWith append the natural numbers and ^
  Σ            Concatenate into one list
 u             Remove duplicates
!              Index

Proof (Without the u)
For triangle numbers : f(½n*(n+1))=n
Otherwise : f(n)=k! for some k.
As the density of triangular numbers is zero, this has the same probability as the sequence of factorials: 1

Thought that Π was a П (russian P)

@StanStrum Nope Pi, as in product

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