File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change 31
31
my $ count = 0 ;
32
32
33
33
# 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
+ }
45
48
}
46
49
}
50
+ say $ count ;
47
51
}
48
- say $ count ;
49
52
50
53
sub printable (@ x is copy ) {
51
54
my $ msb = pop @ x ;
You can’t perform that action at this time.
0 commit comments