text:
Counting King's Hamiltonian Paths through 3-by-N grid
Background
A Hamiltonian path is a path on a graph that steps through its vertices exactly once. On a grid, this means stepping through every cell exactly once.
On a square grid, a Chess King can move to a horizontally, vertically, or diagonally adjacent cell in one step.
Challenge
Count the number of Hamiltonian paths using Chess King's moves through a square grid of 3 rows and N columns (denoted X below), starting at the left side of the entire grid (denoted S below) and ending at the right side (denoted E below):
  <------N------>
  X X X ... X X X
S X X X ... X X X E
  X X X ... X X X

In other words, count all paths from S to E that passes through every X exactly once using only King's movements.
Standard code-golf rules apply. The shortest code in bytes wins. Kudos if you can solve this with short code in a way other than brute-forcing all possible paths.
Test cases
Generated using this APL code (equivalent Python 3 + Numpy) which I created by finding 15 possible states of the rightmost column and deriving a 15-by-15 transition matrix (figures up to N=3 are crosschecked with a pure brute-force Python).
N  -> Answer
0  -> 1
1  -> 2
2  -> 28
3  -> 154
4  -> 1206
5  -> 8364
6  -> 60614
7  -> 432636
8  -> 3104484
9  -> 22235310
10 -> 159360540

Thanks to @mypronounismonicareinstate and @ChristianSievers for confirming the test cases in the sandbox.

It seems like it would be really hard to get count paths in a way other than enumerating them. Maybe for 2-by-N there's some nice classification that leads to a formula.

@xnor I tried it first, and it boiled down to power of 2 times fibonacci or something, which is... boring.

Oh, I see it now. A 2-by-N path is specified by choosing non-overlapping pairs of adjacent columns for where the path doubles back left, which are counted by Fibonacci numbers, combined with specifying which of the two cells in each column is visited first, for a power of 2. Neat for combinatorics, boring for a golf challenge :)

this is now https://oeis.org/A338426

Wolfram Language (Mathematica), 76 72 bytes
LinearRecurrence[{6,12,-27,2,30,4,-6},{0,0,1,2,3,29,155}-6/5,{#+4}]+1/5&

Try it online!
The non-homogeneous linear recurrence equation is so much shorter to express that it saves a few bytes to modify the code to handle non-homogeneous linear recurrence.
More info: In this case, it cannot be represented as a polynomial. I tried to put the recurrence into RSolve, but it takes a long time to figure out the exact symbolic form (I terminate it before it completes), and I'm pretty sure that the required coefficients are irrational (approximate numerical formula can be obtained).
Returns a singleton list containing the result.

Indeed, the characteristic polynomial $x^8-7 x^7-6 x^6+39 x^5-29 x^4-28 x^3+26 x^2+10 x-6$ of the linear recurrence equals $x-1$ times an irreducible degree-7 polynomial, and so the exact formula will involve the degree-7 algebraic numbers that are the roots of this polynomial.

Python 2, 136 129 bytes
f=lambda n,c=0,p=1:p==3*n+4and c+6>>3*n+3or sum(f(n,c|1<<p,p+d-4)for d in range(9)if~47&1<<p+3and(p%3*3+d%3)%8and~c&(-p>~n*3)<<p)

Try it online!
-5 bytes thanks to @ovs
Performs a depth-first search starting at S and ending at E. The start position is encoded as p=1, and increase down and to the right, so the top row for n=4 is 0,3,6,9 and the bottom row is 5,8,11,14.
f=lambda n,c=0,p=1:(
    # if at final position:
    p==3*n+4
        and c+6>>3*n+3 # return 1 if all cells passed through else 0
    or
    # else return sum of:
     sum(
        f(n,c|1<<p,p+d-4)  # ways from that point
        for d in range(9) # for all 9 points within distance 1
        if~47&1<<p+3 # except if off to the left

        and(p%3*3+d%3)%8 # or that would be walking off top or bottom
        # (-p>~n*3) # or off to the right
        # (if this evaluates False, then the next condition is ~c&0<<p, which always gives falsey 0;
        #  if this evaluates True, then the next condition is ~c&1<<p, which tests if location already visited)
        and~c&(-p>~n*3)<<p
    )
)

I think 254&1<<p%3*3+d%3 can be replaced by (p%3*3+d%3)%8.

And -p>~n*3 instead of p<3*n+3.

Python 3, 104 bytes
f=lambda n,a=[154,28,2,1,0,-1,-1]:n and f(n-1,[sum(map(int.__mul__,a,(6,12,-27,2,30,4,-6)))-4]+a)or a[3]

Try it online!
Unlike Mathematica, Python doesn't have a built-in for linear recurrence equations, so calculating a homogeneous recurrence equation takes approximately the same number of bytes as a non-homogeneous one.
Alternative solution.

05AB1E, 26 bytes
_i1ëL3LâœʒθнQyннyüα2‹PPP}g

Brute-force approach, so it's pretty slow. Also, 4 bytes are wasted on edge-case n=0.
Try it online or verify the \$[0,1,2]\$ test cases (times out for \$n\geq3\$).
Explanation:
In general:

Get all possible coordinates based on the input \$n\$
Get all permutations of these coordinates
Filter this list of permutations and only keep those that satisfy:

The first coordinate in this permutation is in the first column
The last coordinate in this permutation is in the last column
The difference between each overlapping pair of coordinates in this permutation is 1 step (in either a horizontal, vertical, or (anti-)diagonal direction)

Get the amount of valid permutations left to get the result
(Fix edge case \$n=0\$.)

_i       # If the (implicit) input-integer is 0:
  1      #  Push 1 (which is implicitly printed as result)
 ë       # Else:
  L      #  Push a list in the range [1, (implicit) input]
   3L    #  Push list [1,2,3]
     â   #  Take the cartesian product of the lists to get all (1-based) coordinates
      œ  #  Get all permutations of these coordinates
ʒ        #  Filter the list of permutations by:
  н      #   Get the x-coordinate
 θ       #   of the last coordinate in this permutation
   Q     #   And check if it's equal to the (implicit) input-integer
 y н     #   Also get the x-coordinate
  н      #   of the first coordinate in this permutation
 yü      #   For each overlapping pair of coordinates:
   α     #    Get the absolute difference between the two: [|x1-x2|,|y1-y2|]
    2‹   #   Check for each difference in each pair if it's 0 or 1: [|x1-x2|<2,|y1-y2|<2]
      P  #   Check if both values within each pair are truthy: (|x1-x2|<2)*(|y1-y2|<2)
       P #   Check if all checks for each overlapping pair are truthy
 P       #   Get the product of all three checks (note: only 1 is truthy in 05AB1E)
}g       #  After the filter: get the amount of valid permutations by taking the length
         #  (which is output implicitly as result)

Brachylog, 40 bytes
Bruteforce for now. Times out on TIO for test cases > 2, but at least 3 was verified locally.
0+₁|{;3⟦₁ᵐẋp{hh1&b;?zk{\-ᵐȧᵐ≤ᵛ1}ᵐ&th}?}ᶜ

Try it online!
How it works
0+₁|

If input is zero, return 1. Otherwise …
{…}ᶜ

Count all …
;3⟦₁ᵐẋ

coordinates [[1,1],[1,1],[1,2],…,[N,1],[N,2],[N,3]] …
p{ … }

permutations that fulfill:
hh1

The first point's x coordinate must be 1
&b;?zk

Zip the permutation with itself shifted by one, drop the wrapped around. [[[1,1],[2,2]], …]
{\-ᵐȧᵐ≤ᵛ1}ᵐ

Check king moves: For each of the pairs, [[1,1],[2,2]] transpose [[1,2],[1,2]] subtract [-1,-1] absolute values [1,1] all of them must be less or equal than 1.
&th}?

Also, the last point's x coordinate must unify with the input.

Charcoal, 128 bytes
Ｎθ⊞υＥ⁺³θ⁰⊞υＥ⁺³θ∧›ι¹‹ι⁺²θ⊞υＥ⁺³θ›ι¹⊞υ§υ¹⊞υ§υ⁰≔⟦Ｅ³∨ιυ⟧υ≔⁰ηＦυＦ…·⊖§ι²⊕§ι²Ｆ…·⊖§ι¹⊕§ι¹Ｆ§§§ι⁰κλ¿‹λ⁺²θ⊞υ⟦Ｅ§ι⁰Ｅν∧∨⁻ξκ⁻ρλπλκ⟧≧⁺¬⊖ΣＥ§ι⁰ΣνηＩη

Try it online! Link is to verbose version of code. Brute force version, because I haven't figured out a recurrence relation, assuming one is even possible. Explanation:
Ｎθ

Input n.
⊞υＥ⁺³θ⁰⊞υＥ⁺³θ∧›ι¹‹ι⁺²θ⊞υＥ⁺³θ›ι¹⊞υ§υ¹⊞υ§υ⁰

Build up an array of unvisited squares, but with a border of 0s so the starting square is actually [2, 1] (and is visited).
≔⟦Ｅ³∨ιυ⟧υ

Start a breadth-first search with this array and the starting square just mentioned.
≔⁰η

Start with zero successful paths.
ＦυＦ…·⊖§ι²⊕§ι²Ｆ…·⊖§ι¹⊕§ι¹Ｆ§§§ι⁰κλ

For each position, loop through all of the unvisited squares of the 3×3 square that has the current square at its centre.
¿‹λ⁺²θ

If we have not reached the finish, then ...
⊞υ⟦Ｅ§ι⁰Ｅν∧∨⁻ξκ⁻ρλπλκ⟧

... push the grid with this square visited plus the new position to the list of positions to search...
≧⁺¬⊖ΣＥ§ι⁰Σνη

... otherwise if this is the last unvisited square then increment the number of successful paths.
Ｉη

Print the final count of successful paths.

JFTR, I found a counterexample to my original recurrence relation approach, so it was never going to work out. I still wonder how @Bubbler derived his transition matrix...

Jelly, 28 25 27 bytes
Rp3Ḷ¤Æị€;ıŒ!ISḞ=ʋƇ³IA<2ẠƲƇL

or
Ḷp3R¤Æị€Œ!ISḞ=ʋƇ’IA<2ẠƲƇL+¬

Try it online!
Not the most exciting answer: brute-forces all possible paths and times out on TIO for n>2.
+3 bytes for fixing n=0 case.
I have temporarily paused golfing since the bytecount reached f(2)=28.
Rp3Ḷ¤Æị€;ıŒ!ISḞ=ʋƇ³IA<2ẠƲƇL
Rp3Ḷ¤Æị€                       # Generate all points on a lattice from 1+0j to n+2j
        ;ı                     # Append 0+1j (start position)
          Œ!                   # Take all permutations
                ʋƇ             # Filter for
            ISḞ=  ³              # real(last-first)=n
                        ƲƇ     # Filter for
                   IA<2Ạ         # All moves have magnitude less than 2
                          L    # Length

