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

 Pennies, Dimes, and Quarters (Posted on 2009-02-17)
In my left pocket I have a mix of pennies (1 cent) and quarters (25 cents). In my right pocket I have a bunch of dimes (10 cents). The number of coins in each pocket is the same, so is the cash value. What is the smallest (nonzero) number of coins I can have?

What if I had coins of x cents and z cents in my left pocket and coins of y cents in my right pocket - is there some quantitiy of coins I can have so that each pocket has the same number of coins and same cash value? (The value of the coins are positive integers x > y > z.)

 See The Solution Submitted by Brian Smith Rating: 2.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 part 1 -- computer solution | Comment 1 of 10

CLS

x = 25: y = 10: z = 1

FOR n = 1 TO 1000
amt = y * n
noX = 0
found = 0
DO
noZ = (amt - x * noX) \ z
r = (amt - x * noX) MOD z
IF r = 0 AND noZ + noX = n THEN
PRINT x, y, z
PRINT noX, n, noZ, amt
PRINT 2 * n
found = 1
END IF
noX = noX + 1
LOOP UNTIL x * noX > amt OR found = 1
IF found THEN EXIT FOR
NEXT

yields:

`25            10            13             8             5             8016`

meaning

`denomination: 25            10            1number:        3             8            5    `
`value of each side:         80total number of coins:      16`

 Posted by Charlie on 2009-02-17 12:00:47

 Search: Search body:
Forums (0)