Count paths in a cube I have a question about this exercise. I understand that the solution to this type of exercise lies in how many words can be formed with a certain number of letters, but my doubt is about the way in which it can be moved, because the problem says that it can go backwards. I would appreciate your support!

Inside a wire cube $C$ of dimensions $ 5 \times 5 \times 5$, wires are placed by dividing it into cubes of dimensions $1 \times 1 \times 1$. Call $A$ the lower left vertex of the front face of $C$, and let $B$ the vertex opposite $A$ in $C$ (that is, $B$ is the upper right vertex of the posterior face of $C$). How many different "paths" lead from the point $A$ to point $B$ along the hub wires, if the only directions possible are: backwards, to the right and up?

 A: You should start by breaking down the word problem into more mathematical language, using coordinates to simplify the geometry. For example, we can let $A=(0,0,0)$, and $B=(5,5,5)$. The question also gives us three directions: right is $a=(1,0,0)$, up is $b=(0,1,0)$, and backwards is $c=(0,0,1)$. Admittedly, "backwards" is a bit ambiguous, but once you formalize the words into numbers, it's hard to imagine any other sensible interpretation.
To reach $B$ from $A$, we need to go right five times, up five times, and backwards five times. Any order of these moves (that is, $5a+5b+5c$) will reach $B$, so you just need to count how many words there are if you only use the letters $\{a,b,c\}$, and you use each one exactly five times.
A: In order to reach from $A$ $(0,0,0)$ to $B$ $(5,5,5)$ in $C$ you must go

*

*$5$ steps up ($U$)

*$5$ steps right ($R$)

*$5$ steps back ($B$),

in some arbitrary order, a total of $15$ steps.
This is exactly same as number of distinct permutations of the string $UUUUURRRRRBBBBB$, which is $\frac{15}{5!5!5!}$
