20 Goats | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

20 Goats

Is that Possible.? There are 20 goats and we have to cut them in 5 days . We can't cut them in even way we have to cut them in odd numbers only, we have to cut them each day (5 days)

24th Nov 2022, 9:25 AM
Anukalp
Anukalp - avatar
3 Answers
+ 4
You are right, the sum of 5 odd numbers is always odd, cannot be 20.
24th Nov 2022, 11:18 AM
Tibor Santa
Tibor Santa - avatar
+ 1
I guess sum of odd number, odd time gives odd number only.
24th Nov 2022, 9:26 AM
Anukalp
Anukalp - avatar
+ 1
#or you can verify it very naively by brute force computation.😁 from itertools import combinations_with_replacement #generate odd number list oddnums = [] for i in range(1,29): if i%2!=0: oddnums.append(i) #collect all possible sums of 5 odd numbers from the list, repetitions included. sums =[] for n in combinations_with_replacement(oddnums,5): sums.append((sum(n))) print(f'{len(sums) = }') print(f'{min(sums) = }') print(f'{max(sums) = }') #check if there is a 20 in there. print(f'{set(sums) = }') print(f'{20 in sums = }')
26th Nov 2022, 1:45 AM
Bob_Li
Bob_Li - avatar