Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make verbose progress information optional
  • Loading branch information
Paul Cochrane committed Apr 23, 2015
1 parent 81d99c8 commit 08df7a7
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions categories/euler/prob063-polettix.pl
Expand Up @@ -31,21 +31,24 @@
my $count = 0;

# 9 is the maximum possible base for this problem. 9**22 has 21 digits
for 1 .. 9 -> $x {
my @x = (1);
for 1 .. * -> $y {
@x = multby(@x, $x);
my $px = printable(@x);
if ($px.encode('utf-8').bytes == $y) {
say "$x ** $y = $px (", $px.encode('utf-8').bytes, ')';
$count++;
}
elsif ($px.encode('utf-8').bytes < $y) {
last;
sub MAIN(Bool :$verbose = False) {
for 1 .. 9 -> $x {
my @x = (1);
for 1 .. * -> $y {
@x = multby(@x, $x);
my $px = printable(@x);
if ($px.encode('utf-8').bytes == $y) {
say "$x ** $y = $px (", $px.encode('utf-8').bytes, ')'
if $verbose;
$count++;
}
elsif ($px.encode('utf-8').bytes < $y) {
last;
}
}
}
say $count;
}
say $count;

sub printable (@x is copy) {
my $msb = pop @x;
Expand Down

0 comments on commit 08df7a7

Please sign in to comment.