You are given an 8 by 8 chess board with two randomly placed pieces. One of the pieces is a knight and the other piece is a King which does not move. Write a program to determine if the knight can capture the king in two moves or less. If you're unfamiliar with chess this article will show you how a knight moves.
Comments:
Emre Ozdemir - 10 years, 6 months ago
My solution with C++
reply permalink
Kaan Genç - 10 years, 6 months ago
Python 3.4. I kinda cheated by creating a list of possible moves. I used the "distance from f5 square" image from the linked article to build the list.
reply permalink
keemz - 10 years, 6 months ago
For practice, here is the code written in Apple's new Swift:
reply permalink
keemz - 10 years, 6 months ago
break without semi-colon
reply permalink
Max Burstein - 10 years, 6 months ago
Very cool!
reply permalink