How have the right to 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 4 minutes 1 (25 cents), and a half-dollar (50 cents).
You are watching: 50 coins to make a dollar
If you have not make the efforts to solve it, have a walk now. For anyone else, the price is after the break.You should use is 40 pennies, 8 nickels (40 cents) and 2 dimes (20 cents). Go you solve it? any other answers?
I have developed an ebook comprise 101 the the vault Friday Puzzles! that is called PUZZLED and also is available for the Kindle (UK here and USA here) and on the iBookstore (UK here in the USA here). Girlfriend can try 101 that the puzzles for cost-free here.
I did settle it, but only with trial and also error. Feels prefer there need to be a tidy formula to reach the result
I created a quick Perl regime to uncover all the ways of making $1 out of those coins, then display screen just those i m sorry consist that 50 coins.
See more: What Is 56 A Multiple Of 6 A Multiple Of 6? Is 56 A Multiple Of 6
There’s fixed anything to the algorithm: most of it it just separating it down right into simpler instances that have the right to be addressed trivially — view the comments because that details.
Running it finds both solutions:
$ ./50_coins50 coins: 45 × 1¢ + 2 × 10¢ + 1 × 25¢ + 2 × 5¢50 coins: 40 × 1¢ + 2 × 10¢ + 8 × 5¢
Here’s the program, heavily commented:
# 50_coins## do $1 out of 50 coins: https://rewildtv.com/blog-2/
use v5.10;use warnings;use strict;
use List::AllUtils qw;
# find all the methods 100 can be damaged down into the available coins:foreach my $count (breakdown(100, (50, 25, 10, 5, 1)))
# count the complete coins used, and also display if there’s 50: mine $coins = sum values %$count; speak qq<$coins coins: >, join q< + >, map qq<$count->$_ × $_¢> sort tricks %$count if $coins == 50;
sub breakdown# returns all the methods of make $target using
# If the target is zero, then we can make the (using no coins): return if $target == 0;
# Otherwise if there room no coins us can’t make anything: return if !
# If the target has actually gone below zero then it’s difficult to do anything: return if $target # at the very least one). The the possible ways of make $target, they either involve # the very first coin or castle don't — for example ways of making $1 deserve to be split # into those that use at least one 25¢ and those that don't usage 25¢ at all. # work out every of those sets separately, and return the linked list. # # usage this duty again to solve each that the smaller troubles — which might # in turn involve invoking that again, and so on, until it reaches among the # simple cases above. Stop Perl worrying that it'll never end: no warnings qw;
# The means of make $1 making use of at least one 25¢ coin is the very same as including # one 25¢ coin to each of the means of making 75¢ making use of those coins # (including potentionally further 25¢ coins). So find all the methods of # do that smaller sized target utilizing the exact same coins, and add one counting of the # very first coin right into each the the breakdowns: map $_->$coin<0>++; $_ breakdown($target – $coin<0>,
# The means of making $1 there is no using any 25¢ coins is similar to that coin # had actually never been contained in the perform of permitted coins in the an initial place. # So find all the ways of make the exact same target but without using the # very first coin: breakdown($target,