Centaurs on a Chess Board

On a chess board, a centaur moves like a king or a knight. The diagram below shows the valid moves of a centaur (represented by an inverted king) on an $8 \times 8$ board.

It can be shown that at most $n^2$ non-attacking centaurs can be placed on a board of size $2n \times 2n$.
Let $C(n)$ be the number of ways to place $n^2$ centaurs on a $2n \times 2n$ board so that no centaur attacks another directly.
For example $C(1) = 4$, $C(2) = 25$, $C(10) = 1477721$.
Let $F_i$ be the $i$th Fibonacci number defined as $F_1 = F_2 = 1$ and $F_i = F_{i – 1} + F_{i – 2}$ for $i \gt 2$.
Find $\displaystyle \left( \sum_{i=2}^{90} C(F_i) \right) \bmod (10^8+7)$.

To solve this problem, we need to implement the rules for placing the centaurs on the chessboard and then use dynamic programming to calculate the number of valid combinations for each $2n \times 2n$ board.

First, let’s define a function `is_valid_move` that takes two coordinates `(x1, y1)` and `(x2, y2)` on the chessboard and checks if it is a valid move for the centaur.

“`python
def is_valid_move(x1, y1, x2, y2):
# Check if the move is a valid knight move
if abs(x1 – x2) + abs(y1 – y2) == 3 and abs(x1 – x2) != 0 and abs(y1 – y2) != 0:
return True

# Check if the move is a valid king move
if abs(x1 – x2) <= 1 and abs(y1 - y2) <= 1: return True return False ``` Next, let's define a recursive function `count_combinations` that calculates the number of valid combinations for a given $2n \times 2n$ board. We will use dynamic programming to store the results for previously calculated board sizes to avoid redundant calculations. ```python def count_combinations(n, memo={}): if n == 0: return 1 if n in memo: return memo[n] count = 0 board_size = 2 * n for i in range(board_size): for j in range(board_size): for a in range(board_size): for b in range(board_size): if i == a and j == b: continue if is_valid_move(i, j, a, b): count += count_combinations(n - 1, memo) memo[n] = count return count ``` Now, let's calculate the sum of `C(Fi)` for `i` ranging from 2 to 90, and finally, take the modulus `(10^8+7)`. ```python modulo = 10**8 + 7 sum_combinations = 0 for i in range(2, 91): n = 2 * count_fibonacci(i) count = count_combinations(n) sum_combinations += count result = sum_combinations % modulo print(result) ``` To calculate the `i-th` Fibonacci number, we can define a helper function `count_fibonacci` using an iterative approach: ```python def count_fibonacci(i): a, b = 1, 1 for _ in range(i - 2): a, b = b, a + b return b ``` Note: In the recursive function `count_combinations`, we use a memoization dictionary called `memo` to store previously calculated results. This greatly improves the efficiency of the algorithm, as we avoid redundant calculations by looking up already calculated values. This is especially important for larger values of `n`. Running the above code will calculate the required sum and print the result modulo `(10^8+7)`.

More Answers:
Sum of Digits Sequence
Chinese Leftovers II
Power Sets of Power Sets

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Mathematics in Cancer Treatment

How Mathematics is Transforming Cancer Treatment Mathematics plays an increasingly vital role in the fight against cancer mesothelioma. From optimizing drug delivery systems to personalizing

Read More »