You are creating a variant of chess. A chessboard consists of 64 squares. The labelling of each square is as described here
You are creating a new type of piece called the duke. The duke is similar to the knight but moves where the knight follows a 2+1 move, the duke follows a 3+1 move. Instead of moving like a knight in an L shape where one leg of the L has two squares (as described here), the duke also moves in an L shape, but with one leg of the L having three instead of two squares.
Write a Python program that accepts input as an example “c4”. This position represents the present position of the duke. Your program should output a list of all possible moves. The ordering of the list should be alphabetically and numerically in increasing order, for example, a1 comes before b1 and a1 comes before a7.
DO NOT USE Dictionaries or any form of brute force if statements.
For example:
Input Result
c3
[‘b6’, ‘d6’, ‘f2’, ‘f4’]
c4
[‘b1’, ‘b7’, ‘d1’, ‘d7’, ‘f3’, ‘f5’]
can someone plz give me the code for this
Sanjana Reddy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2