I need the pseudocode of the following program: import sys class KnightsTour: de
ID: 3854688 • Letter: I
Question
I need the pseudocode of the following program:
import sys class KnightsTour: def-init-(self, width, height): self.w = width self.h height self.x0 self.y0 self, board = self.generate_boardO def getCoord(self, coord): self. x coord [0] self.y -coord [1] def generate_board(self): Creates a nested list to represent the game board I1 for i in range(self.h): self.board.append([0]*self.w) def print_board(self): print ("") print ("--- for elem in self.board: print (elem) print ("-- print (" " def generate_legal_moves(self, cur_pos): 1 11 tI Generates a list of legal moves for the knight to take next possible-pos move-offsets [] [(1, = 2), (1, -2), (-1, 2), (-1, -2), = for move in move_offsets: new x - cur_pos [0] new y - cur_pos [1] move [0] move [1] continue elif (new_xExplanation / Answer
Step 1: If all blocks are visited then print solution
Step 2:Else:
i)add next move to solution and check if belongs to solution or not.It has 8 moves and select any one
ii)If above selected move does not belong solution,then remove it from solution and try another moves
iii)if none solution works then retun false
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.