There is a chessboard 8x8. Suppose each cell of the board contains a certain number of apples. A chess piece “knight” can walk according to the classic rules of the knight's move. Once in the next cage, the horse collects all the apples that are in it. There are restrictions on the number of moves. Your program should accept the following arguments as input: the maximum number of moves, the name of the file containing the scheme for filling the chessboard with apples. The lines in the file correspond to the lines of the chessboard, the lines are separated by hyphens. Numbers in rows are separated by spaces. Your program should display the maximum possible number of apples collected by the knight, with a given limit of moves and an arbitrary choice of the starting position.
Actually, I would like to understand how this method should be solved. I need the code itself, of course, but I think I can write a program myself if I understand its main idea. There was an idea to solve through the greedy algorithm, moving into a cell containing the maximum possible number of apples (compared the number of apples in each of the cells available at the moment and went into the cell with the maximum number), but, I think this solution is soft saying not quite right. The task must contain a recursion. Submit an idea for solving this program or advise literature on this topic, please. Thank you in advance! : D