f ( x , y ) return the number of places a knight can move to (in one move) on a standard 8 × 8 chess board from the given ( x , y ) position. What is the sum of f ( x , y ) for all x and y ?
LetHere are some explicit examples:
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Generally, on a n × n board one can make a translation ( x , y ) from ( n − ∣ x ∣ ) ⋅ ( n − ∣ y ∣ ) different positions.
The knight has eight translations as possible moves, with ∣ x ∣ = 1 and ∣ y ∣ = 2 or vice versa.
Thus there are 8 ⋅ ( n − 1 ) ⋅ ( n − 2 ) possible knight moves on an n × n board, and with n = 8 we get 8 ⋅ 7 ⋅ 6 = 3 3 6 .
Note that the 8 × 8 grid is symmetric about the center and hence, f ( x , y ) = f ( 8 − x , y ) = f ( x , 8 − y ) = f ( 8 − x , 8 − y )
Consider a 4 × 4 grid as shown below
Notice that a knight on the corner ( marked red ) can move to only two squares. A knight on a yellow square can move to 3 squares. A knight on the green squares can move to 4 squares. On the blue, 6 squares, and on the purple, no restriction (all 8 knight moves are possible).
Hence the total will be 4 × ( 4 × 8 + 4 × 6 + 5 × 4 + 2 × 3 + 1 × 2 ) = 3 3 6
Nice solution. Solving f ( x , y ) for only 16 values and using that information to figure out the rest is a great way to go about it. Using your solution, it would only take another short step to generalize this to an n × n board.
Log in to reply
There is a one line solution to this problem.
Hint: 8 × 4 2 .
Python 3:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Problem Loading...
Note Loading...
Set Loading...
There are 8 types of knight moves, corresponding to ( ± 1 , ± 2 ) , ( ± 2 , ± 1 ) .
Let's consider how many valid moves there are for the case of ( + 1 , + 2 ) .
We are moving 1 to the right and 2 to the top. Hence, we cannot start in the right most column, nor can we start in the top 2 rows. Given any other starting position, it is clear we can move ( + 1 , + 2 ) . Hence, there are 7 columns × 6 rows of possible starting positions, which gives us 42 total.
This analysis is the same for each of the 8 moves, and each of them has 42 starting positions. Hence, there are a total of 8 × 4 2 = 3 3 6 possible moves that the knight can make.
Note: This analysis generalizes easily to a n × m board. What is the generalized answer?