Girls and pigs number of solutions

Back to Problem Solutions forum

cescapa     2015-05-19 21:13:40
User avatar

Hey Rodion, on the girls and pigs problem (I suggest: monkeys and pigs), in the problem statement you have as follows:

*For the input data 26 and 136 possible solutions are:

*5 pigs with 26 breasts each (giving 20 legs and 130 breasts) with 3 girls; *1 pig with 114 breasts (mega-pig!) under the care of 11 girls.

But in fact there is one additional solution available, right? See this:

2 pigs with 59 breasts under the care of 9 girls (monkeys): 2x4 + 9x2 = 8+18 = 26 legs 2x59 + 9x2 = 118+18 = 136 breasts

Similarly, there are more solutions available for 106,336 and 200,500:

1: 106,336 solution exists with 51 monkeys and 1 pigs with 234 breasts 2: 106,336 solution exists with 49 monkeys and 2 pigs with 119 breasts 3: 106,336 solution exists with 43 monkeys and 5 pigs with 50 breasts 4: 106,336 solution exists with 33 monkeys and 10 pigs with 27 breasts 5: 106,336 solution exists with 7 monkeys and 23 pigs with 14 breasts

1: 200,500 solution exists with 98 monkeys and 1 pigs with 304 breasts 2: 200,500 solution exists with 96 monkeys and 2 pigs with 154 breasts 3: 200,500 solution exists with 94 monkeys and 3 pigs with 104 breasts 4: 200,500 solution exists with 92 monkeys and 4 pigs with 79 breasts 5: 200,500 solution exists with 90 monkeys and 5 pigs with 64 breasts 6: 200,500 solution exists with 88 monkeys and 6 pigs with 54 breasts 7: 200,500 solution exists with 80 monkeys and 10 pigs with 34 breasts 8: 200,500 solution exists with 76 monkeys and 12 pigs with 29 breasts 9: 200,500 solution exists with 70 monkeys and 15 pigs with 24 breasts 10: 200,500 solution exists with 60 monkeys and 20 pigs with 19 breasts 11: 200,500 solution exists with 50 monkeys and 25 pigs with 16 breasts 12: 200,500 solution exists with 40 monkeys and 30 pigs with 14 breasts 13: 200,500 solution exists with 0 monkeys and 50 pigs with 10 breasts

drewcocker     2015-05-20 04:23:14
User avatar

Although it's not stated in the question, I think the number of breasts per pig needs to be even, i.e., breasts come in pairs. (I agree about the name of the problem. Girls and pigs seems rather sexist.)

cescapa     2015-05-20 05:02:06
User avatar

That makes sense but I am still getting 10 valid answers for 200 legs and 500 breasts:

98 monkeys and 1 pig with 304 breasts 96 monkeys and 2 pigs with 154 breasts 94 monkeys and 3 pigs with 104 breasts 90 monkeys and 5 pigs with 64 breasts 88 monkeys and 6 pigs with 54 breasts 80 monkeys and 10 pigs with 34 breasts 70 monkeys and 15 pigs with 24 breasts 50 monkeys and 25 pigs with 16 breasts 40 monkeys and 30 pigs with 14 breasts 0 monkeys and 50 pigs with 10 breasts

Is there an implied rule that the pigs can't be on their own?

drewcocker     2015-05-25 06:41:12
User avatar

Yes, I think that's the case as well. I reran my solution (which passed previously) and it failed on a case where there was a possible solution of 0 monkeys. The described scenario is of a herd of pigs and the pig herders looking after them. The pigs wouldn't be off by themselves.

Please login and solve 5 problems to be able to post at forum