in reply to Project Euler (a series of challenging mathematical/computer programming problems)
i'm pretty sure my answer for 112 is correct, but apparently it's not. anybody see anything wrong with this? it works fine for the two examples (.5>538, .9>21780).
my $max = .99;
my $bouncy = 0;
for (my $n=1; ; $n++)
{
my ($inc, $dec) = (0, 0);
my @d = split //, $n;
for (my $i=0; $i<@d1; $i++)
{
if ($d[$i] < $d[$i+1]) { $inc++ }
elsif ($d[$i] > $d[$i+1]) { $dec++ }
}
$bouncy++ if $inc and $dec;
next if $max > $bouncy/$n;
printf "n=%d: %%%f\n", $n, $bouncy/$n;
last;
}
Re^2: Project Euler (a series of challenging mathematical/computer programming problems) by hv (Parson) on Feb 11, 2006 at 23:59 UTC 
Even though I can't see it explicitly stated anywhere, I think the intention of the site is that you solve the problems on your own without asking for help.
For what it's worth, while working through the problems I found that at least 75% of the time if my first attempt at an answer was wrong it was because I had misread the question rather than because I had a bug in my code.
Hugo
 [reply] 
Re^2: Project Euler (a series of challenging mathematical/computer programming problems) by mpolo (Chaplain) on Feb 12, 2006 at 17:18 UTC 
Well, I don't think that directly helping would be "ethical", but for what it's worth I (and most of the successful coders from what I remember in the fora) did that one with a rather different approach. One helpful trick is to try the examples in the problem (just insert a print "helpful debugging stuff\n" if $n==number_with_known_property; and see if they get classified correctly by your program. Much more fun is number 113, which has a slick mathematical solution, or my methodical numbercrunching solution...
 [reply] [d/l] 
