A set of five numbers are added in all 10 possible pairs like in some of the
Pumpkins puzzles.
When sorted the middle six sums are 47, 48, 50, 51, 52, and 54. The two largest sums and two smallest sums are not given, similar to
Permuted Sums.
What are the possible sets of the five original numbers?
I found two solutions.
The 5 numbers, followed by the 10 sums:
(20, 23, 25, 27, 31)
[43, 45, 47, 48, 50, 51, 52, 54, 56, 58]
(21, 23, 24, 27, 31)
[44, 45, 47, 48, 50, 51, 52, 54, 55, 58]
The fact that the middle 6 sums show no duplicates implies, and I'm fairly certain proves, that the set of 5 integers also has no duplicates, but for completeness I decided to search with the possibility of duplicates in mind.
If we number the 10 sums in order from 1 to 10, and call the set of 5 integers a,b,c,d,e from smallest to largest, then:
if a+d=b+c then 3,4 are same
if a+e=b+c then 4,5 are same
if a+e=b+d then 5,6 are same
if a+e=c+d then 6,7 are same
if b+e=c+d then 7,8 are same
I didn't do it, but I suspect that requiring all 5 equations to be false will prove that none of a,b,c,d,e are the same.
--- code follows ---
from itertools import combinations
from itertools import combinations_with_replacement
def testSums(aList):
""" input is a list of integers
returns a list of sum of any 2 of these integers,
sorted in order from smallest to largest """
ans = []
for group_of_2 in combinations(aList,2):
ans.append(sum(group_of_2))
return sorted(ans)
match = [47, 48, 50, 51, 52, 54]
myList = [i for i in range(1,60)]
for group_of_5 in combinations_with_replacement(myList,5):
middle6 = testSums(group_of_5)[2:8]
if middle6 == match:
print(group_of_5,'\n', testSums(group_of_5))
|
Posted by Larry
on 2020-12-20 10:24:57 |