All possible unique combinations
an anonymous user
·
Python
import itertools
# Function to print a combination as a matrix
def print_combination(combination):
for row in combination:
print(row)
print()
# Generate all possible combinations of placing 6 pieces in 9 spaces
all_positions = list(itertools.combinations(range(9), 6))
# Define the tic-tac-toe board size
board_size = 3
# Iterate through all combinations and print them as matrices
for positions in all_positions:
matrix = [[0] * board_size for _ in range(board_size)]
for position in positions:
row = position // board_size
col = position % board_size
matrix[row][col] = 1
print_combination(matrix)
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.