I have written a solution to find the right location of queens. The problems I am facing and hopefully you can help me with is if statement to check if the user input even or odd, if it is even it will proceed otherwise the program will respond to the user that the input should be even.
it is working if the value is even but when it is odd it stops and do not print the statement I wrote.
Please see below code:
x = 1
cnt = 1
i=1
j=1
location = 1
n = int(input("Please enter the chessboard dimention and # of queens:"))
if (n&1==1):
Print("The queen no. should be even number")
else:
while location < n:
y = int(cnt +(n/2))
print(" Queen no. ",location," is in row:",x,"Column:",y,"\n")
i+=1
j+=1
x+=1
y =cnt
cnt+=1
location+=1
print(" Queen no. ",location," is in row:",x,"Column:",y,"\n")
x+=1
location+=16
Aucun commentaire:
Enregistrer un commentaire