All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Minimizing disjoint sum (Posted on 2023-06-20) Difficulty: 2 of 5
Let A and B be two non-empty subsets of X = {1, 2, . . . , 8 } with A ∪ B = X and A ∩ B = ∅. Let PA be the product of all elements of A and let PB be the product of all elements of B. Find the minimum possible value of PA +PB.

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 2 of 6 |
The minimum sum is 402 produced by the following pairs of subsets:
(4, 6, 8) and (1, 2, 3, 5, 7)
(5, 6, 7) and (1, 2, 3, 4, 8)
(1, 4, 6, 8) and (2, 3, 5, 7)
(1, 5, 6, 7) and (2, 3, 4, 8)

----------
Output:
The minimum sum of Pa and Pb is 402
(4, 6, 8)
(5, 6, 7)
(1, 4, 6, 8)
(1, 5, 6, 7)
(2, 3, 4, 8)
(2, 3, 5, 7)
(1, 2, 3, 4, 8)
(1, 2, 3, 5, 7)
"""

x = [i for i in range(1,9)]

from itertools import combinations
minsum = 10000000000000
mincomb = ()
for a in range(1,8):
    for comb in combinations(x,a):
        pa = 1
        pb = 1
        for i in range(1,9):
            if i in comb:
                pa *= i
            else:
                pb *= i
        pab_sum = pa+pb
        if pab_sum < minsum:
            minsum = pab_sum
            mincomb = comb
print('The minimum sum of Pa and Pb is', minsum)

for a in range(1,8):
    for comb in combinations(x,a):
        pa = 1
        pb = 1
        for i in range(1,9):
            if i in comb:
                pa *= i
            else:
                pb *= i
        pab_sum = pa+pb
        if pab_sum == minsum:
            print(comb)


  Posted by Larry on 2023-06-20 13:55:12
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (12)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information