Unsolvable question

I can’t solve this and i needed this today itself can someone help

We can help you solve this, but won’t write the code for you. Solving
problems and writing the code yourself is part of the learning process.

How could you solve this yourself, on a piece of paper just writing
numbers into a grid? Can you explain that process to us as an English
set of instructions, as you would telling someone else to do it?

There’s a very helpful diagram at the bottom of that question, making
clear how the values are laid out in the matrix.

The question has a a pair of what seem like constraints: that the first
cell has a 1 and the last cell has the result of n*m. But if you
count from 1 upwards filling in an n by m matrix, you’ll get that
for free - that’s just how many numbers you’ll end up using.

To get you started: figure out where those numbers land in the matrix -
put off actually putting them there until later. So write a bit of code
which counts from 1 through to n*m and prints out the counter value
and the (x,y) position in which it would land.

Have you been shown a for-loop?

Cameron Simpson cs@cskk.id.au

1 Like