Skip to content

Instantly share code, notes, and snippets.

@vhxs
Created December 9, 2024 03:43
Show Gist options
  • Save vhxs/b5d032df97f1e5e1d46dd32f039311fc to your computer and use it in GitHub Desktop.
Save vhxs/b5d032df97f1e5e1d46dd32f039311fc to your computer and use it in GitHub Desktop.
"anti-bingo"
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