Galloping Queens #2

Define a Galloping Queen as a chess piece whose legal move is that of a Knight , and that of a Queen .

In how many ways can you place 2 non-attacking Galloping Queen's on an 8 × 8 8\times8 chessboard?

Try more questions on Galloping Queens


The answer is 1120.

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.

1 solution

Eli Ross Staff
Jun 30, 2016

We can simplify things by looking at the "difference in position" and seeing if it fits a queen or knight move:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def attacking_squares(x,y):
    #difference in position
    a,b = x[0]-y[0], x[1]-y[1]
    #queen move (same axis or diagonal)
    if a*b == 0 or abs(a) == abs(b):
        return True
    #knight move
    if abs(a*b) == 2:
        return True
    return False

c = 0
for x0 in range(1,9):
    for x1 in range(1,9):
        for y0 in range(1,9):
            for y1 in range(1,9):
                    if attacking_squares((x0,x1),(y0,y1)) == False:
                        c += 1
print c/2

This gives 1120, where we divided by 2 in the last step because each pair of points gets counted twice.

For a more mathematical approach, we can work with values of ( a , b ) (a,b) which satisfy a b = 0 , ab=0, a = b , |a|=|b|, or a b = 2 , |ab|=2, and then back out how many pairs of ( x , y ) (x,y) this corresponds to. This would get a little messy (don't overcount!), and is a great example of where I'd rather just use a computer rather than working it out...

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...