Created
December 9, 2024 03:43
-
-
Save vhxs/b5d032df97f1e5e1d46dd32f039311fc to your computer and use it in GitHub Desktop.
"anti-bingo"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from itertools import permutations | |
def count_permutation_matrices(n): | |
count = 0 | |
row_permutations = permutations(range(n)) | |
permutation_matrices = [] | |
for perm in row_permutations: | |
matrix = np.zeros((n, n), dtype=int) | |
for row, col in enumerate(perm): | |
matrix[row, col] = 1 | |
if not any(matrix[i, i] == 1 for i in range(n)): | |
continue | |
if not any(matrix[i, n - 1 - i] == 1 for i in range(n)): | |
continue | |
count += 1 | |
return count | |
n = 1 | |
while True: | |
print(count_permutation_matrices(n)) | |
n += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment