coverOn Friday I posted this puzzle…..

How can you use 50 American coins to add up to a dollar? The coins available are a penny (1 cent), a nickel (5 cents), a dime (10 cents), a quarter (25 cents), and a half-dollar (50 cents).

If you have not tried to solve it, have a go now.  For everyone else, the answer is after the break.
You need to use is 40 pennies, 8 nickels (40 cents) and 2 dimes (20 cents).  Did you solve it? Any other answers?

I have produced an ebook containing 101 of the previous Friday Puzzles! It is called PUZZLED and is available for the Kindle (UK here and USA here) and on the iBookstore (UK here in the USA here). You can try 101 of the puzzles for free here.

47 comments

    1. Please People, It’s not a riddle if you don’t have to use at least one of each coin. ie 4 quarters, or 2 quarters 5 dimes, or 1 quarter 5 nickels and 5 dimes…..!!!!

  1. I hit the ‘official’ answer first. I realised that
    a) the bulk of the coins had to be pennies to get the 50 coin total
    b) the totals of odd coins had to add up to an even amount (pennies and quarters)
    c) the pennies must be in multiples of 5
    d) therefore the maximum number of pennies must be 45 and the minimum 40
    e) half dollars were ‘too big’

    and at least one answer then became simply selecting a total of 60 cents using 10 coins from nickels, dimes and quarters.

  2. I wrote a quick Perl program to find all the ways of making $1 out of those coins, then display just those which consist of 50 coins.

    There’s hardly anything to the algorithm: most of it it just splitting it down into simpler cases that can be solved trivially — see the comments for details.

    Running it finds both solutions:

    $ ./50_coins
    50 coins: 45 × 1¢ + 2 × 10¢ + 1 × 25¢ + 2 × 5¢
    50 coins: 40 × 1¢ + 2 × 10¢ + 8 × 5¢

    Here’s the program, heavily commented:

    #! /usr/bin/perl

    # 50_coins
    #
    # Make $1 out of 50 coins: https://richardwiseman.wordpress.com/blog-2/

    use v5.10;
    use warnings;
    use strict;

    use List::AllUtils qw;

    # Find all the ways 100 can be broken down into the available coins:
    foreach my $count (breakdown(100, (50, 25, 10, 5, 1)))
    {

    # Count the total coins used, and display if there’s 50:
    my $coins = sum values %$count;
    say qq[$coins coins: ],
    join q[ + ], map { qq[$count->{$_} × ${_}¢] } sort keys %$count
    if $coins == 50;
    }

    sub breakdown
    # returns all the ways of making $target using @coin values
    {
    my ($target, @coin) = @_;

    # If the target is zero, then we can make it (using no coins):
    return {} if $target == 0;

    # Otherwise if there are no coins we can’t make anything:
    return if !@coin;

    # If the target has gone below zero then it’s impossible to do anything:
    return if $target < 0;

    # If we reach this far then there's a non-zero target and some coins (well,
    # at least one). Of the possible ways of making $target, they either involve
    # the first coin or they don't — for example ways of making $1 can be split
    # into those that use at least one 25¢ and those that don't use 25¢ at all.
    # Work out each of those sets separately, and return the combined list.
    #
    # Use this function again to solve each of the smaller problems — which may
    # in turn involve invoking it again, and so on, until it reaches one of the
    # simple cases above. Avoid Perl worrying that it'll never end:
    no warnings qw;

    (

    # The ways of making $1 using at least one 25¢ coin is the same as adding
    # one 25¢ coin to each of the ways of making 75¢ using those coins
    # (including potentionally further 25¢ coins). So find all the ways of
    # making that smaller target using the same coins, and add one count of the
    # first coin into each of the breakdowns:
    map { $_->{$coin[0]}++; $_ } breakdown($target – $coin[0], @coin)),

    # The ways of making $1 without using any 25¢ coins is just like that coin
    # had never been included in the list of allowed coins in the first place.
    # So find all the ways of making the same target but without using the
    # first coin:
    breakdown($target, @coin[1 .. $#coin],
    );
    }

  3. I have heard a similar puzzle, have a go if you want: You have 100 dollars, and your task is to buy 100 animals. Exactly. the chickens costs 50 cents, the hens costs 3 dollars, and the rooster costs 10 dollars. You have to use all the money, and you have to buy at least one of each animal.

  4. I got the answer given (the one with three different kinds of coins) by trial and error, with a biro and a post-it note.
    Someone on Friday mentioned solving this with two equations. I don’t know if this meant simultaneous equations, but if anyone could show me how I could have done it more ‘scientifically’ I’d be grateful.

  5. Without need for any code, the solution (coin initials for unknowns) fulfils
    p+n+d+q+h=50 and p+5n+10d+25q+50h=100.
    Eliminating the pennies leaves:
    4n+9d+24q+49h=50.
    Constraining to positive integers that sum to 50 in this way, we must have h=0, q={0,1}, d<=4 and n<=10.
    It's easy enough to test with q=0 (4n+9d=50 only has solution n=8, d=2) and q=1 (4n+9d=26 only has solution n=2, d=2) so we have two answers: 40p, 8n, 2d, 0q, 0h and 45p, 2n, 2d, 1q, 0h

    1. Dear foolonthehill: That’s very kind of you. Thanks. I surprise myself by being able to follow your explanation. I must be getting better at this stuff.

  6. Ooops – obviously, that should say “we must have h=0, q={0,1}, d<=5 and n 50 and 4×13 > 50.
    For completeness, the other step I missed is to say that q<=2, but for q=2, 4n+9d=2 has no solution, leaving just q={0,1}

    I think that DiscoveredJoys identification that 'p' must be a multiple of 5 is interesting, and might lead to a simpler proof. Though as I don't use the pennies in mine, it would need another approach….

    1. Weird – now my reply has been mangled too. Let’s try again….
      “we must have h=0, q={0,1}, d<=5 and n 50 and 4×13 > 50.”

    2. Ha ha. Obviously I’m _not_ getting better at this stuff in that case! I managed to understand it and you’d made a mistake! Thanks for the clarification. I’ll see if I can follow this one instead. Anne

  7. Nope. Still broken – it keeps removing a line of text! Last try:
    “We must have h=0, q={0,1}, d less or equal to 5 and n less than or equal to 12.
    This is simply because each term must be less than 50: 9 times 6 > 50 and 4 times 13 > 50.”

  8. So, I think I can also formalise DiscoveredJoys theory a bit, by saying p=5x with 1 <= x <= 9:
    n + d + q + h = 50-5x and 5n + 10d + 25q + 10h = 100-5x
    Removing n this time, we get:
    d + 4q + 10h = 4x – 30
    but 4p-30 must be positive, so x={8,9} (hence pennies is 40 or 45 as DiscoveredJoys pointed out)
    so, d + 4q + 10h = 2 or 6, and the two solutions follow…

  9. I realised that the pennies must be a multiple of 5, but less than 50.
    So 45 pennies leaves 5 coins to add up to 55.
    Assuming I was on the right track, one must be a quarter leaving 4 coins for 30 cents and it dropped out from there. (I could have started again with 40 pennies but didn’t). I do like foolonthehill’s approach. (Apart from the typo about “4p – 30 must be positive” which should be “4x – 30” 🙂 )
    And why can’t I type more than 3 lines into this box and see what I’m typing?

  10. I approached it a bit differently. If you start with 50 pennies, you have the correct number of coins, but a 50 cent deficit. Keeping the number of coins constant, swapping out one of the pennies for a nickel raises the total value by 4 cents. A dime adds 9 cents, a quarter adds 24. Then the problem becomes a simpler matter of finding a way to add some number of 4s, 9s, and 24s together to add up to 50.

  11. Not to be left out, but I was busy visiting my sick mother (really), so:

    1 Quarter
    2 Dimes
    2 Nickels
    45 Pennies

  12. I took about a minute or so to find the 40 + 8*5 + 2*10 solution, and then I just assumed there would be loads of other solutions. Then I was surprised to read comments on Friday from several people saying there were only 2 solutions, so I worked out the 45 + 2*5 + 2*10 + 25 solution as well.

    I started with 100 1-cent coins, and repeatedly replaced groups of five with nickels until the number of coins got down to 50. I realised I needed to have dimes as well, otherwise the number of 1-cent coins wouldn’t fit.

  13. This design is steller! You certainly know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!|

  14. a bag contains pennies,nickels,dimes and quarters.There are 50 coins in all of the coins 10% are pennies and 30% are dimes.There are 3 more nickels than pennies.How much money does the bag contain?

Leave a reply to Séan Donnellan Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.