We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I still don't have a full solution, but I was able to solve a much larger number of test cases once I realized a condition that was only slightly implied by the problem description.
It says, "the goal of the game is to capture the opponent’s Queen without losing your own."
When I first read that the algorithm should "determine whether or not White can win in <= m moves regardless of how Black plays," I thought the algorithm didn't need to take into account any strategy. However, my code was incorrect until I implemented some logic that ensures a player will (1) never make a move that puts his queen in danger, and (2) always take his queen out of danger if possible.
Maybe this was obvious, but it took me a long time before I realized this. Hopefully it helps someone else.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Simplified Chess Engine
You are viewing a single comment's thread. Return to all comments →
I still don't have a full solution, but I was able to solve a much larger number of test cases once I realized a condition that was only slightly implied by the problem description.
It says, "the goal of the game is to capture the opponent’s Queen without losing your own."
When I first read that the algorithm should "determine whether or not White can win in <= m moves regardless of how Black plays," I thought the algorithm didn't need to take into account any strategy. However, my code was incorrect until I implemented some logic that ensures a player will (1) never make a move that puts his queen in danger, and (2) always take his queen out of danger if possible.
Maybe this was obvious, but it took me a long time before I realized this. Hopefully it helps someone else.