Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Strip trailing whitespace
  • Loading branch information
Paul Cochrane committed May 9, 2015
1 parent 478bb7f commit 092185a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions categories/euler/prob098-andreoss.pl
Expand Up @@ -4,7 +4,7 @@
=TITLE Anagramic squares
=AUTHOR Andrei Osipov
=AUTHOR Andrei Osipov
L<https://projecteuler.net/problem=98>
Expand All @@ -18,20 +18,20 @@
Expected result: 18769
=end pod

sub correspond([$word1, $word2], [$num1, $num2]) {
$word2.trans($word1 => ~$num1) eq $num2 &&
$num2.trans( ~$num1 => $word1) eq $word2;

}

sub anagrams(@x) {
my %aux;
my %result;

%aux{$_.comb.sort.join}.push: $_
%aux{$_.comb.sort.join}.push: $_
for @x;

for %aux.kv -> $k, @v {
Expand All @@ -52,14 +52,14 @@ (@x)
die "$file is missing" unless $file.IO.e;

my @words = sort unique $file.IO.slurp.split: / <[,"]>+ /;
my %words = anagrams(@words);

my %words = anagrams(@words);
my $longest-word = %words.keys.max;
my %squares = anagrams(
(1 ... (10**($longest-word + 1).sqrt)) »**» 2
);


say max do for 3 ... $longest-word -> \size {
do for @(%words{size}) -> @pair {
do for @(%squares{size}) -> @nums {
Expand Down
4 changes: 2 additions & 2 deletions categories/euler/prob099-andreoss.pl
Expand Up @@ -17,8 +17,8 @@
NOTE: The first two lines in the file represent the numbers in the example given above.
Expected result: 709
=end pod
=end pod

class BaseExp {
has $.base;
Expand Down

0 comments on commit 092185a

Please sign in to comment.