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

Home > Numbers
Three Pasture Puzzle (Posted on 2022-06-01) Difficulty: 3 of 5
Bernie has three pastures, each containing an equal number of animals. He sold all the animals of his pastures to 37 persons, each buying an equal number of animals.

If the cows cost $32.00 each, goats $15.00 each and pigs $5.00 each - determine the maximum number of animals Bernie could have, if he received $1661.00 from the sale.

No Solution Yet Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 1 of 8
There is probably an elegant way to solve this with modular arithmetic, but I used a little analytic and then brute force.

The number of animals must be a multiple of both 3 and 37, so it is a multiple of 111.
The average cost per animal is a weighted average of (5,15,32).
1661/111 = 14.96
1661/222 = 7.48
1661/333 = 4.99 which is less than 5, so this cannot be a solution.

So the maximum possible number of animals is 222.  But it remains to find some combination of different animals that satisfies the other boundary conditions (or should I call it "fence" conditions?)

I ran this code:
def gain(a,b,c):
    cost = [32,15,5]
    return cost[0]*a + cost[1]*b + cost[2]*c

start = 1661
gmax = int(start/15)
cmax = int(start/32)

solutions = []
for c in range(cmax+1):
    for g in range(gmax,-1,-1):
        remain = start - 32*c - 15*g
        animals = c+g+remain/5
        if remain%5 == 0 and animals%111 == 0:
            if remain/5 > 0:
                print(c,g,remain/5, gain(c,g,remain/5), '  animals:', animals)
            if animals == 222:
                solutions.append([c,g,int(remain/5)])
print(solutions)

Output:
3 47 172.0 1661.0   animals: 222.0
8 89 14.0 1661.0   animals: 111.0
13 20 189.0 1661.0   animals: 222.0
18 62 31.0 1661.0   animals: 111.0
28 35 48.0 1661.0   animals: 111.0
38 8 65.0 1661.0   animals: 111.0
[[3, 47, 172], [13, 20, 189]]

Suggesting two possible solutions for 222 animals, $1661 gross income:
cows, goats, pigs:
3, 47, 172
13, 20, 189

  Posted by Larry on 2022-06-01 07:52:28
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