How deserve to you usage 50 American coins to include up to a dollar? The coins obtainable 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 do the efforts to fix it, have actually a go now. For anyone else, the price is after the break.You need to use is 40 pennies, 8 nickels (40 cents) and 2 dimes (20 cents). Did you resolve it? any kind of other answers?


I have developed an ebook comprise 101 of the vault Friday Puzzles! the is referred to as PUZZLED and is obtainable for the Kindle (UK here and USA here) and on the iBookstore (UK below in the USA here). Friend can try 101 of the puzzles for cost-free here.
*

*
Pete
says:

I did fix it, however only through trial and also error. Feels favor there must be a tidy formula to reach the result


*
tibo says:
*
Eddie says:
*
Smylers says:

I wrote a fast Perl regime to find all the means of making $1 out of those coins, then screen just those which consist the 50 coins.

See more: What Is The Central Idea Of The Essay ? Parts Of An Essay

There’s fixed anything to the algorithm: many of that it just dividing it down into simpler situations that can be solved 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, greatly commented:

#! /usr/bin/perl

# 50_coins## do $1 out of 50 coins: https://moment-g.com/blog-2/

use v5.10;use warnings;use strict;

use List::AllUtils qw;

# discover all the means 100 deserve to be damaged down into the obtainable coins:foreach my $count (breakdown(100, (50, 25, 10, 5, 1)))

# count the complete coins used, and also display if there’s 50: my $coins = amount values %$count; speak qq<$coins coins: >, sign up with q< + >, map qq<$count->$_ × $_¢> sort keys %$count if $coins == 50;

sub breakdown# returns all the ways of make $target utilizing
_;

# If the target is zero, then we deserve to make that (using no coins): return if $target == 0;

# Otherwise if there space no coins we can’t do anything: return if !
coin;

# If the target has actually gone below zero then it’s impossible to carry out anything: return if $target # at the very least one). The the feasible ways of make $target, they one of two people involve # the first coin or they don't — for example ways of making $1 have the right to be split # into those that use at the very least one 25¢ and also those the don't usage 25¢ at all. # work out every of those sets separately, and also return the merged list. # # use this function again to deal with each of the smaller troubles — which may # in turn involve invoking that again, and so on, till it reaches one of the # basic cases above. Stop Perl worrying the it'll never end: no warnings qw;

(

# The methods of make $1 utilizing at least one 25¢ coin is the exact same as including # one 25¢ coin to every of the ways of do 75¢ utilizing those coins # (including potentionally more 25¢ coins). So discover all the methods of # make that smaller target using the very same coins, and add one counting of the # very first coin into each the the breakdowns: map $_->$coin<0>++; $_ breakdown($target – $coin<0>,
coin)),

# The means of making $1 there is no using any 25¢ coins is similar to that coin # had actually never been had in the list of enabled coins in the an initial place. # So uncover all the methods of making the very same target but without making use of the # first coin: breakdown($target,