Hi there,

So I'm given a programming problem for a class, and here's what's given:

An n x n game board is populated with integers, one nonnegative integer per square. The goal is to travel along any legitimate path from the upper left corner to the lower right corner of the board. The integer in any one square dictates how large a step away from that location must be. If the step size would advance travel off the game board, then a step in that particular direction is forbidden. All steps must be either to the right or toward the bottom.

Consider the 4 x 4 board shown in Figure 1. Figure 2 shows the three paths from the start (upper left) to the target (lower right), with the irrelevant numbers in each removed.

Figure 1
2 3 3 1
1 2 1 3
1 2 3 1
3 1 1 0
---------------
2 3


1 0
Figure 2
2

1 2 1
0
---------------
2

1
3 0
------------------------------------------
I'm supposed to output how many good paths there are. So my question is, how would you suggest I approach this problem? Thanks for the help!

Member Avatar for hfx642

Questions that you should be asking yourself...
1. How do I want to store (hold) the grid?
2. How do I generate the grid (random or from a file)?
3. How do I traverse the grid?
4. What do I want my output to look like?
5. What do I have to keep track of, along the way?

This should get you started. Good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.