# Problem 44066. Number of paths on a 3d grid

This problem is inspired by https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid, which you might want to solve first.

Consider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down, right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.

Ex: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)

4x3x2 has 60 ways

6x5x4 has 27720 ways

This problem can be solved using dynamic programming but there are other methods too.

### Solution Stats

60.49% Correct | 39.51% Incorrect
Last Solution submitted on Apr 12, 2024

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!