# 05AB1E, ~~13~~ 12 bytes

```
ÝI<ãʒ.øDŸQ}g
```

Try it online!

While most answers use a formula or recurrence relation, this is a simple counting approach.

Each possible path through the grid is represented by the list of its y coordinates. For n segments, there are a total of (n+1) points, but the first and last one are necessarily 0, so that leaves (n-1) points to specify.

```
Ý # range [0..n]
I< # n - 1
ã # cartesian power
```

We now have a list of paths (not yet including the initial and final 0). By construction, none of them ever go below 0. However, some of them have illegal slopes (e.g. jump from 0 to 2), so we need to filter them out.

```
ʒ }g # count how many paths satistfy the following condition
0.ø # surround with 0
Q # is equal to
DŸ # its own fluctuating range
```

`Ÿ`

is the fluctuating range built-in. If there's any pair of non-adjacent numbers, it will fill in the missing numbers (e.g. [0, 2] becomes [0, 1, 2]). Only legal paths will be left unchanged.

A perhaps more intuitive way to check for illegal slopes would be `üαà`

(assert the maximum of pairwise absolute differences equals 1). However, this misses the flat [0, 0, ... 0] path, which costs one extra byte to fix.

Finally, note that the actual code uses `.ø`

where this explanation uses `0.ø`

. Instead of surrounding the path with 0s, this surrounds the implicit input with two copies of the path. This turns the coordinate system upside-down and inside-out, but is otherwise equivalent.