[Solved] How to approach grid type problems? [closed]


In the 2×2 case you have 6 possible ways you say. (So I infer from that that you actually move from grid-point to grid-point rather than from cell to cell):
(r,r,d,d), (r,d,r,d), (r,d,d,r), (d,r,d,r), (d,d,r,r), (d,r,r,d).

Note that we always have 2 ‘d’s and 2 ‘r’s. And we always have 4 moves (_ , _, _, _).

Also note, that if you just place the ‘r’s at the 4 moves, then it is implicitly clear where the ‘d’s will go, i.e. if you put a ‘r’ at position 1 and 3 then you will have an ‘d’ at positions 2 and 4.

Hence you can think of it as: “how many ways are there to distribute 2 ‘d’s to 4 possible positions?”. You have to choose 2 elements out of 4.

This is the well known binomial coefficient (https://en.wikipedia.org/wiki/Binomial_coefficient) “n choose k”. In your case “4 choose 2” (among the 4 choices pick 2) which happens to be 6.

So, now I leave it as an exercise to you: on a 20×20 grid what is your ‘n’ and what is your ‘k’?

The other problem you might run into is how to actually compute the value. But I’m sure you’ll figure it out. Just have a close look at the wikipedia page about the binomial coefficient, you might find something useful there.

2

solved How to approach grid type problems? [closed]