in reply to 1,000 bucks
I like Randal's answer even if it is technically wrong as you need $1023 to make it work! Some really interesting syntax there. Naturally you want a geometric progression. This is short, but very un-obfu ;-) tachyon print "Enter an integer 1-1000 :"; my $amount = <>; #die "Integers 1-1000 only!\n" unless $amount =~ m/^\d{1,4}$/ and $amo +unt <= 1000 and $amount > 0; my @envelope = qw(1 2 4 8 16 32 64 128 256 490); for (reverse @envelope) { next if $_ > $amount; printf "Giving you envelope with \$%d.00\n", $_; $amount -= $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: 1,000 bucks
by cforde (Monk) on May 22, 2001 at 20:34 UTC |