Skip to content

Commit 08df7a7

Browse files
committed
Make verbose progress information optional
1 parent 81d99c8 commit 08df7a7

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

categories/euler/prob063-polettix.pl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,24 @@
3131
my $count = 0;
3232

3333
# 9 is the maximum possible base for this problem. 9**22 has 21 digits
34-
for 1 .. 9 -> $x {
35-
my @x = (1);
36-
for 1 .. * -> $y {
37-
@x = multby(@x, $x);
38-
my $px = printable(@x);
39-
if ($px.encode('utf-8').bytes == $y) {
40-
say "$x ** $y = $px (", $px.encode('utf-8').bytes, ')';
41-
$count++;
42-
}
43-
elsif ($px.encode('utf-8').bytes < $y) {
44-
last;
34+
sub MAIN(Bool :$verbose = False) {
35+
for 1 .. 9 -> $x {
36+
my @x = (1);
37+
for 1 .. * -> $y {
38+
@x = multby(@x, $x);
39+
my $px = printable(@x);
40+
if ($px.encode('utf-8').bytes == $y) {
41+
say "$x ** $y = $px (", $px.encode('utf-8').bytes, ')'
42+
if $verbose;
43+
$count++;
44+
}
45+
elsif ($px.encode('utf-8').bytes < $y) {
46+
last;
47+
}
4548
}
4649
}
50+
say $count;
4751
}
48-
say $count;
4952

5053
sub printable (@x is copy) {
5154
my $msb = pop @x;

0 commit comments

Comments
 (0)