Euler 52

I take a look on the perl6 features, I think it is enough for me to do some euler problem.

I start at euler problem 52.

The problem is euler52

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.

Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.”

sub digits_sort($num) {

sub is_euler52($numb) {
    my @result=map {digits_sort($_) eqv digits_sort($numb)}, $numb<<*<<(2..6);   
    [and] @result;

my $i=142850;
repeat {$i++;} until is_euler52($i);
say $i;

but it is two slow…

real 0m1.689s
user 0m1.476s
sys 0m0.076s

hope it will be better in the future..

#TODO: explain == eq eqv.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s