Hi all!

Resending because the original message does not appear to have arrived at the
list.

=====

Hi Derrick,

On Tue, 16 May 2017 14:01:34 +0800
derr...@thecopes.me wrote:

> Hi All,
> 
> I am working on problem #8 of the euler project. see below.
> 
> 
> I have the below solution below for this which works fine but gives me the
> wrong answer. I checked shlomifish's solution on github and his is similar to
> mine, more elegant since he uses "map", but he gets a different answer. I
> feel like I have some basic misunderstanding about how something should work.
> Or maybe I am misunderstanding the problem. Thanks in advance for any push in
> the right direction. see my solution below.
> 
> Derrick
> 
> #! /usr/bin/env perl
> 
> use strict;
> use warnings;
> use 5.024;
> use List::Util qw(max product);
> 
> my $totalmax = 0;
> 
> while ( my $numbline = <DATA> ) {
>     chomp $numbline;
>     my @numbline = split //, $numbline;

You're processing the input number line-by-line, but it's one whole number and
the products may span across more than one line. You need to slurp it and
prepare an array of digits.

>     say "@numbline ";
>    my @product = (); 
>     for (0..$#numbline - 13) {

This should be "@numbline - 13" - an off-by-one error.

Regards,

        Shlomi Fish

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to