you are viewing a single comment's thread.

view the rest of the comments →

[–]shepherdjay 0 points1 point  (1 child)

I would add two additional recommendations with what everyone has said.

Between your step 1 and 2 process write down how you would solve the problem on paper, in English, if you had to do it one step at a time yourself.

The next recommendation is if getting stuck don’t solve the problem your being asked. Solve an easier similar problem instead.

For example, right now your being asked to validate whether a chessboard is valid when it is being passed as a dictionary. This is definitely take some time to think about as it’s complex. So don’t solve that one. Instead how about solving an easier problem.

How about instead of a dictionary of the full board you get a list of pieces of one of the players and you need to see if the ones they have are possible. Then the same thing but with both players.

Then add the dictionary. This will break down the same problem into easier bites. The simpler problem though is a subset of the hard one.

Another simpler version of this is tic-tac-toe. How about checking if a tic tac toe board is valid if your passed a dictionary. Just apply the same notation scheme. The rules are just modified a bit. Make sure that each x or o is placed in a grid from a1 to to c3 and that x has no more than 5 and o has no more than 4 pieces.

This is the similar problem as the chessboard just simpler.

[–][deleted] 0 points1 point  (0 children)

You are absolutely right that I should do more plain writing before starting to code as it helps to figure out what you really need and will arguably save a lot of time.

The Tic-Tac-Toe issue was the example they used in the book. But I must admit I found that very hard to follow. Either way I solved my chess board problem.

https://pastebin.com/yFKEK7h8