[Purdue-pm] Efficiency, was: my 2015-08-12 challenge problem solution

Rick Westerman westerman at purdue.edu
Sun Aug 9 15:01:12 PDT 2015


I think the problem is the ‘ symbol.   Evidently my email program made it into an odd character. Try replacing the ‘ with a proper single quote.


--
Rick Westerman
westerman at purdue.edu




> On Aug 9, 2015, at 5:21 PM, Mark Senn <mark at ecn.purdue.edu> wrote:
> 
> Rick Westerman <westerman at purdue.edu> wrote on 2015-08-09 at 11:18 -04:
> |  my $data = ‘aaa:b:cccc’ ;
> |  
> |  my ($one) = reverse grep { $_ } split ‘:’, $data ;
> |  
> |  my @twoarr = split ‘:’, $data ;
> |  my $two = $twoarr[-1] ;
> |  
> |  my $pos   = rindex $data , ':' ;
> |  my $three = substr($data, $pos + 1) ;
> 
> (I'm not sure what what will happen with input encoding when I send this
> message but I doubt if the code above will be runnable.)
> 
> When I save the above code in a file named "t.pl" and type "perl t.pl"
> (using Perl 5 version 5.22.0 on a Intel x86_64 Redhat Linux 6.6 system)
> I get
>    Unrecognized character \xE2; marked by <-- HERE after y $data = <-- HERE near column 12 at f01.pl line 1.
> 
> The quotes in the
>    my $pos ...
> line look ok though.  Did the original code from Rick run for anyone?
> 
> FOLLOWUP CHALLENGE QUESTION (that I'm not going to do)
> 
> In the original problem, identify all characteristics of possible input
> data that could affect the runtime (when using only ASCII characters)
> and write an O(n)-like expression to describe it.  Plot the predicted 
> runtime and real runtime vs. the number of unique first names (n) for
> n from one to a billion.
> 
> -mark



More information about the Purdue-pm mailing list