
"""
Can you provide a Python program that solves the following problem?

Using all integers in the interval [1,10] exactly once find 10 integers
x1, x2, x3, ... x9, x10 that satisfy the equation

x1*x2 + x3*x4 + x5*x6 + x7*x8 + x9*x10 = 121

ChatGPT

Certainly! You can use Python's itertools library to generate
permutations of the numbers from 1 to 10 and then check each permutation
to see if it satisfies the equation. Here's a Python program to solve
the problem:
"""

# lrb - 6/7-9/24

from itertools import permutations

# Function to check if a permutation satisfies the equation
def satisfies_equation(perm):
	product_sum = perm[0]*perm[1] + perm[2]*perm[3] + perm[4]*perm[5] + perm[6]*perm[7] + perm[8]*perm[9]
	sum_1 = perm[7] + perm[0]
	sum_2 = perm[1] + perm[2]
	sum_3 = perm[3] + perm[4]
	sum_4 = perm[5] + perm[6]
	sum_5 = perm[8] + perm[9]
	bool = sum_1 == 11 and sum_2 == 11 and sum_3 == 11 and sum_4 == 11 and sum_5 == 11
	return product_sum == 121 and bool and perm[0] == 1

# Generate all permutations of the numbers 1 to 10
perms = permutations(range(1, 11))

# Iterate through each permutation and check if it satisfies the equation
cnt = 0
for perm in perms:
	if satisfies_equation(perm):
		cnt += 1
		if cnt == 5 or cnt == 11:
			print("Solution found:")
#			print(perm[7],perm[0],perm[1],perm[2],perm[3],perm[4],perm[5],perm[6],perm[8],perm[9])
			print(perm[6],'x',perm[7],' ',perm[1],'x',perm[0],' ',perm[2],'x',perm[3],' ',perm[5],'x',perm[4],' ',perm[8],'x',perm[9])
		if cnt == 12:
			break
"""
This code will generate all possible permutations of the numbers 1 to 10
and then check each permutation to see if it satisfies the equation.
Once it finds a permutation that satisfies the equation, it will print
the solution and stop.
"""
