Find all Integer Solutions

preview_player
Показать описание
We find all combinations of 40 integers whose sum and product are both 40.

00:00 Intro
00:15 Making a start
02:18 Ruling out some cases
05:17 Finding solutions
Рекомендации по теме
Комментарии
Автор

Some fiddling on Desmos tells me that one solution is {4*-1, 33*1, 1*2, 1*4, 1*5}, where a*b is a instances of b. Dunno what (if any) others there are.

jessehammer
Автор

I was flabbergasted by this, not thinking the problem was "small" enough to attack case-by-case!

worldnotworld
Автор

Nice problem! I was a bit surprised that checking all possible cases (factorizations) didn't take longer than that. But you managed to handle it quite quickly with good explanations!

Would it make sense to add an additional constraint that the sequence should be increasing (or decreasing)? I think it would make the whole problem a bit cleaner, since you wouldn't need to worry about the different possible orderings. Or alternatively it might be a fun additional easy exercise to figure out the total number of different solutions taking the ordering into account.

Does anybody know, if there's any different way to get the answer to the problem without going through so many different cases (factorizations) one-by-one?

ReallyAmateurPianist
Автор

Interesting problem and well explained solution!

Chester
Автор

40 = 2*20 = 4*10 = 2*2*10 = 8*5 = 2*4*5 = 2*2*2*5 are the only possible factorizations, up to signs and factors of 1.

For each factorization, we consider all possibilities for signs that give positive sum of factors - otherwise there isn't enough 1s leftover to bring the sum to 40. We then use 1s to bring the sum to 40 and split the remaining factors evenly between 1s and -1s, making sure the final product is positive.

This means that if we initially have even number of factors summing to odd number or vice versa, there is no way to evenly split between 1s and -1s at the end, so we can't get to even 40. If parity matches, final number of -1s determines the sign of the initial product.

Detailed breakdown for 1st factorization:
2*20: 1*20 + 1*2 + 28*1 + 10*(-1)
(-2)*20: wrong sign, no solution
2*(-20): not enough 1s, no solution
(-2)*(-20): not enough 1s, no solution

All the solutions after reduced case work:
2*20: 1*20 + 1*2 + 28*1 + 10*(-1)
4*10: 1*10 + 1*4 + 32*1 + 6*(-1)
2*4*5: 1*5 + 1*4 + 1*2 + 33*1 + 4*(-1)

BrollyyLSSJ
Автор

My solution: 40 has prime factorization 2*2*2*5, so we can have some factors of those (potentially with minus signs) and all the rest are 1 or minus 1.
Moreover, something like 2*2*2*5 doesn't work since we're left with 36 1/-1s, so there's no way to make the overall expression even. This leaves us with:
4 2 5
4 10
2 20
Let's look at cases, starting from 2 20:
20 has to be positive, if 2 is positive we then add 28 +1s and 10 -1s, getting the right answer. If 2 is negative, we need 30 +1s and 8 -1s, but then the multiplication has the wrong sign.
With 4 10 the 10 needs to be positive. If the 4 is as well we need 27 plus and 11 minus, but then the sign of the multiplication is incorrect. If the 4 is negative 31 plus and 7 minus, and this works. MADE AN OOPSIE FOR 4 10, THIS DOESN'T SUM TO 40 BUT TO 30... OOPS
For 5 4 2 the 5 and either 4 or 2 must be positive. If all 3 are positive we need 33 plus and 4 minus, and the sign is right. If 4 or 2 are negative then the signs don't work out

tcoren
Автор

-2, 20, 23(1), 1(-1)? -4, 10, 35(1), 1(-1)? -2, 4, 5, 34(1), 1(-1)?

mikecaetano
Автор

Could we use Arithmetic Mean = Geometric Mean if

Leoteal