[JOB] Perl Software Developer and Database programmer
Andy Armstrong
andy at hexten.net
Thu Feb 23 11:34:26 GMT 2006
On 23 Feb 2006, at 09:22, Peter Hickman wrote:
> The original code wouldn't have done that.
So I see. I have to admit I assumed the original test was flawed - so
I guess I didn't get the job :)
We could do with knowing whether ordering was significant too.
>
> #!/usr/bin/perl -w
>
> use strict;
> use warnings;
>
> my @alphas = qw/1 2 3 4 5 2/;
> my @betas = qw/1 2 3 1 2 3/;
> my @results;
>
> foreach my $alpha ( @alphas ) {
> foreach my $beta ( @betas ) {
> if ( $alpha == $beta ) {
> push @results, $beta;
> }
> }
> }
>
> print join ( ' ', @results ) . "\n";
>
> Gives: 1 1 2 2 3 3 2 2
>
> I think your code would produce different results.
> I'm off to make a cup of tea.
>
--
Andy Armstrong, hexten.net
More information about the london.pm
mailing list