It gives an error for n=0 (it's an annoying edge case that wasted 4 bytes in my answer as well.. :/)

@KevinCruijssen Fixed, either by manually adding one or taking permutations of the list including the start point.

R, 191 168 bytes
Edit: -23 bytes by switching to linear instead of matrix coordinates
f=function(p=-1,m=rep(0,3*n),n){if(p>0)m[p]=1
`if`(all(m),p/3>n-1,`if`(!sum(q<-!m[a<-(a=p+(-4:4)[!!c((p+2)%%3,1,(p+3)%%3)])[a>0&a<=3*n]]),0,sum(sapply(a[q],f,m,n))))}

Try it online!
Recursively tries all paths & counts-up those that end in last column & visit all positions.
Commented version:
paths=f=function(p=c(2,0),m=matrix(0,3,n),n){       # start at position 'S'; fill matrix with zeros
    m[t(p)]=1                                       # set visited positions to 1
    if(all(m)){                                     # visited all positions?
        if(p[2]==n){                                # if we're in the last column...
            return(1)}                              # ...then this is a valid path
        else{return(0)}                             # otherwise it isn't.
    } else {                                        # if there are still some positions to visit:
        a=p+rbind(1:3,rep(1:3,e=3))-2               # a = all possible king moves...
        a<-t(a[,!colSums(a<1|a>dim(m))])            # ...limited to bounds of matrix
        q=!m[a]                                     # q = moves to unvisited positions
        if(!sum(q)){return(0)}                      # if we can't move, it's not a valid path
        else{                                       # if we can move...
            return(sum(sapply(split(a,seq(q))[q],f,m,n)))
                                                    # return the sum of all valid paths from here
                                                    # by recursively calling self with each new position
        }
    }
}

JavaScript (ES6),  82  79 bytes
This is using @user202729's linear recurrence.
f=n=>([5,5,6,7,8,34,160][n+3]||[6,12,-27,p=2,30,4,-6].map(c=>p+=c*f(--n))&&p)-6

Try it online!

Husk, 22 bytes
#¹mo→→fΛδΛ≈fȯε→←P¤×eḣ3

Try it online!
It's just brute force, so not that fast, though TIO can handle \$n = 3\$.
Husk's default return values line up nicely so that I don't waste any bytes special casing \$n = 0\$.
Explanation
P¤×eḣ3  Generate all permutations of vertices.
 ¤   3  Apply to both 3 and n:
    ḣ   Range from 1.
  ×e    Cartesian product.
P       Permutations.
        For n=0 the range and the product are empty,
        and P gives [[]].
        Note that the second coordinates run from 1 to n.

f(ε→←)  Check initial vertex.
f(   )  Filter by condition:
    ←     First element.
   →      Last element of that
  ε       has absolute value at most 1.
        For n=0 the condition is checked for [],
        which is a list of lists of numbers.
        ← defaults to [], an empty list of numbers in this case.
        → defaults to 0 on it, and ε reports true.

fΛδΛ≈  Check adjacent vertices.
f      Filter by condition:
 Λ       For all adjacent pairs,
  δΛ     in both coordinates
    ≈    the values differ by at most 1.
       For the empty list, Λ is always true regardless of the condition.

#¹mo→→  Check last vertex.
  mo    Map
    →→  Last element of last element.
#¹      Count occurrences of n.
        The defaults work as with the initial vertex.

R+gtools, 147 bytes
n=scan();m=3*n;`if`(!n,1,sum(apply((p=permutations(m,m,complex(m,rep(1:n,e=3),1:3)))[Re(p[,1])<2&Re(p[,m])==n,],1,function(x)all(abs(diff(x))<2))))

Try it online!
Tests all permutations of coordinates as complex numbers, and counts those that start with Re=1, end with Re=n, and for which all steps have an absolute value less than 2.
I felt that I couldn't consider myself a 'real' code-golfer unless I'd submitted a ridiculously-inefficient 'brute-force' answer that would time-out with anything except the shortest input...
Completes on TIO for n up to 3.


text:
Distributive on myself
Background
We all know about distributivity, i.e. \$a(b+c) = ab + ac\$. This is a property on 2 different operations, namely addition and multiplication. But indeed, nothing can stop us from studying distributivity of 1 operation. In this challenge, you will be studying a kind of left-distributive operation.
Task
Given a positive integer \$N\$. Consider an operation \$p \star q\$ where \$p, q\in\{0, 1,\dots, N-1\}\$, such that \$ p \star 1 \equiv p + 1 \pmod N\$ and \$p \star (q \star r) = (p \star q) \star (p \star r)\$. In essence, you are making an \$N\times N\$ table. For instance, if \$N = 4\$, a possible \$\star\$ is:
⋆ q 0 1 2 3
p-+---------
0 | 0 1 2 3
1 | 0 2 0 2 ←
2 | 0 3 0 3
3 | 0 0 0 0
      ↑

Note that the marked column satisfies \$ p \star 1 \equiv p + 1 \pmod N\$. In this challenge, we are interested in the marked row. It seems to be periodic, and the challenge is to find its period. The smallest positive period for a sequence \$a_0, \dots , a_{N-1}\$, is defined to be the smallest positive integer \$k\$, such that \$k\$ divides \$N\$, and \$a_i = a_{i + k}\$, for \$i=0..(N-k-1)\$.
However, there may be many possible \$\star\$'s for a given \$N\$, or there may be none. So you need to compute the (smallest positive) periods for all of them.

Task: given a positive integer N, compute all the possible smallest positive periods of 1 ⋆ q. This is code-golf.

Details and clarifications
In the case N = 4, the given table turns out to be the only possible one, so you should output a list (or a set, etc.) consisting only of the number 2. But for N = 3, no operation satisfies all the requirements, so you can output an empty list, or 0, or some falsy value.
The smallest positive period will always be between 1 and \$N\$, if the sequence 1 ⋆ q (0 <= q < N) doesn't repeat at all, it is of period \$N\$.
N will range from 1 to \$2^{32}-1\$. So it is almost kolmogorov-complexity. But note that a formula or recurrence relation of this is unknown.
Test cases
In : N = 1
Out: [1]

In : N = 2
Out: [1]

In : N = 3
Out: []

In : N = 4
Out: [2]

@Arnauld Yeah, I originally planned to require the output each period seperated by spaces for each N=1..1024, seperated by newlines. Later I decided to take input, and enlarge the upper limit. Forgot to change the tag.

Do you have any test cases for N>4?

Shouldn't the output for n=2 be [1]? The only possible operation has the table 0 1 \\ 0 0, and 0 0 has period 1.

Such an operation can only exist when N is a power of 2.

@att Why can it only exist for N a power of 2?

@att whoops, yep

https://oeis.org/A098820

Python 2, 113 bytes
N=input()
f=lambda p,q:f(f(p,q-1),-~p%N)if p*q else q
print([i for i in range(1,N)if N%i+f(1,i)<1]+[N])[:N&N-1<1]

-2 bytes thanks to @Jakque
Try it online!
The short, recursive approach is slow since it repeats computation of many entries, so I've made an iterative, memoized approach which is much faster (quadratic in N) and can compute up to N=4096 within 60 seconds on TIO.
How it Works
The algorithm assumes that \$\star\$ is unique, if it exists (proof below). It uses recursion, setting
\$p\star q=\begin{cases}
q, &p=0 \\
p+1 \mod n, &q=1 \\
(p \star (q-1 \mod n))\star (p+1 \mod n), &\text{otherwise}
\end{cases}\$
The first case (\$p=0\$) is Lemma 1 in the uniqueness proof: \$0\star q=q\$.
The second case (\$q=1\$) is given.
The third case has a simple proof despite its complex self (assuming addition and subtraction are mod \$N\$:
\begin{align*}
&p \star q\\
=&p \star ((q-1)+1) \\
=&p \star ((q-1)\star 1) \\
=&(p \star (q-1))\star(p\star 1) \\
=&(p \star (q-1))\star(p+1)
\end{align*}
This is enough to determine the unique \$\star\$ (The proof shows that the third case will not recurse indefinitely).
The period is the minimum \$i\$ such that \$1\star (i+1) = 1\star 1 = 2\$. If this \$i\$ doesn't divide \$N\$, then it is not a period.
Ungolfed code:
# f(p,q,N) = p⋆q
def f(p,q,N):
    if p==0:
        return q
    if q==1:
        return (p+1)%N
    return f(f(p,(q-1)%N,N),(p+1)%N, N)

def period(N):
    if any(f(p,f(q,r,N),N) != f(f(p,q,N),f(p,r,N),N) for p in range(N) for q in range(N) for r in range(N)):
        # The f does not exist
        return []
    for i in range(1, N):
        # period is i if f(1,i+1)=f(1,1)=2
        if f(1,i+1,N) == 2:
            # might not be divisible, in which case it is not the period
            if N%i:
                return [N]
            return [i]

This could be sped up immensely by memoization utilizing \$ a \star 2 = a \star (1 \star 1) = (a\star 1)\star (a\star 1) = (a+1)\star(a+1) \$ and \$1 \star a = (1\star (a-1))\star 2\$.
Proof of Uniqueness of \$\star\$
For this section, we assume all addition/subtraction is mod \$N\$.
Lemma 1: For all \$a\$, \$0 \star a = a\$
Proof: Induction
Base case: \$a=1\$. Given since \$0\star 1=1\$.
Step: Assume this lemma holds for \$a=k\$. Then \begin{align*}
&0 \star (k + 1)\\
=&  0\star (k\star 1) \\
=& (0\star k)\star (0\star 1) \\
=& k \star 1 \\
=& k+1,
\end{align*}
so this holds for \$a=k+1\$. Since this addition is mod \$N\$, this will "wrap around" back to \$0\$, so it applies for \$a=0\$ too, not just \$a\geq 1\$
Theorem: If an operation \$\star\$ is valid for a given \$N\$, then it the unique \$\star\$ that is valid for that \$N\$.
Proof: We use strong induction to show that, for all \$0\leq a,b\leq N-1\$, \$a\star b\$ is uniquely determined by \$N\$. In addition, for each \$a\$ and \$b\$ in the same set, either (1) \$a\star b=0\$ or (2) \$a<a\star b<N\$

Base case: \$a\star b\$ is uniquely determined and equal to \$0\$ for \$a=N-1\$ and for all \$b\$.
We prove this base case with induction too.

Base case: \$b=1\$. We are given \$a\star 1=a+1\$, so \$(N-1)\star 1=0\$, uniquely determined.
Step: Given \$(N-1)\star b=0\$ for \$b=k\$, then
\begin{align*}
      &(N-1)\star (b+1)\\
      =&(N-1)\star (b\star 1)\\
      =&((N-1)\star b)\star((N-1)\star 1)\\
      =&0\star0 \\
      =&0,
    \end{align*}
where we use Lemma 1 to show \$0\star 0=0\$,
so \$(N-1)\star b\$ is uniquely determiend to be \$0\$.

Assume \$a\star b\$ is uniquely determined and either (1) or (2) hold for all \$k<a\leq N-1\$ and for all \$b\$. Then for \$a=k\$, we will show \$a\star b\$ is uniquely determined and either (1) or (2) hold for all \$b\$, again with induction.

Base case: \$k\star b\$ is uniquely determined and either (1) or (2) hold for \$b=1\$. This is trivial since \$k\star 1=k+1>k\$, so \$k\star 1\$ is unique and (2) holds

Step: Assume \$k\star b\$ is uniquely determined and either (1) or (2) hold for \$b=j\$. Then:
\begin{align*}
      &k\star (b+1)\\
      =&k\star (b\star 1)\\
      =&(k\star b)\star(k\star 1)\\
      =&(k\star b)\star(k+1)
    \end{align*}
If (1) holds, then \$k\star b=0\$, so \$k\star(b+1)=k+1>k\$ by Lemma 1. Thus \$k\star(b+1)\$ is uniquely determined and satisfies (2).
If (2) holds, then \$k<k\star b\leq N-1\$,so by the outer inductive assumption, \$k\star(b+1)=(k\star b)\star (k+1)\$ is uniquely determined and either (1) or (2) holds for it.
In either case, \$k\star(b+1)\$ is uniquely determined and either (1) or (2) hold for it, completing the inductive step.

(p+1)%n => -~p%n for -2 bytes

@Jakque updated

Wolfram Language (Mathematica), 106 90 42 bytes
AtomQ@#&&2^Tr@UnitStep[#-{2,3,5,9}]&@*Log2

Try it online!
Returns the period if it exists, or False otherwise.
Laver Tables exist iff \$N\$ is a power of 2. The sequence of periods is A098820 on the OEIS.
Assuming the l3 rank-into-rank cardinal exists, it's been shown that the first \$N\$ for which the period is greater than 16 is at least \$2^{A(9,A(8,A(8,255)))}\ggg2^{31}-1\$, where \$A\$ is the Ackermann function. John Baez has a relatively accessible layman's explanation here.

Is there supposed to be a nonprintable U+F4A1 in the middle of your answer?

@Neil yes: Mathematica uses it for \[Function]; it's used here to enable recursion on the row-computing function with #0 (this is the function called on1-#). The function on r computes (a*(b+1))=((a*b)*(a+1)) from r=a*b.

Well, its presence seems to completely confuse Firefox 77 for some reason...

source: Stack Exchange

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

sort: votes


text:
Music with pi and e
Because I forgot to celebrate Pi Day (14.3), let's celebrate with \$\pi\$, \$e\$ (Euler's number) and music!
Challenge
No,  we don't have time to eat a pi-pizza, let's make a program.
What you need is \$500\$ digits of \$\pi\$, and \$10\$ digits of \$e\$.
The input is an integer \$n\$ between \$0\$ and \$499\$ inclusive.
Then you should loop through the first \$n\$ digits of \$\pi\$:
If the digit is:

\$0\$ then the note is C
\$1\$ then the note is D
\$2\$ then the note is E
\$3\$ then the note is F
\$4\$ then the note is G
\$5\$ then the note is A
\$6\$ then the note is B
\$7\$ then the note is C'
\$8\$ then the note is D'
\$9\$ then the note is E'

Next, for each digit in \$\pi\$, take a digit from \$e\$ based on this mapping:

If the digit from \$\pi\$ is \$0\$, take the \$1\$st digit from \$e\$
If the digit from \$\pi\$ is \$1\$, take the \$2\$st digit from \$e\$
If the digit from \$\pi\$ is \$2\$, take the \$3\$st digit from \$e\$
etc.

You need only \$10\$ digits of \$e\$, because the digits in \$\pi\$ are between \$0\$ and \$9\$.
Finally, take the note and the digit from \$e\$. Return a tuple (or equivalent) containing:

the note
the \$e\$ digit divided by \$4\$ (representing the beat)

Test cases
In:10
Out:
('D', 0.25)
('G', 2.0)
('D', 0.25)
('A', 0.25)
("E'", 1.0)
('E', 2.0)
('B', 2.0)
('A', 0.25)
('F', 0.5)
('A', 0.25)
In:5
Out:
('D', 0.25)
('G', 2.0)
('D', 0.25)
('A', 0.25)
("E'", 1.0)

Help
Here are \$500\$ digits of \$\pi\$:
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912

And \$10\$ digits of \$e\$:
2.7182818284

Note that '3.' and '2.' don't count in the digits of \$\pi\$ and \$e\$, and that we are using \$0\$ indexing (so the \$0\$th digit of \$\pi\$ is \$1\$ etc.).
Rules

This is code-golf so the shortest answer wins.
Optional; After every tuple or list output, there can be a trailing newline.

As one week is over, here is an ungolfed code in Python 2:
Python 2, 526 bytes
def music_maker(n):
 i=p=1;x=3*100**n
 while x:x=x*i/-~i/4;i+=2;p+=x/i
 pi_number=str(p)[:-1] #First 3 lines calculates Calculate Pi
 euler='7182818284'
 del x,i,p #You don't need those Variables any more. They were ment for calculating
 for i in range(n):
  current_pi = pi_number[i] #Current Pi
  current_e = euler[int(current_pi)] #Current e
  number_to_note = {0:"C", 1:"D",2:"E",3:"F",4:"G",5:"A",6:"B",7:"C'",8:"D'",9:"E'"} #Dict number to note
  print((number_to_note[int(current_pi)], int(current_e)/4)) #Prints result

Try it online!

Here's a dict:{0:"C", 1:"D",2:"E",3:"F",4:"G",5:"A",6:"B",7:"C'",8:"D'",9:"E'"}

Great, it looks ok now, so I've upvoted and deleted my comment. :)

@KevinCruijssen Thanks. I didn't get replies for those 2 mistakes in the sandbox.

Made Euler's number lower case, feel free to revert my edit if you don't like it.

@Noodle9 Thanks for the edit!

I've edited the question to try to improve the formatting, as well as try to make it slightly clearer, as it came up for review in the Close Votes queue. If you don't like the changes I've made, please feel free to rollback, or edit it yourself

What is C'? Is that a sharp?

@cairdcoinheringaahing Thank you very for the edit. It looks awesome and mathematically like now.

@mbomb007 No, it's not; it's C one octave higher. C♯ is C sharp.

@mbomb007  See Helmholtz pitch notation on Wikipedia.  C is an octave below middle C.  C' is middle C.

Need clarification: you say that this is to use 0 based indexing, so an input of 0 would result in 1 note output, but your examples use 1 based indexing (input of 10 yields 10 results), so which is it?

@Xcali Then it's also the same. If input pi-digit is 0 then your note is C... And if your pi-digit is 0 take the 1 e-digits...

Will we be able to hear what it looks like?

@Kaddath I tried in Python 3 to play Music, but it didn't work. Can anybody do this?

@cairdcoinheringaahing Normally, after how much Time shall I declare a winner for this question?

@Tanmay for code-golf it's not ogligatory to declare a winner, as there are multiple languages that obviously cannot compete in length (while still pretty interesting to golf), but if you want to accept one, usually it's recommended to wait at least a week. But don't forget to upvote any number of answers you think deserve it!

@Tanmay That's not the question.  The question is, when the input is 0, how many notes do I output?  When the input is 4, how many notes do I output?

"Xcali When the input is 0, output 1 note. When input is 4 output 5 notes. This will just make 2 or 3 bytes longer(in a ""normal"" language)

@Kaddath Edit to your comment: Will we able to hear what it hears like? ;D

05AB1E, 33 30 bytes
LεAuS7£ÀÀD3£''««žsyè©èžt¦®è4/‚

Outputs as a list of pairs in the ["string-note", beat-decimal] format.
Try it online.
Explanation:
L                # Push a list in the range [1, (implicit) input]
 ε               # Map each integer to:
  Au             #  Push the uppercase alphabet
    S            #  Convert it to a list of characters
     7£          #  Only leave the first 7: ["A","B","C","D","E","F","G"]
       ÀÀ        #  Rotate it twice towards the left: ["C","D","E","F","G","A","B"]
         D       #  Duplicate it
          3£     #  Only leave the first 3 character of this copy: ["C","D","E"]
            ''«  #  Append a "'" to each: ["C'","D'","E'"]
               « #  Merge the two lists together:
                 #   ["C","D","E","F","G","A","B","C'","D'","E'"]
  žs             #  Push an infinite list of pi-digits: [3,1,4,1,5,...]
    yè           #  Index the current integer into it (0-based, so leading 3 is skipped)
      ©          #  Store it in variable `®` (without popping)
       è         #  Index this pi-digit into the notes string-list
  žt             #  Push an infinite list of e-digits: [2,7,1,8,2,...]
    ¦            #  Remove the leading 2
     ®           #  Push the pi-digit from variable `®`
      è          #  Index it into the infinite list of decimal e-digits
       4/        #  Divide it by 4
  ‚              #  Pair the pi-note and e-digit/4 together
                 # (after which the resulting list of pairs is output implicitly)

JavaScript (Node.js),  150 ... 134  133 bytes
Saved 3 bytes thanks to @KevinCruijssen
Expects a BigInt as input and prints the music to STDOUT. This also works for \$n>500\$.
n=>{for(k=p=1n,x=3n*100n**n;x;p+=x/k)x=x*k++/k++/4n;for(;x<n;)console.log('CDEFGABCDE'[d=(p+'')[x++]]+" '"[d/7|0]+'7182818284'[d]/4)}

Try it online!
How?
Part 1: compute \$n\$ digits of \$\pi\$
This is based on the following formula:
$$\pi-3=\sum_{n=1}^{\infty}\frac{3}{4^n}\left(\prod_{k=1}^{n}\frac{2k-1}{2k}\right)\times\frac{1}{2n+1}$$
Instead of using floats -- whose precision is obviously far too limited -- we use a Big Integer \$x\$ initialized to \$3\$ times a large enough power of \$10\$ and process integer divisions until we have \$x=0\$.
For 500 digits, we could just use \$x=3\cdot10^{503}\$. We instead start with \$x=3\cdot100^n\$, which is more than enough to get \$n\$ correct digits and easier to golf.
for(                    // loop:
  k = p = 1n,           //   start with k = p = 1
  x = 3n * 100n ** n;   //   start with x = 3 * 100 ** n
  x;                    //   stop when x = 0
  p += x / k            //   add x / k to p after each iteration
)                       //
  x =                   //   update x to:
    x * k++ / k++ / 4n  //     x * k / (k + 1) / 4 (and increment k twice)

Part 2: convert to music notes
for(; x < n;)           // repeat as many times as requested:
  console.log(          //   print:
    'CDEFGABCDE'[       //     string of notes
      d = (p + '')[x++] //     d = x-th digit of pi, extracted from p
    ] +                 //
    " '"[d / 7 | 0] +   //     append a quote if d is greater than or equal to 7,
                        //     or a space otherwise
    '7182818284'[d]     //     get the d-th digit of e (using Math.E would be longer)
    / 4                 //     and divide it by 4 for the beat
  )                     //   end of console.log()

-3 bytes by removing k=0 and reusing x in the second part, since it's already 0 after the loop in the first part: 134 bytes.

Perl 5 -Mbignum=bpi, 86 84 bytes
say+(C..G,A..E)[$_],"'"x($_>6),$",((exp 1)=~/./g)[$_+3]/4for(substr bpi<>+1,2)=~/./g

Try it online!
How?
for               # loop over
  (substr         # a substring of
     bpi<>+1,     #   PI to the appropriate number of decimals
     2)           #   starting after the second character
  =~/./g          # split into characters

    say+              # output
      (C..G,A..E)[$_],  # the note letter
      "'"x($_>6),       # a ' if it is in the next octave higher
      $",               # a space
      ((exp 1)          # Euler's number
       =~/./g)           # split into characters
       [$_+3]            # skipping the first 3 (2.7)
       /4                # divided by 4 beats

Wolfram Language (Mathematica), 97 bytes
Print[C[D,E,F,G,A,B,"C'","D'","E'"][[#]]|R[E,10,2+#][[1,-1]]/4]&/@#&@@R[Pi,10,#,-1]&
R=RealDigits

Try it online!
Prints notes as [key] | [duration], with one note per line.
Since Mathematica's number->string functions are so bulky (FromCharacterCode, anyone?), hardcoding the keys' names as symbols seems to be shorter.

Charcoal, 52 bytes
Ｐ×φψ¤≕Pi→→≔ＥＫＤＮ→Ｉιθ⎚Ｅθ⁺⁺⁺§…α⁷⁺²ι×'›ι⁶ ∕Ｉ§⪫74×²1828ι⁴

Try it online! Link is to verbose version of code. Actually works up to n=998. Explanation:
Ｐ×φψ¤≕Pi

Charcoal apparently has a built-in for π, but unfortunately the only way I know how to use it is copied from the Charcoal answer to Bake a slice of Pi which involves using it as a flood fill. Here I just output 1,000 null characters which therefore gives me 998 decimals of π, well above the 499 required by the challenge.
→→≔ＥＫＤＮ→Ｉιθ

Now input the number of decimals required, read them from the canvas, and convert them to integers.
⎚

Clear the canvas ready for the actual output.
Ｅθ⁺⁺⁺

Map over the digits and concatenate...
§…α⁷⁺²ι

... the first 7 letters of the uppercase alphabet, cyclically indexed by 2 more than the digit...
×'›ι⁶

... an ' if the digit is greater than 6...

... a space...
∕Ｉ§⪫74×²1828ι⁴

... and the appropriate digit divided by 4, taken from the string 7182818284, constructed by doubling the string 1828 and inserting it into the string 74.

Python 2, 173 164 162 156 150 149 143 141 bytes
def f(n):
 i=p=1;x=3*100**n
 while x:x=x*i/-~i/4;i+=2;p+=x/i
 while x<n:i=int(`p`[x]);print"CDEFGAB"[i%7]+"'"[i<8:],1907986849/9**i%9/4.;x+=1

Try it online.
Prints the pairs newline-delimited to STDOUT in the format string-note beat-decimal (space-delimited).
Port of @Arnauld's JavaScript answer, so make sure to upvote him!
-6 bytes thanks to @ovs, which opened up -6 more bytes by switching to Python 2
-1 byte thanks to @Arnauld
-2 bytes thanks to @Tanmay

You don't need the second colon in the slice without a step and 1907986849//9**d%9/4 is a little shorter than int('7182818284'[d])/4.

Also reducing the number of assignment expressions doesn't hurt: Try it online!

@ovs Thanks! Now that I don't use := as much anymore, it's also shorter in Python 2 with int(`p`[k]) and regular / instead of //.

159 bytes

@Noodle9 ? Did you forgot to update the page when you made that comment or was there some sort of delay? I'm already at 143 bytes when you made your 159 bytes comment. ;)

@Tanmay Thanks for the -1 byte (and an additional -1 by removing the space between print"). :) But next time please leave a comment with the golfing suggestion instead of editing someone else's answer.

Guess we were out of sync somehow - did it on my phone. :(

@Kevin Thanks. I did not know how to do propose a golf.

Vyxal, 29 bytes
ƛkAf7Ẏ2Ǔ:3Ẏ\'vJJn∆iin∆i›∆ė4/"

Try it Online! or Run both test cases!
Port of 05AB1E. If it can't output rationals instead of decimals, add øḋ before ". Then it will be as strings.
How?
ƛkAf7Ẏ2Ǔ:3Ẏ\'vJJn∆iin∆i›∆ė4/"
ƛ                              # For each item `n` in the (implicit) inclusive one range of the (implicit) input
 kA                            # Push the uppercase alphabet
   f                           # Convert to list of characters
    7Ẏ                         # Leave only the first seven letters: ["A","B","C","D","E","F","G"]
      2Ǔ                       # Rotate left twice: ["C","D","E","F","G","A","B"]
        :                      # Duplicate
         3Ẏ                    # Leave only the first three letters of the duplicate: ["C","D","E"]
           \'vJ                # Append a single quotation mark to each letter: ["C'","D'","E'"]
               J               # Join these two lists together: ["C","D","E","F","G","A","B","C'","D'","E'"]
                n∆i            # Get the `n`th (zero-indexed) digit of pi
                   i           # Index this into the list of notes
                    n∆i        # Get the `n`th pi digit again
                       ›       # Increment it
                        ∆ė     # Get the zero-indexed E digit from that
                          4/   # Divide by four
                            "  # Pair the pi-note and e-digit/4 together

perl -MMath::BigFloat -pl, 170 bytes
$n=$_;$p=new Math::BigFloat;$p->accuracy(500);$_=$p->bpi;s/..//;s!.!'('.substr(CDEFGABCDE,$&,1).("'"x($&>6)).', '.((substr 7182818284,$&,1)/4).")\n"!eg;/(.+\n){$n}/;$_=$&

Try it online!
How does this work?
$n = $_;

This gets the input (which is in $_ due to the -p switch; the -l switch removes the newline).
$p = new Math::BigFloat;
$p -> accuracy (500);
$_ = $p -> bpi;
s/..//;

This gets us the 500 required digits from \$\pi\$. First we create a Math::BigFloat object, give it an accuracy of 500 (so, 500 decimals behind the comma). We then query the object to get \$\pi\$, which we store in $_. And we then remove the first two characters, to set rid of the leading 3..
s !.!
  '(' .    substr (CDEFGABCDE, $&, 1) . ("'" x ($& > 6)) .
  ', ' . ((substr  7182818284, $&, 1) / 4) .
  ")\n"
  !eg

This does the majority of the work. We take each digit of \$\pi\$ and replace it with the result of the middle three lines of code above. During the replacement, the digit being replaced is in $&. We start with an opening paren, then we look up the note by using the current digit as in index into a string (substr (CDEFGABCDE, $&, 1). If the digit is greater than 6, we need to add a prime (("'" x ($& > 6))). We then add a comma. Then, to get the beat, we index into the digits of \$\epsilon\$, and divide by four (((substr  7182818284, $&, 1) / 4)). Finally, we add an closing paren and a newline.
/(.+\n){$n}/;
$_ = $&

This trims the resulting string to the desired length. We're grabbing n times a group of non-newline characters followed by a newline character, and store the result into $_, which gets printed due to the -p command line switch.

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


text:
Solve a 2xN Maze
Given a \$2\times N\$ maze, determine if you can get from the start top left corner to end bottom right corner using only up, down, left, and right moves.
Input
A \$2\times N\$ block (\$1 \le N \le 100\$) of your choice of two distinct characters, one representing walls and the other representing empty tiles that can be moved through. You may use any reasonable input format, ex. one string with newline, two strings, or two lists of characters, or a binary matrix.
It is guaranteed the start and end positions are empty tiles.
Output
Truthy or Falsey value indicating if the maze is solvable.
Examples
In these test cases, x represents wall and . represents empty tile.
True cases
.
.

..
x.

.x
..

...
...

..x
x..

....
..x.

.x...x...
...x...x.

...xx.....x
xx.....xx..

False cases
.x
x.

.x.
.x.

.xx
xx.

.xxx.
..x..

..x.
xxx.

.xx.x..
..xx...

.....x.x.
xxx.x....

....xx.xxx
.....xxx..

I think this is equivalent to "check that no two x's touch diagonally or vertically".

@xnor are you sure?

idk if I should allow taking in as one long string of even length.

Probably yes, I think...

What freedom is there with the output? Can we output truthy for non-solvable and falsy for solvable? Need the truthy / falsy values be two unique values, or can we for example output 2, -1, 3 as truthy values for differnet outputs?

@LuisMendo I think that is a codegolf meta question and language dependent. https://codegolf.meta.stackexchange.com/questions/2190/interpretation-of-truthy-falsey So it's reasonable to have 0 be truthy and all other integers be falsey, but I am hesitant to allow arbitrary numbers to be chosen as truthy and falsey.

There is strong consensus that you can't just define say 0 to be truthy and other integers falsy, or any arbitrary choice. Rather, it depends on how an if branch in your language treats those numbers. My questions were: do the output values need to be two unique values, or can there be more than two possible outputs? And, can we use truthy for non-solvable and falsey for solvable?

it's language specific... if your outputs in your language have a way to evaluate the output as conditional, then it is fine. I think inverted outputs is ok too but you should mention it.

Is two numbers representing the bit sequences a reasonable format?

@xnor yeah that's ok

can we take the input as vertical format? (2 columns wide)?

3xn or 4xn might be interesting as a separate challenge, which is more complex than 2xn but it is still guaranteed to have a non-backtracking path on any solvable maze.

@Bubbler yes I definitely thought about it. and counting the number of solvable mazes is also interesting

@LevelRiverSt sure

@LuisMendo That is the common practice for exit values of programs -- 0 is success, anything else is a failure.

Can we take the input in two different formats, e.g. first one as x. and the second as 01?

is input always "horizontal" like in examples? can I make them vertical instead?

Suggested test case: x\nx. I had an answer that was wrong on this and only this.

@xigoi not valid test case - start and end are guaranteed to be empty.

Suggested test case: row 1=.x.., row 2=..x.

I'm not going to finish this, because Retina can be solved in 10 bytes using the Regex answer, but another interesting way to solve this is the duplicate the input, and then shift the 3rd row over 1, and the 4th over 2. Then if any x's are adjacent vertically, it's not solvable. This method eliminates diagonals. https://tio.run/##K0otycxLNPz/X4Xr0DY9FVsuPW0VLj09FYP///XAoAKGuCoqIAwoBgA

@mbomb007 You should finish it and post. You were working on a $2$ row $N$ column solution, and surely that will be shorter than the 29 byte regex solution.

@Deadcode It's still longer because I still have to use balancing groups to find if there's a pair of adjacent x's or not.

@mbomb007 What if you remove the beginning character of both lines one at a time until the blockage is at the beginning of both lines? Then you wouldn't need balanced groups.

@Deadcode Already tried it. It's much longer, and you have to check the duplicated lines at the same time as well, not just two. :/

APL (Dyalog Unicode), 8 bytes
∧/⍲⌿2∨/⎕

Try it online!
Takes input from stdin as a 2-row boolean matrix, where 1 is a wall and 0 is a space. Prints 1 for true, 0 for false (which are the only truthy/falsy values in APL).
How it works
Given a maze (1=wall, 0=space)
0 0 1 0 0 0 1
1 0 0 1 1 0 0

Think of putting a bar between every two horizontally adjacent cells, where at least one side must be a wall (1):
0   0 | 1 | 0   0   0 | 1
1 | 0   0 | 1 | 1 | 0   0
          ^

Then the maze has a solution if and only if no two bars align vertically, as pointed above.
∧/⍲⌿2∨/⎕
       ⎕  ⍝ Take input from stdin
    2∨/   ⍝ Compute the "bars" in the above diagram,
          ⍝ by ORing every two horizontally adjacent bits
  ⍲⌿      ⍝ Compute NAND of the two bars vertically;
          ⍝ each column is passable unless both rows are 1
∧/        ⍝ Reduce by AND; check if all columns are passable

That is a clever solution! I would think inserting the walls would take more code than it actually does.

Python 2, 26 bytes
lambda m,n:m&(n/2|n|2*n)<1

Try it online!
Takes inputs as numbers representing bit sequences, which the challenge author okayed. Though I realized this representation is kind-of suspect because leading zeroes are ambiguous.
The idea is to check whether any 1 in the top number (x symbol in the top line) corresponds to a 1 in any of the three adjacent positions in the below number. We do this by "smearing" each bit the bottom number n in three positions as n/2|n|2*n, or-ing the number with its left and right shift.
It would also work to do (m|m*2)&(n|n*2)<1, but precedence means more parens are needed.

nice solution. I guess you could do the same in C with a 128 bit integer type.

Ruby, 29 28 bytes
->t,b{"#{t+2*b}"!~/45|54|6/}

Try it online!
Takes input as two integers, t and b, each representing a row of the maze, with digits 1 representing empty tiles and 2 representing walls. Returns false if t+2*b contains the digits 45 or 54 (two walls touch diagonally) or 6 (two walls touch vertically). Returns true otherwise.
It's possible to get down to 22 bytes by porting @xnor's very elegant Python 2 answer:
Try it online!

Nice approach, though I don't think it enforces the rule start top left corner to end bottom right corner; e.g. I think "x\n." should fail, but it passes.

@DigitalTrauma That's not a valid maze for this challenge: 'It is guaranteed the start and end positions are empty tiles.'

I love this approach.  Well done.

@Dingus - right - yes - sorry, I missed that bit

Regex (POSIX ERE / RE2 or better), 13 10 bytes
x(|
|.
.)x

Try it online! - POSIX ERE
Try it on regex101 - RE2
Try it online! - ECMAScript
Try it online! - .NET
The problem statement didn't say anywhere that there specifically had to be \$2\$ rows and \$N\$ columns rather than \$2\$ columns and \$N\$ rows, or that the input can't be taken in transposed form.
So here is a solution that works on virtually any regex engine. Like A username's answer, this matches iff the maze is not solvable. The wall character is x, and empty tiles can be represented by any other character.
Regex (POSIX ERE / RE2 or better), 33 30 27 bytes
^((''
|^)(('.
)*|(.'
)*))*$

Try it online! - POSIX ERE
Try it on regex101 - RE2
Try it online! - ECMAScript
Try it online! - .NET
This is version that matches solvable mazes and doesn't match unsolvable mazes. It was interesting to implement in a regex flavor that has no negative lookahead. The way it works is pretty much like actually walking through the maze and solving it.
The empty tile character is ', and walls can be represented by any other character. The input given to this regex must not begin with a newline, and must end with a single newline.
The version of POSIX ERE on TIO treats newlines incorrectly in this version, even though with REG_NEWLINE not set, newline is supposed to be treated like any normal character. So in the ERE test harness, I made it use ! as a line separator instead of newline. But when tested locally on my machine, it works with actual newlines.
Regex (GNU ERE or better), 29 24 bytes
^((''
|^)(.?'.?
)?\3*)*$

Try it online! - GNU implementation of POSIX ERE, old version
Try it on regex101 - ECMAScript
Try it online! - ECMAScript
Try it online! - .NET
The addition of backreferences allows for a more compact regex. But there doesn't seem to be a clear-cut standard that includes backreferences without lookaheads. The closest appears to be GNU ERE, used by egrep and sed -E, but there doesn't seem to be any library interface for it, and neither of those utilities support matching raw newlines.
The version of GNU libc on TIO enables backreferences in ERE, but with an up-to-date version of the libraries, they're only enabled in BRE, not ERE. The version on TIO has the newline bug, though, so same workaround for newlines is used in the TIO test harness.
The empty tile character is ', and walls can be represented by any other character. Matches iff the maze is solvable. The input given to this regex must not begin with a newline, and must end with a single newline.
Regex (ECMAScript or better + /s flag), 17 bytes
^(?!.*x(|
|.
.)x)

Try it on regex101 - ECMAScript 2018
Try it online! - ECMAScript 2018
Try it online! - .NET
With negative lookahead it is trivial to modify the 10 byte regex into one that matches iff the maze is solvable.
As in the regex it's based on, the wall character is x, and empty tiles can be represented by any other character.
Note that the /s flag was introduced in ECMAScript 2018 (JavaScript ES9).
Regex (Perl / Java / PCRE2 / .NET), 29 bytes
^(.(?=.*
(\2.|)))+x.*
\2.?.?x

Try it online! - Perl
Try it on regex101 - PCRE2
Try it online! - .NET
This takes the input in the form of \$2\$ rows of \$N\$ columns. The challenge just wouldn't be complete with that submitted only in .NET flavor and not PCRE as well. Matches iff the maze is not solvable. The wall character is x, and empty tiles can be represented by any other character.
The .NET balanced group method is still shorter (at 27 bytes), as expected.
This solution takes advantage of the fact that the upper-left corner will never be blocked. It would need to be modified otherwise, because it looks for a wall in the top row that has a wall diagonally or orthogonally below it. It starts this search at the second column from the left.

J, 19 17 bytes
0=1#.[:,*&#./;._3

Try it online!
-2 thanks to Bubbler for suggesting Max Cubes instead of subarrays.
A port of Bubbler's APL solution saves 1 byte:
2 e.[:+/2+./\"1]

but it seemed a shame not use J "Max Cubes" here, as the problem seems almost tailor-made for it.
How
Let's take the example:
0 1 1 1 0 0
0 0 0 0 1 0

v;._3 will apply the verb v to every 2x2 block.  Eg, <;._3 will produce:
┌───┬───┬───┬───┬───┐
│0 1│1 1│1 1│1 0│0 0│
│0 0│0 0│0 0│0 1│1 0│
└───┴───┴───┴───┴───┘

In our case, we want a verb that detects "walls" (diagonal or vertical).  */@:#. does the job.  It converts each row from a binary number into an integer #., and then multiplies the resulting 2 integers together */@:.  This result will always be 0 if there is no wall.
So now we can just sum all of the results 1#. and check if the result is 0 0=.  If it is, there are no walls and we can get through.  Otherwise, we're blocked.

17 bytes for the top solution by using MaxCubes instead.

@Bubbler thanks, updated.  but why did you way "top solution"?  there are still some others including yours quite a bit shorter, no?

Snails, 7 bytes
Based on @xnor's observation, this checks if there are xs above (u), below (d) or diagonally from (y) another x. Returns 0 for solvable mazes a positive integer otherwise. I've wanted to use this language for so long!
\xudy\x

Try it online!
Explanation
Snails is a 2D pattern matching language that was created by @feresum which is not entirely unlike regex.
In this program, the \x matches a literal x, then looks above, below or diagonally to it (udy) for another literal x (\x).

As I remembered that challenge from years ago, I was looking for this language in the answers.

MATL, 10 9 7 bytes
4&1ZI2<

Input is a binary matrix, with 1 for . and 0 for x.
Output is an array of ones (which is truthy) if the maze is solvable, or an array containing at least a zero (which is falsey) if not solvable.
Try it online! Or verify all test cases including check for truthyness or falsiness.
Explanation
Solvability is equivalent to full connectedness of all non-wall tiles
The maze is solvable if and only if all non-wall tiles are connected to each other using 4-neighbourhood.
Proof
All connected ⇒ solvable: this is clear.
Solvable ⇒ all connected. Let the maze be
A ··· SUWY
B ··· TVXZ

This maze is solvable by assumption. Consider its rightmost square of size 2:
WY
XZ

There are two ways that Z can be connected to the input:

Through tiles W and Y: this means that W and Y are non-wall. They are connected to Z.  If X is non-wall it is connected to W, Y and Z too.
Through tile X: this means that X is non-wall. It is connected to Z. If W or Y are non-wall they are connected to X and Z too.

We now proceed from either W or X to the left, considering the square
UW
VX

By the same reasoning as above, all non-wall tiles in this square will be connected to each other, and to the tiles from the previous square.
This way we proceed until A is reached (which is possible by hypothesis), and all non-wall tiles are connected.
How the code works
The program checks that the image formed by considering wall tiles as background and non-wall tiles as foreground has a single connected component.
4      % Push 4
&1ZI   % Implicit input: binary matrix. Label connected components using
       % 4-neighbourhood. This assigns a different label to each connected
       % component of ones in the input. Labels are positive integers. The
       % result is a matrix of the same size as the input
2<     % Less than 2? Element-wise. All comparisons will be true if and
       % only if there is a single connected component
       % Implicit diplay

R, 38 bytes
function(t,b)all(c(b[-1],T,b,T,b)[!t])

Try it online!
Checks that the bottom row is 'open' at position x-1, x and x+1 for every 'closed' position in the top row.
How?

consider matrix of 3 rows:

remove first item from bottom row of maze + add 1 at the end
bottom row of maze
add 1 at the start of the bottom row of maze without last item

check that all elements are 1 in columns where top row of maze is 0

Golfing:

R 'recycles' logical indices, so we don't actually need to make a matrix, we can just list the elements
no need to remove the last item of the bottom row of maze since it's guaranteed to be true

R, a different approach, still 38 bytes
function(t,b)all(t&t[-1]|b&c(b[-1],1))

Try it online!
Completely different approach, but annoyingly the same number of characters.
Checks that it's always possible to move rightwards, either on the top or on the bottom.
How?
top & top[-1] = logical AND of each element of top with it's neighbour to the right
| = logical OR
bot & bot[-1] = logical AND of each element of bot with it's neighbour to the right
The last element (that has no rightward neighbour) is a problem, because R 'wraps around' the longer vector, so if the last top element is 0 and the first bottom element is 0 then it will fail.
We can fix this by forcing it to evaluate to TRUE, which we can do by adding a 1 at the end of the 'chopped-off' bottom row (since we know the last element of the full-length row must be 1).

Excel, 38 bytes
=AND(ISERROR(FIND({12,3,21},A1+2*A2)))

Input is 2 strings (1 for each row of the maze), in cells A1 and A2, with 1 for a Wall, and 0 for a space.
First, it adds the first row, and twice the second row together.  This will convert each column to base-4 representation of whether it contains no walls (0), wall in the top row only (1), wall in the bottom row only (2), or wall in both rows (3)
We then try to FIND any examples where there are walls in both rows (3), or walls in different rows of adjacent columns (12 or 21)
If both of these return errors, then there is a clear path

I love it when Excel is able to compete competitively against 'real' programming languages!  Well done.

@DominicvanEssen Are you implying Excel isn't a real programming language? It's turing complete

Regex (.NET), 35 31 27 bytes
^(.)* ?#.*
(?>(?<-1>.)*) ?#

This had to be done. Checks if the string contains one of the following (uses #s and spaces) :
 #
#

#
#

#
 #

Matches impassible grids, doesn't match passible ones.
See Martin Ender's excellent capture group documentation.
Try it online!
Thanks to Deadcode for -9 bytes.

Hm, now I decide if you're a reputatable source :)

Cool to see someone new giving regex answers! So, note that since both rows will always have the same number of characters in them, (?<-1>.)* will always initially match will all copies of \1 popped from the balanced group stack. It can only do so less than the maximum number of times if the regex engine backtracks into it when it tries to make the following # match. So you can save 4 bytes by wrapping it in an atomic group and getting rid of the conditional.

@Deadcode Thanks! I just had a look at the link above and tried to figure it out. I'm not very good at this.

Hint: The (?<-1>.)* is the thing you don't want to be backtracked once it's finished. So wrap it in an atomic group (?>...). And then the (?(1)...|...) conditional is no longer needed; you can remove the conditional, which would now always evaluate its condition as "false" since \1 will now be guaranteed to no longer have any contents by that point, so you can keep its former "false" case and discard its "true" case.

@Deadcode Ok, thanks!

Oops, I completely spaced on the fact that you used (?<1>.)* to do the initial counting! You can save another 4 bytes by simply using (.)*. If you omit a group's name, it's automatically given a number, starting at 1 and incrementing from there for each additional unnamed group. This will make your technique the winning $2$ rows by $N$ columns one (as far as flavors of regex go).

@Deadcode It's not mine, you've been doing the golfing, but sure!

Jelly, 4 bytes
+ƝẠƇ

Try it online!
Takes a list of pairs, where 0 represents a path and 1 represents a wall. Returns a falsy value if the maze is solvable and a truthy value if not.
Jelly, 6 bytes
ḋ×ṛɗ/Ẹ

Try it online!
Takes a list of pairs, where 0 represents a wall and 1 represents a path. Returns 1 if the maze is solvable and 0 if not.

Charcoal, 26 23 bytes
⭆⪫Ｅ²Ｓ¶⎇⁼ι.ψι←¤-Ｊ⁰¦⁰Ｔ¹¦¹

Try it online! Link is to verbose version of code. Takes two strings of .s and xs as input (actually any character other than space or . would work) and outputs - if the maze can be solved or a blank space if it cannot. Edit: Saved 3 bytes because I had misread the question. Explanation:
⭆⪫Ｅ²Ｓ¶⎇⁼ι.ψι

Print the input, but change all the .s to null bytes, since Charcoal knows how to fill those.
←

Move to the end position.
¤-

Flood fill the null bytes with -s (chosen because this is Charcoal's default output character for a Boolean true value, but any character other than space would work).
Ｊ⁰¦⁰

Jump back to the start position.
Ｔ¹¦¹

Delete everything other than the start position, which is now - if the maze could be solved, or blank if it could not be solved.

what do you mean by "it's not clear which the start and end positions are"?

@qwr I must have been too tired... I see it now.

Perl 5 -p0, 67 bytes
$x=$_;$_=!grep{$b=$_-1;$x=~/^.{$b,$_}x.*?\n.{$b,$_}x/gm}1...5*y///c

Try it online!

Wolfram Language (Mathematica), 54 bytes
Max@MorphologicalComponents[#,CornerNeighbors->1<0]<2&

Try it online!
Credit for this idea goes to this answer by alephalpha from a couple years ago, where it used in a different context.
The core insight here is that -- if the maze can be solved -- then the "spaces" form a single contiguous morphological chunk.  And Wolfram has a built-in for detecting that.

Io, 90 bytes
method(x,y,x map(i,v,v>0and(list(i-1,i,i+1)map(c,y at(c abs))detect(>0)))reduce(or)!=true)

Try it online!
Io, 98 bytes
Port of Bubbler's APL solution.
method(x,(o :=x map(o,o slice(0,-1)map(i,v,v+o at(i+1))))at(0)map(i,v,v*o at(1)at(i))push(0)sum<1)

Try it online!

05AB1E (legacy), 7 bytes
Port of @Bubbler's answer.
€ü~øP_P

Try it online!
Explanation
€       Map:
 ü          Apply to pairs:
  ~             OR
   ø    Transpose
    P   Product
     _  NOT
      P Product

Haskell, 53 51 bytes
or.map(or.foldr1(zipWith(&&))).mapM(\x->[x,tail x])

Try it online!
The anonymous function takes a list of two lists where True is a wall and False is empty. Returns False if the maze is solvable.

is the function c or (#)?

Prolog, 99 bytes
f([[1,_],[_,1]|_]):- !,0=1.
f([[_,1],[1,_]|_]):- !,0=1.
f([[1,1]|_]):- !,0=1.
f([_|T]):-T==[];f(T).

Try it in SWISH
xnor's comment that the problem statement was equivalent to checking if no 2 x's touched vertically or diagonally helped me a lot here.

Imperfect version (never terminates if false), 66 bytes
f([X|T],C):-nth0(C,X,0),(T==[];f(T,C);D is mod(C+1,2),f([X|T],D)).

Try it in SWISH
Requires the first input to be a list of length N containing lists of length 2. Empty tiles are denoted by 0, and walls are denoted by anything else (I could also have used characters, I suppose, but this seemed easier). The second input (C) is 0 if we're currently at the tile on top, and 1 if we're at the tile on the bottom.
An example query would be:
?- f([[0,1],[0,1],[0,0],[1,0],[1,0],[0,0],[0,0],[0,1],[0,1],[0,0],[1,0]],0).
true.

However, if the maze is unsolvable, there wouldn't be any output, it'd just keep running.

JavaScript, 63 bytes
n=>k=>!n.filter((e,i)=>e>0&[k[i-1],k[i],k[i+1]].includes(1))[0]

Takes input in currying format, each argument being an array of 1s and 0s. Outputs true if the maze is solvable and false if unsolvable.

Try it online!


text:
Sum the array times n, except the last
I've been posting relatively hard challenges recently, so here goes an easy one.
Task
Given an array \$A\$ and a number \$n\$, calculate the sum of all numbers of \$A\$ multiplied by \$n\$, except the last one. All numbers (the elements of \$A\$ and the value of \$n\$) are positive integers, and \$A\$ is non-empty. Shortest code in bytes wins.
I have a 3-byte J solution. Can you find it (or beat it in a different language)?
Test cases
A           N   Ans   Explanation
3 1 4 1 5   10  95    (3+1+4+1)*10+5
3 1 4 1 5   1   14    (3+1+4+1)*1+5
1           999 1     1

Can we take the list in reverse?

@Third-party'Chef' No.

I wonder if your J solution used mixed base conversion

Can we take the input as numbers instead of a single array?

@HighlyRadioactive Yes, that's fine.

@xnor Unfortunately no. See xash's solution for explanation.

J, 3 bytes
That was fun to find.
&+/

Try it online!
How it works
10 (&+/) 3 1 4 1 5 will bind 10 as an argument of + as 10&+, one verb that gets inserted between the elements of the list by /. So we have: 3 (10&+) 1 (10&+) 4 (10&+) 1 (10&+) 5. Now x n&v y means that y gets applied to n&v for x times. With J's right to left evaluation we get: to 5 add 1 times 10, add 4 times 10, add 1 times 10, add 3 times 10. A challenge made for J's stranger parts. :-) And because + is commutative, +&/ would also be a valid solution.

Perfect, you nailed it!

JavaScript (ES6),  28  23 bytes
Saved 3 bytes thanks to @Mukundan314
Expects (A)(n).
A=>n=>eval(A.join`*n+`)

Try it online!
How?
We simply join the input array with "*n+", so that [1,2,3] is turned into "1*n+2*n+3" and evaluate the resulting string.

I'm simultaneously amazed and disgusted. Good work!

Haskell, 17 bytes
foldr1.((+).).(*)

Try it online!
It turns out this this was close to a port of the intended J solution. The pointfree function ((+).).(*) takes the argument n to the map \a b->a*n+b, that is, to add n times the left value to the right value. This creates the same "verb" as J used, and the foldr1 does the same a J's automatic right to left evaluation. It starts with the rightmost value in the list, which never gets multiplied by n, and applies it right-to-left, effectively increasing the sum so far with n times to the new element.

Python 3, 27 bytes
lambda a,n:a.pop()+sum(a)*n

Port of my Japt solution to python
Try it online!

Snap! Just wrote the exact same code without looking at any answers!

+1 for 2 min earlier

Wolfram Language (Mathematica), 19 bytes
#2Tr@Most@#+Last@#&

Try it online!

Python 3, 27 bytes
lambda a,n:a.pop()+sum(a)*n

Try it online!

Clojure 41 bytes
#(+(last %1)(* %2(apply +(butlast %1))))
Unfortunately, + does have to be applyed.
Try It Online

Welcome to the community! Why not add a Try-It-Online link for your code so users can try it out :)

You can save 2 bytes by writing just % instead of %1, it is always recognized as the first argument, even when there are more.

And another one by swapping the order of operands: https://tio.run/##S87JzyotSv2vkZKappD2X1lDWyMnsbhEQVVTQ0sjsaAgp1JBWyOptAQqqKlqpKn5X5OLS6OgKDOvJCdPQSNNIdpYwVDBBIhNYxUMDTQ1cUuiyxnGKlhaWgJNBAA

05AB1E, 5 bytes
-2 bytes thanks to @KevinCruijssen.
*`²÷O

Try it online!
Explanation
*     Multiply list by second operand
 `    Dump
   ÷  Divide the last item by
  ²   the second operand
    O Sum the stack

05AB1E, 7 bytes
„²*ý.VO

Try it online!
Explanation
„       2-char string
 ²*     (Which does when evaluated) Multiply by the second input
   ý    Join the input list by this
    .V  Evaluate
      O Sum the resulting stack

5 bytes.

APL (Dyalog Extended), 9 bytes (SBCS)
Anonymous tacit infix function. Takes \$A\$ as left argument and \$n\$ as right argument.
⊢/+.×+×∘~

Try it online!
×∘~ \$A×(1-n)\$
+.×+ \$\big(\sum_{i=1}^N A_i×n\big)+\$
⊢/ rightmost element (lit. right-argument reduction)
So this effectively implements: $$
\Bigg(\bigg(\sum_{i=1}^N A_i×n\bigg)+A×(1-n)\Bigg)_N\\
\bigg(\sum_{i=1}^N A_i×n\bigg)+A_N×(1-n)\\
\bigg(\sum_{i=1}^N A_i×n\bigg)+A_N-n×A_N\\
\bigg(\sum_{i=1}^{N-1} A_i×n\bigg)+A_N
$$

@Bubbler Ugh, thanks, that'll be much harder to explain. Also, it isn't really related to my solution at all. You should self-answer with that, I guess.

APL (Dyalog Unicode), 5 bytes
+⍣⎕/⎕

Try it online!
A full program, which pretty much works like the 3-byte J solution. Takes two lines of input, \$A\$ first and \$n\$ second.
How it works
+⍣⎕/⎕
    ⎕  ⍝ Take the input A
   /   ⍝ Reduce by...
+      ⍝   Add the left argument
 ⍣⎕    ⍝   n times

For n=10 and A = 3 1 4 1 5, this becomes:
+⍣10/3 1 4 1 5
3 (+⍣10) 1 (+⍣10) 4 (+⍣10) 1 (+⍣10) 5
3 added 10 times to
         1 added 10 times to
                  4 added 10 times to
                           1 added 10 times to
                                    5

APL (Dyalog Extended), 8 bytes
1¨⍛,⊥0,⊣

Try it online!
A longer but more interesting one. A tacit dyadic function that takes \$A\$ on its left and \$n\$ on the right.
Uses mixed base conversion ⊥, which does the following:
Base:        1  1  1  ... 1    n
Digit value: n  n  n  ... n    1
Array value: 0  a1 a2 ... ax-1 ax
Total: a1n + a2n + ... + ax-1n + ax

How the code works
1¨⍛,⊥0,⊣  ⍝ Input: left=A, right=n
1¨        ⍝ An array of ones as long as A
  ⍛,      ⍝ Append n, which becomes the base
     0,⊣  ⍝ A prepended with single zero, which becomes the values
    ⊥     ⍝ Mixed base conversion as described above

Another interesting method could be (⎕⊥,)/⎕, but I don't think you can get rid of the brackets

R, 37 36 35 bytes
-2 bytes with help from Giuseppe
function(l,n)rev(l)%*%n^(seq(!l)>1)

Try it online!
Reverse the vector, and perform dot product with the vector \$(n^0, n^1, n^1, \ldots,n^1) = (1, n, n,\ldots, n)\$.
I just discovered this behaviour of seq, which gains 1 byte on item 4 of this tip: seq(!l) is equivalent to seq(along.with = l) (giving the vector 1 2 3 ... length(l)) in all situations, even if l is of length 1. That is because !l is a logical, not an integer, and so we avoid the call to seq.int when l is a (length 1) integer.

If the list were guaranteed to be at least length 2, this would be a byte shorter, but as it is, it's longer by one instead.

@Giuseppe Good old seq_along! I parlayed it into a 36-byter. Thanks!

@Giuseppe seq(!l) works and is equivalent to seq(a=l), even if l is of length 1!

Wow, it's been a while since I saw such a neat and applicable golfing trick! That's probably more due to my lack of participation here than anything else.

K (oK), 14 13 bytes
Solution:
{*|x+/y*-1_x}

Try it online!
Explanation:
Couldn't figure out a smart way of solving this.
{*|x+/y*-1_x} / the solution
{           } / lambda taking implicity x, y
        -1_x  / drop (_) 1 element from end of x
      y*      / multiply by y
   x+/        / sum up with x as accumulator
 *|           / take last (reverse, first)

Notes:

-1 byte thanks to coltim - thanks!

You can trim a byte by doing {*|x+/y*-1_x}

Pyramid Scheme, 407 bytes
     ^      ^
    /l\    /+\
   /oop\  ^---^
  ^-----^ -  /x\
 / \   / \   ---
/arg\ /set\
-----^-----^
    /2\   /+\
    ---  ^---^
        ^-  /1\
       ^-   ---
      ^-
     /]\
    ^---^
   / \ /2\
  /set\---
 ^-----^
/x\   ^-
---  /]\
    ^---^
   ^-  /#\
  / \  ---^
 /set\   / \
^-----^ /arg\
-    /+\-----^
    ^---^   /2\
   /*\  -   ---
  ^---^
 ^-  /#\
/x\ ^---
---/ \
  /arg\
 ^-----
/1\
---

Try it online!
Takes input through command arguments, with n as the first argument. This basically implements the algorithm:
i = 2
x = 0
o = 0
while args[i]:
  o += x*args[1]
  x = args[i]
  i += 1

print(o + x)

But with more nesting and some shortcuts, like using the variable 2.

Perl 5 + -pa -MList::Util+sum, 19 bytes
$_=pop(@F)+<>*sum@F

Try it online!

Did you mean -MList::Util=sum?

Interesting, I didn't know = would work there. I've always used + for places where spaces can't be used without quotes or to help precedence (e.g. /\d+\D/,say+($1)x$&). Looks like a bunch of things work though. Good to know, thanks! :)

Japt, 7 bytes
o +V*Ux

Try it online!
Explanation
o +V*Ux
o         // Pop and return last element of first input
  +       // plus
   V*     // second input times
     Ux   // Sum of first input

Retina 0.8.2, 31 bytes
\d+
$*
1(?=.*,1*;(1*)|1*$)
$1
1

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

Convert to unary.
1(?=.*,1*;(1*)|1*$)
$1

Multiply all but the last element of A by n and delete A.
1

Take the sum and convert to decimal.

Pyth, 7 bytes
+*sPQEe

Try it online!
Explanation
+*sPQEe
    Q    # First input
   P     # Remove the last element
  s      # Sum elements
 *   E   # Multiply by the second input
+     e  # Add the last element of the first input

Emacs Lisp with dash library: 38 51 bytes
(lambda(n A)(+(car(last A))(* n(-sum(butlast A)))))

(38 bytes was the function body' size only.)

You forgot to add the last back in.

My bad, unfortunately the answer is now much longer.

x86-16 machine code, 18 bytes
33 DB       XOR  BX, BX         ; clear running sum
49          DEC  CX             ; decrement array length
74 09       JZ   ADD_LAST       ; handle array length of 1 case
        LOOP_SUM:
AD          LODSW               ; load next value into AX
03 D8       ADD  BX, AX         ; BX = BX + AX
E2 FB       LOOP LOOP_SUM       ; keep looping
93          XCHG AX, BX         ; move sum into AX
F7 E2       MUL  DX             ; DX:AX = AX * DX
93          XCHG AX, BX         ; move result back to BX
        ADD_LAST:
AD          LODSW               ; load last value into AX
03 C3       ADD  AX, BX         ; AX = AX + BX
C3          RET                 ; return to caller

As a callable function: [SI] to input array, CX array length, DX = N.  Output to AX.
Rather than make an elaborate test program, here's it being run using DOS DEBUG, entering the input array into memory and setting registers as they would be called:

Explanation of above:
Enter input array into memory address DS:200 as 16-bit, little-endian words:
-e 200 3 0 1 0 4 0 1 0 5 0

Point SI to this input array:
-r SI
:200

Set CX to array's length:
-r CX
:5

Set N to 10 (0xA in hex):
-r DX
:A

Execute and stop before last instruction (RET will "return to DOS" and clobber registers):
-g 111

Result is AX=005F or 95 in decimal.

Pyramid Scheme, 7747 3668 1985 1732 1619 bytes
Edits

-4079 bytes by giving the variables shorter names...
-1638 bytes by doing some more manual optimisation
-253 bytes by using more 0-height trees
-113 bytes because out can output the final result directly

    ^  ^        ^       ^        ^  ^        ^        ^        ^
   / \ -^      / \     / \      / \ -^      / \      / \      / \
  /set\ -^    / do\   /set\    /   \ -^    /set\    /   \    /out\
 ^-----^ -^  ^-----^ ^-----^  / set \ -^  ^-----^  /     \   -----^
/l\   / \ -^/c\   ^-/n\   ^- ^-------^ -^/i\   ^- / loop  \      /+\
---  /arg\^----  ^- ---  ^- /N\     /#\^----  ^- ^---------^    ^---^
    ^------^    / \     /-\ ---    ^----^    ^- / \       / \  /s\ /#\
   / \    ^-   ^---^   ^---^      / \  ^-   ^- /<=>\     ^---^ --- ---^
  /99 \  ^-   / \ / \ /n\ /1\    /arg\^-   ^- ^-----^   / \ / \      / \
  ----- ^-   ^---/   \--- ---   ^------^  ^- /i\   /0\ ^---/set\    /arg\
       ^-   / \  -----^        /n\    ^- /-\ ---   ---/ \ ^-----^   -----^
      ^-   ^---      / \       ---   ^- ^---^        ^---/s\   / \      /-\
     ^-   / \       /set\           ^- /n\ /1\      / \  ---  / + \    ^---^
    ^-   /set\     ^-----^         / \ --- ---     ^---      ^-----^  /n\ /1\
   ^-   ^-----^   /c\   /!\       /set\           / \       /s\   /*\ --- ---
   -^  /n\   /+\  ---  ^---      ^-----^         /set\      ---  ^---^
   / \ ---  ^---^     /=\       /s\   /0\       ^-----^         /#\ /N\
  /set\    /n\ /1\   ^---^      ---   ---      /i\   /-\       ^--- ---
 ^-----^   --- ---  / \ /l\                    ---  ^---^     / \
/n\   /0\          /arg\---                        /i\ /1\   /arg\
---   ---         ^-----                           --- ---  ^-----
                 /n\                                       /i\
                 ---                                       ---

Try it online!
Explanation
(set nil (arg 99)) // Make nil

// Count the number of input arguments - n
(set nargin 0)
(do
    cond
    (
        (set nargin (+ nargin 1))
        (set cond (! (= (arg nargin) nil)))
    )
)
(set nargin (- nargin 1))

(set N (# (arg nargin))) // N - the number all but last of the array elements is getting multiplied by

// Add all but last elements of A
(set sum 0)
(set i (- nargin 1))
(loop
    (<=> i 0)
    (
        (set i (- i 1))
        (set sum (+ sum (* (# (arg i)) N))) // A[i] multiplied by N
    )
)
(set sum (+ sum (# (arg (- nargin 1))))) // Add the last element of A
(out sum) // Print

Some golfing for 1042 bytes. There's more you can do though (especially with that first do loop)

Golfscript, 13 bytes
~:i;-1%{i*+}*

Try it online!
Explanation:
~ to convert string input to array and integer on stack. :i; assigns \$n\$ to i and pops value. -1% reverses the array and {i*+}* folds the array with (a, b) -> a*n + b

11 bytes, if you take input in a different format

Ruby, 46 19 bytes
->a,n{eval a*"*n+"}

Courtesy of petStorm.
Old answer:
n,*A,l=gets.split(' ').map(&:to_i)
p A.sum*n+l

19 bytes, as an anonymous function

I should use anonymous functions more. Thanks!

MAWP, 26 bytes
%@_2A<\:.>2M3A[1A~M~]%\WM:

Now it works properly on the testcases. Works on MAWP 1.1's integer input.
Try it!

The new program works now. Only took 6 days!

+1 for persistence!

Jelly, 4 bytes
Ṫṭ×S

Try it online!
Ṫ       Pop the last element of the left argument,
 ṭ      append it to
  ×     the right argument times what's left of the left argument,
   S    and sum.

A more fun solution, which borrows Jonathan Allan's base conversion trick:
Jelly, 5 bytes
S,¥/ḅ

Try it online!
   /     Reduce the left argument by
 ,       pair right with
S ¥      the sum of left,
    ḅ    and convert from base right.

Bonus: Ä-.ịḅ’} is a whole 7 bytes, and doesn't even work if the left argument only has one element, but it's just kind of funny.

Befunge-98 (PyFunge), 29 27 bytes
j&10p#v&\10g*\4
_\.@  >+\:#

Try it online! Input is first N, then A. Note that there has to be a trailing space.
Animation of the code:

The pilcrow (¶) represents a newline (value 10) in the grid.

PHP, 41 bytes
fn($a,$n)=>array_pop($a)+array_sum($a)*$n

Try it online!
Just trying to use all the built-ins!

Raku, 20 bytes
{@^a.pop+$^b*@a.sum}

By using twigils, @^a matches the first arg (the array), and $^b the second (the multiplier).
Try it online!

Jelly, 5 bytes
ṪṭSƊḅ

A dyadic Link accepting a list of numbers on the left and a number on the right which yields a number.
Try it online!
ṪṭSƊḅ - Link: list of numbers, A; number n
   Ɗ  - last three links as a monad - f(A):
Ṫ     -   remove the tail (of A) and yield its value
  S   -   sum (the remaining elements in A)
 ṭ    -   tack -> [sum_of_remaining, tail]
    ḅ  - convert from base (n) -> n×sum_of_remaining+1×tail

Q'Nial, 33 bytes (20 bytes without operator definition)
s is op n a{+link[n*front,last]a}   %full operator definition

+link[n*front,last]a                %simple function

Explanation:
+                                   sum, reduce by +
 link                               list of the items of the argument
     [                              atlas (argument of link operation), point-free notation
      n*                            n *
        front                       all elements but the last of the argument
             ,
              last                  last element of the argument
                  ]                 end atlas
                   a                array a (argument of atlas)

Intermediate results, for n=10 and a=3 1 4 1 5
         10 s 3 1 4 1 5
or
         s 10 (3 1 4 1 5)

or
         +link[10*front,last]3 1 4 1 5

         [n*front,last] a
+-------------+-+
|+--+--+--+--+|5|
||30|10|40|10|| |
|+--+--+--+--+| |
+-------------+-+

         link[n*front,last] a
+--+--+--+--+-+
|30|10|40|10|5|
+--+--+--+--+-+

         +link[n*front,last]a
95

Pip, 10 bytes
a@v+b*$+Ha
Attempt This Online!
-2 from DLosc.

@RVa can be a@v; also, @< can be H if you use Pip 1.0: Attempt This Online

Julia 1.0, 21 19 bytes
A$n=pop!(A)+sum(A)n

Try it online!

Risky, 9 bytes
-_{1+0+00_?+0+?*?

Try it online!

tinylisp, 58 bytes
(load library
(d S(q((A N)(i(t A)(a(*(h A)N)(S(t A)N))(h A

Try it online!
tinylisp, 78 65 bytes
(d S(q((A N)(i(t A)(i(h A)(a(S(c(s(h A)1)(t A))N)N)(S(t A)N))(h A

Try it online!
Solution without using library, which is only for *.
-13 bytes thanks to DLosc

The non-library version can be 65 bytes if you make the multiplication algorithm part of the main function.

@DLosc that's incredibly clever. I have a lot of practice to do!

C (gcc), 56 bytes
s,i;f(v,l,f)int*v;{for(i=0;i<l-1;s+=v[i++]);return s*f;}

Try It Online!
f takes a vector (v), the length of the vector (l) and the factor to multiply the vector with (f) as arguments. It sums up the values in the vector, except for the last one (in s) and returns the sum multiplied by the factor.

Thunno 2 s, 4 bytes
×Ẹ¹÷

Attempt This Online!
Thunno 2, 5 bytes
µʋ¹×+

Attempt This Online!
Suggested by @noodleman.
Explanation
×Ẹ¹÷  # Implicit input
×     # Multiply each item in the list by the number
 Ẹ    # Dump onto stack, last item on top
  ¹÷  # Divide this number by the second input
      # Implicit output of summed stack

µʋ¹×+ # Implicit input
µʋ    # Right-reduce the input list by:
  ¹×  #  Multiply by the second input
    + #  And add this to the cumulative total
      # Implicit output

5 bytes flagless µʋ¹×+

@noodleman thanks, updated

TI-BASIC, 17 bytes
Input N
Nsum(Ans)-(N-1)Ans(dim(Ans

Takes input of \$A\$ in Ans.
Alternatives that are also 17 bytes:
Input N
sum(Ansmax(1,N(N>cumSum(1 or Ans

Input N
sum(AnsNaugment(1 or ΔList(Ans),{N⁻¹

Charcoal, 10 9 bytes
Ｉ⁺⊟θ×η↨θ¹

Try it online! Link is to verbose version of code. Presumably Charcoal has the same problem as IO when it comes to summing empty lists. Edit: saved 1 byte by converting from base 1 instead. Explanation:
   θ        `A`
  ⊟         Remove last element
 ⁺          Added to
       θ    Remaining elements of `A`
      ↨ ¹   Take the sum by converting from base 1
    ×       Multiplied by
     η      `n`
Ｉ           Cast to string
            Implicitly print

Wolfram Language (Mathematica), 16 bytes
a___~f~b_=+a#+b&

Try it online!
This one doesn't need a strange-looking input.
Takes input as f[A][n].

older, 17 bytes
#//.a_@b_:>a#2+b&

Try it online!
Takes a singly linked list as input: if X is a value and L is a list, X is the single-element list with element X, and  X[L] is the list with element X, followed by the elements of L. For example, 3@1@4@1@5=3[1[4[1[5]]]] is the list with 3, 1, 4, 1, 5.
Per this discussion, we can take the first element with Head, and the tail with Last.

is {3@1@4@1@5,10} a valid input?   If it is, nice job! I tried something similar but the best I could do was 24 bytes #/.{a__,b_}:>Tr@{a}#2+b&

@J42161217 a flat input can get down to 18 byes by taking it in Dot or a Flat two-byte operator (a_.b_ is Times[Optional[a_],b_] rather than Dot[a_,b_]): Try it online! For a list, you can get 20: #/.{a__,b_}:>+a#2+b&

Zsh, 25 bytes
n=`<&0`
<<<$[0${@/#/*n+}]

Try it online!
Takes the list as arguments and N on stdin. Inspired by the JS answer. Prefix each element with *n+ and $[evaluate arithmetically]. We have to add a 0 to the start as well. This is one byte shorter than using the join flag <<<$[${(j:*n+:)@}]
Zsh -P, 24 bytes
a=(0 \*`<&0`+$@)
<<<$[a]

Try it online!
Alternate solution using the -P flag, which enables RC_EXPAND_PARAM to do the same thing.

Vimscript 36 Bytes
Disgusted to report that Arnauld's solution also works for vimscript.
let F={a,n->eval(join(a,"*".n."+"))}

T-SQL, 40 bytes
I am using a table instead of an array, sql doesn't have arrays
The test uses a temporary table instead of a real table, because of lack of permissions to create a table.
SELECT sum(a*@-i/@@rowcount*a*~-@)FROM t

Try it online

SimpleTemplate, 81 bytes
It's fairly chunky :/
Mostly due to limitations in my language...
{@eachargv.0}{@ifloop.last is equal0}{@set*_ _,argv.1}{@/}{@incby_ R}{@/}{@echoR}

Takes a string of numbers or an array as the first argument, and the n as the 2nd argument.
You can try this on http://sandbox.onlinephpfunctions.com/code/4c7290781560c876ff1e72e5d1680ed7b98861a3

Ungolfed:
The code above is a little weird to read...
Here's a more readable version:
{@set result 0}
{@each argv.0 as number}
    {@if loop.last is equal to false}
        {@set* number number, argv.1}
    {@/}
    {@inc by number result}
{@/}
{@echo result}

Notes:

{@set result 0} is optional, as {@inc} will create the variable, if it doesn't exist
{@each argv.0 as number} doesn't need need the as number, defaulting to the variable _ to store values
{@if loop.last is equal to false} uses the special variable loop to know if it is the last item in the {@each} Also, false is the same as 0.
{@set* number number, argv.1} multiplies number with argv.1 and stores it inside number. If number was an array, it would multiply with all the values.
{@inc by number result} will increment the variable result by number (effectivelly, result = result + number)
{@/} is usually optional, but, with this code, they are all required.

excel, 25 bytes
Enter A followed by n in one column, followed by this formula
=SUM(R1:R[-3])*R[-1]+R[-2]

Note: R1C1 Reference Style option must be checked.

Lua, 58 bytes
r,t=0,{...}for i=2,#t-1 do
r=r+t[i]end print(r*t[1]+t[#t])

Try it online!
Having almost no array functions, Lua doesn't do too well in this challenge.

Perl 5 + -pi, 19 bytes
s/,/*$^I+/g;$_=eval

For example, for multiplicand 10, perl -pi10 -e's/,/*$^I+/g;$_=eval
Try it online. Idea stolen from this J answer. Accuracy improved by Dom Hastings in comments on this answer (many thanks!).

You need to take n from input too, it's not always 10! :)

You can get the same byte-count using non-standard input for n (-i): Try it online!

dc, 21 bytes
ss0[+z2<o]dso0rx*ls+p
Examples:
dc -e '10 3 1 4 1 5 ss0[+z2<o]dso0rx*ls+p'
95
dc -e '1 3 1 4 1 5 ss0[+z2<o]dso0rx*ls+p'
14
dc -e '999 1 ss0[+z2<o]dso0rx*ls+p'
1

Raku, 21 bytes
{*.join("*$_+").EVAL}

Try it online!
This works the same as the Perl 5 answer and also works with non-mutable lists, unlike the existing Raku answer, which is only one byte smaller than this.
Note: My previous answer of the same size does not work for singleton lists, which I've lodged an issue about.

Scala, 22 bytes
a=>a.last+_*a.init.sum

This returns a List[Int] => Int => Int
Try it online

MATL, 9 bytes
*1G0)0Z(s

Try it online!
Explanation
*1G0)0Z(s
*          % Multiply the inputs and push it onto the stack
 1G        % Push first input onto the stack
   0)      % Replace top stack element with its last element
     0Z(   % Set last element of multiplied inputs to top element in stack
        s  % Replace top stack element with its sum

Rust, 45 bytes
|a,n|a.pop().unwrap()+a.iter().sum::<i64>()*n

Try it online
The expected argument types are a: &mut Vec<i64> and n: i64.

Japt -h, 6 bytes
Ç+Ux*V

Try it

PowerShell Core, 29 bytes
param($a,$b)$a-join"*$b+"|iex

Try it online!
^ inspired by Arnauld's solution
My original one
PowerShell Core, 75 bytes
param($a,$b)(($a[($l=$a.Length-1)]+$b*($a[0..($l-1)]-join'+'|iex)),$a)[!$l]

Try it online!

Stax, 6 4 bytes
╡÷E@

Run and debug it

Factor + math.unicode, 23 bytes
[ dup pop -rot Σ * + ]

Try it online!

Vyxal s, 5 bytes
*ṫ⁰/J

Try it Online!

TI-BASIC, 30 bytes (on-calc) / 37 bytes (as text)
Assumes list variable L₁ contains the array and variable N contains n.
dim(L₁
Nsum(L₁,1,Ans-1)+L₁(Ans

Explanation

dim(L₁: Get the size of L₁, to be used in the next line as Ans.
Nsum(L₁,1,Ans-1)+L₁(Ans: The sum( function has optional arguments to specify the beginning and end of a region of the list to be summed. The sum is implicitly multiplied by N, then added to the last element of the list, and implicitly printed.

Closing parentheses can be left out at the end of lines in TI-BASIC.

Ly, 18 bytes
&n&spp&+>l<s>l*+u;

Try it online!
&n                 - read all the numbers into the stack
  &s               - save the entire stack to the backup cell
    pp             - delete top two entries on the stack
      &+           - sum the stack
        >l         - switch to clean stack, load original input
          <s       - switch back, save summary to backup cell
            >l     - switch stacks, load save sum of 2nd to N entries
              *    - multiple top two entries on stack
               +   - add top two stack entries
                u  - print top of stack as a number
                 ; - exit the code to avoid printing the rest of the stack

Arturo, 28 bytes
$[a,n][+last a n*sum chop a]

Try it
$[a,n][           ; a function taking args a and n
  +last a         ; add the last elt in a to
  n*sum chop a    ; n times the sum of a without its last elt
]                 ; end function

JavaScript (Node.js), 33 bytes
n=>a=>a.reduceRight((x,c)=>x+c*n)

Attempt This Online!
Not as short as the eval solution but uses a very similar method.

Swift, 46 bytes
{a,n in a.dropLast().reduce(a.last!){$0+n*$1}}

Try it online!
Type signature: <C: BidirectionalCollection where C.Element: Numeric>(C, C.Element) -> C.Element. (That syntax isn't quite legal Swift for lack of generic lambdas, but you know what I mean.)
For each element ($1) in a except the last one, add n*$1 to the running total. The total starts at a.last instead of zero.

sed 4.2.2, 65 bytes
s/<(!*)><(!*)>$/%\2%\1/
s/><//g
:a
s/!>%(!*)%/>%\1%\1/
ta
s/.*%//

Try it online!
Input is a list exclamation marks surrounded by <>. n is given as the last element of the list. Output is just exclamation marks.
Example where A = [3,1,4,1,5] and n = 1:
<!!!><!><!!!!><!><!!!!!><!> => !!!!!!!!!!!!!!

C (clang), 40 bytes
f(*a,l,n){return--l?*a*n+f(a+1,l,n):*a;}

Try it online!

jq, 18 bytes
(add-last)*$n+last

Try it online!

Befunge-98 (PyFunge), 24 bytes
j&0#v&:61p+2
g+.@>'.-*61

Try it online!
Ended up converging on a similar layout to ovs' answer, though with a different strategy:
Explanation:
 &0          Read numeric input (n) and push a zero on top as sum
   #         Skip into the main loop
     &:61p+  Read a number in, save a copy in (6,1) and add it to the sum
j          2 Jump over the initialisation and continue the loop
    v&       When we're out of input, go to the next line

At this point, our stack looks like `n sum`

    >'.-     Retrieve our saved last value and subtract it from the sum
        *    Multiply by n
g+       61  Retrieve our saved value and add it back to the sum
  .@         Print and exit

Nibbles, 2.5 bytes (5 nibbles)
/@+*_

/@+*_       # full program
/@+*_$@     # with implicit args added;
/           # fold from right over
 @          # arg2
            # with function:
  +         #   add
   *        #   the product of
    _       #     arg1
     $      #     and the left-hand element
      @     #   to the right-hand element

Uiua, 7 bytes
/+⍜↘×¯1

Try it!
/+⍜↘×¯1
     ¯1  # push negative one
  ⍜↘×    # multiply all but last element by input
/+       # sum

Desmos, 32 31 bytes
f(a,n)=na.total-(n-1)a[a.count]

Try it on Desmos
-1 byte thanks to Aiden Chow.

This is a relatively recent update as a result of the creation of the Desmos Geometry Tool but a.length can be replaced with a.count.

Io, 31 bytes
Saves a byte over the 32 byte solution. But it's boring.
method(a,N,a sum*N-a pop*(N-1))

Try it online!
Explanation
method(a, N,
    a sum * N         // Sum the input, multiply by N
  - a pop * (N - 1)   // Minus the last item, multiplied by N - 1
)

Io, 32 bytes
Just as comparison
method(a,N,a push(a pop/N)sum*N)

Try it online!
Explanation
method(a, N,
           a pop           // Extract the last item from the input list
                /N         // Divide it by N
    a push(       )        // And then put it back into the original list
                   sum     // Sum the list
                      *N   // Multiply the value by N
)

C (gcc), 53 bytes
Saved 2 bytes thanks to ceilingcat
s;f(a,n)int*a,n;{for(s=0;a[1];s+=*a++);return*a+s*n;}

Try it online!

n is implicit int in C89, so you don't need to specify it's type.

Perl 6, 29 bytes
->$a,$b {$a.pop+([+] $a)*$b};

Try it online!

You can use $^a and $^b instead, as well as .sum, and the semi-colon is not needed, which ends up being the same as a previous Raku answer

@JoKing Oh, my bad! Thanks for the tip, though - I'm still learning Raku.


text:
Too much lines for me!
The problem
You just got a new job, hurray! You expect to be given various interesting tasks, and be able to learn a lot in the next few months.
Good news, your boss gave you your first work this morning. You are now in charge of... Writting adresses on envelopes. Yay.
Fortunatelly, you are not required to write everything by hand : there is a software for this, in which you can enter the address as plain text.
However, the software is not really well-made and very old. When you opened the files, every information was scared on several lines, and do not fit anymore on the envelope format you were given.
Definitely not wanting to repare this by hand, you decide to write a small programm that will put the data back in the right format for you.

Your task
Distribute the input on the right amount of lines.
Each line should have the same amount of inputs (regardless of their size in characters) when possible, and if not, the number of line with different lengths should be limited to its minimum.
Meaning that the distribution is to be made in terms of inputs and not characters.
For cases where two solutions are possible (7 inputs on 3 lines for example), the algorithm should maximise the number of inputs in the first lines (starting from the top). There is an example for this very case.

Input format
N M
string0
string1
string2
string3
string4
string5
...
string(N-1)

Where :
N is an int and corresponds to the number of fragments in which the data was scattered.
M is an int and corresponds to the number of lines in which the data should be. You may assume that M<=N if necessary.
string0 ... string(N-1) are strings that can contain any non-control ASCII character, including spaces and end with [space]\n. You thus do not need do add spaces between the strings in the output.
You may also assume that there is no horizontal length limit.
They do not contain any line break except the final one.

Examples
Input            Output

3 1            string0 string1 string2
string0
string1
string2

5 3            AA BBB
AA             C DDDDD
BBB            EEEE
C
DDDDD
EEEE
8 2            AAAAA BBB C DDD
AAAAA          EE FFF GGGG HH
BBB
C
DDD
EE
FFF
GGGG
HH

8 3           AAA BBB CCC
AAA           DDD EEE FFF
BBB           GGG HHH
CCC
DDD
EEE
FFF
GGG
HHH

7 3            string0 string1 string2
string0        string3 string4 string5
string1        string6
string2
string3
string4
string5
string6

Test cases
5 3
This
is
the
first
test case

8 6
Good Night, Good night!
Parting
is
such sweet
sorrow,
that I shall
say good night
till it be morrow.

8 3
I
am starting
to
run
out
of
ideas for
test cases.

Expected outputs:
This is  //2 strings [This ] and [is ]
the first //2 strings [the ] and [first ]
test case //1 string [test case ]

Good Night, Good night! Parting //2 strings [Good Night, Good night! ] and [Parting ]
is such sweet //2 strings [is such ] and [sweet ]
sorrow, //1 string [sorrow, ]
that I shall //1 string [that I shall ]
say good night //1 string [say good night ]
till it be morrow. //1 string [till it be morrow. ]

I am starting to //3 strings
run out of //3 strings
ideas for test cases. //2 strings

Rules
Please mark your answer as : Language - XX bytes.
It is code-golf, so the winner is the answer with the smallest score in bytes.
It would also be very nice if you could provide even briefs explainations, as it is always very enlightning to read this kind of post.

"any ASCII character", even line breaks like CR and LF? How about null-bytes?

Please clarify the number of line with different lengths should be limited to its minimum. Does it mean we should break lines to minimise the number of existing line lengths or that all lines should have the same length except for one, and if so, does it matter which one?

Thank you for your comments, answer, and recommandations. It is indeed very unclear, (unlike what I thought). I updated the post so it becomes more understandable (let me know if it is not).
Thank you for taking the time to let me know what I made wrong. ^-^

My pleasure. For the future, consider using the sandbox to iron out issues such as these before posting.

With N=7 and N=3 should the result lines have 3 3 1 or 3 2 2 inputs?

I definitely will. Once again, thank you very much.

3 3 1, I am currently writting the edit for this kind of cases

@Adám
Okay, I think I clarified as much as I can for now.
The characters for strings are any non-control ASCII characters that do not contain \n excepted the final one.
Once again, thank you very much. I will definitely try the Sandbox next time.
Sorry for the inconvenience.

I don't see this challenge benefiting from the extra processing of the fragments.  All the relevant calculations can be done from the two integers and the fragments are just arranged based on that.

05AB1E, 23 21 bytes
This is my first 05AB1E program (In fact this is my first golfing using golfing language), so please, if you have any notes, tips or improvements - I would love to get some in the comments section.
Program:
`rs/î©\õ.gGs«N®%0Qi¶«}}

Explaination:
`rs/î©\õ.gGs«N®%0Qi¶«}}
`                             Push each element of the input to the stack
 r                            Reverse the stack
  s                           Swap the first two values in stack (which are the numbers)
   /                          Division between both numbers in order to get the number of words in each line
    î                         Round up
     ©                        Store that value in the register
      \                       Remove that number from the stack (remove head)
       õ                      Push empty string to pass over the first iteration
        .g                    Push the length of the stack (which is the number of words)
          G            }      Loop from 1 to The length of the stack
           s                  Swap the two words in the head of the stack
            «                 Concatenate
             N                Push counter_variable
              ®               Push the number we saved in the register (number of words per line)
               %              Modulo (To check if we need to concatenate a newline)
                0Q            Equals zero
                  i  }        If true
                   ¶          Push newline
                    «         Concatenate

Try it online!
Saving 2 bytes with the help of @KevinCruijssen:
`rs/îUõ.gGs«NX%_i¶«}}

Try it online!

8 bytes, takes input as string M N.

Got it! That's awesome. Learned some new things :)

@Third-party'Chef' The '  could be the space-builtin ð. :) Although in this case, removing ' ý is shorter, since » implicitly joins inner lists by spaces before joining by newlines: 5 bytes - try it online.

@SomoKRoceS Some 05AB1E tips can be found here. As for your current implementation: 1) The ©\ +® could be U+X or V+Y for -1 (which pops and stores the value in X/Y respectively, whereas © doesn't pop). 2) There is a builtin for 0Q, which is _. Good luck with future challenges. :) If you have any questions, feel free to ask.

@KevinCruijssen WTF, it's the first tip of the small 05AB1E golfing tips!

@Third-party'Chef' I actually added that just yet (5 minutes ago), since I noticed it was missing, haha. ;)

Thanks all! @KevinCruijssen I will try those out and update my answer.
By the way, kind of a "meta" question: Should I Include KevinCruijssen's and Chef's in my answer (with credits of course), or you post another answer with your approach?

Either is fine and it's up to us and yourself. :) If @Third-party'Chef' want to post his 8-byter (which I golfed to 5 bytes) as a separated answer, he's free to do so. If not, you could edit in his answer and my golf with credit indeed, although I would also still leave your original answer as well, since it would be a waste to just remove it after you took the effort in writing it (kinda like what I did here - two programs with different approaches in one answer).

Oh alright :) thanks

K (ngn/k), 15 bytes
Anonymous lambda. Takes N, M, and strings as arguments.
{,/'(&~y!!x)_z}

Try it online!
{…} lambda; x is N, y is M, z is strings:
 (…)_z cut list of strings before the following indices:
  !x enumerate strings
  y! division remainder when divided by target number of lines
  ~ mask indicating zeros
  & indices of trues in mask
 ,/' concatenate elements of each list

APL (dzaima/APL), 18 bytes
Anonymous tacit infix lambda. Takes N as right argument and M as left argument. Prompts stdin for strings as list of character vectors.
{,/⍺⍬⍴⎕,(⍺|-⍵)⍴⊂⍬}

Try it online!
{…} "dfn"; left and right arguments are ⍺ and ⍵:
 ⊂⍬ enclose the empty list to treat it as a whole
 (…)⍴ cyclically reshape it to the following length:
  -⍵ negate the number of inputs
  ⍺| division remainder when divided by the number of output lines
 ⎕, concatenate that many empty list to the string from stdin
 ⍺⍬⍴ reshape to M rows and as many columns as needed
 ,/ concatenate across