line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Goedelize; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21598
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
80
|
|
7
|
1
|
|
|
1
|
|
1479
|
use Math::BigInt; |
|
1
|
|
|
|
|
24435
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Alpha-to-number |
17
|
|
|
|
|
|
|
my %a_to_n = ( ' ' => '0', |
18
|
|
|
|
|
|
|
'a' => '1', |
19
|
|
|
|
|
|
|
'b' => '2', |
20
|
|
|
|
|
|
|
'c' => '3', |
21
|
|
|
|
|
|
|
'd' => '4', |
22
|
|
|
|
|
|
|
'e' => '5', |
23
|
|
|
|
|
|
|
'f' => '6', |
24
|
|
|
|
|
|
|
'g' => '7', |
25
|
|
|
|
|
|
|
'h' => '8', |
26
|
|
|
|
|
|
|
'i' => '9', |
27
|
|
|
|
|
|
|
'j' => '10', |
28
|
|
|
|
|
|
|
'k' => '11', |
29
|
|
|
|
|
|
|
'l' => '12', |
30
|
|
|
|
|
|
|
'm' => '13', |
31
|
|
|
|
|
|
|
'n' => '14', |
32
|
|
|
|
|
|
|
'o' => '15', |
33
|
|
|
|
|
|
|
'p' => '16', |
34
|
|
|
|
|
|
|
'q' => '17', |
35
|
|
|
|
|
|
|
'r' => '18', |
36
|
|
|
|
|
|
|
's' => '19', |
37
|
|
|
|
|
|
|
't' => '20', |
38
|
|
|
|
|
|
|
'u' => '21', |
39
|
|
|
|
|
|
|
'v' => '22', |
40
|
|
|
|
|
|
|
'w' => '23', |
41
|
|
|
|
|
|
|
'x' => '24', |
42
|
|
|
|
|
|
|
'y' => '25', |
43
|
|
|
|
|
|
|
'z' => '26', |
44
|
|
|
|
|
|
|
'.' => '27' |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
### Methods |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
50
|
1
|
|
|
1
|
0
|
16
|
bless {}, shift; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub to_number { |
54
|
1
|
|
|
1
|
0
|
12
|
my ($self, $text) = @_; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
48
|
my %link = %a_to_n; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
### Check the text |
59
|
1
|
50
|
|
|
|
12
|
croak "The string must contain only alpha chars and spaces" |
60
|
|
|
|
|
|
|
if ($text !~ /^[a-zA-Z\s]*$/); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
### Append dot |
63
|
1
|
50
|
|
|
|
6
|
if ($text !~ /\.$/) { $text .= "."; } |
|
1
|
|
|
|
|
4
|
|
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
7
|
my @txt = split(//, $text); |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
2
|
my $current_prime = 2; |
68
|
1
|
|
|
|
|
13
|
my $result = Math::BigInt->new(1); |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
121
|
foreach my $char ( @txt ) { |
71
|
4
|
|
|
|
|
11
|
my $prime = get_next_prime($current_prime); |
72
|
4
|
|
|
|
|
15
|
my $current = Math::BigInt->new($prime); |
73
|
4
|
|
|
|
|
117
|
$result *= ($current ** $link{$char}); |
74
|
4
|
|
|
|
|
912
|
$current_prime = $prime + 1; |
75
|
|
|
|
|
|
|
} |
76
|
1
|
|
|
|
|
9
|
return $result; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub to_text { |
81
|
1
|
|
|
1
|
0
|
446
|
my ($self, $number) = @_; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
23
|
my %link = reverse %a_to_n; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
### Check the text |
86
|
1
|
50
|
|
|
|
8
|
croak "The string must be number\n" |
87
|
|
|
|
|
|
|
if $number !~ /^[0-9]*$/; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
4
|
my $goedel = Math::BigInt->new($number); |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
28
|
my $current_prime = 2; |
92
|
1
|
|
|
|
|
2
|
my $result; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
1
|
PROCESS: while (1) { |
95
|
4
|
|
|
|
|
6
|
my $prime = get_next_prime($current_prime); |
96
|
|
|
|
|
|
|
|
97
|
4
|
|
|
|
|
5
|
my $times = 0; |
98
|
4
|
|
|
|
|
4
|
my $tmp = $goedel; |
99
|
4
|
|
|
|
|
5
|
DIVISION: while (1) { |
100
|
37
|
|
|
|
|
82
|
my $num = ($tmp/$prime); |
101
|
37
|
100
|
|
|
|
4616
|
last DIVISION if ( ($tmp % $prime) > 0 ); |
102
|
33
|
|
|
|
|
7284
|
$times++; |
103
|
33
|
|
|
|
|
67
|
$tmp = $num; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
4
|
100
|
|
|
|
866
|
last PROCESS if $link{$times} eq "."; |
107
|
3
|
|
|
|
|
7
|
$result .= $link{$times}; |
108
|
3
|
|
|
|
|
7
|
$current_prime = $prime + 1; |
109
|
|
|
|
|
|
|
} |
110
|
1
|
|
|
|
|
28
|
return $result; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get_next_prime { |
114
|
8
|
|
|
8
|
0
|
9
|
my $current = shift; |
115
|
8
|
|
|
|
|
14
|
GUESS: for (my $guess = $current; ; $guess++) |
116
|
|
|
|
|
|
|
{ |
117
|
12
|
|
|
|
|
29
|
for (my $divisor = 2; $divisor < $guess; $divisor++) |
118
|
|
|
|
|
|
|
{ |
119
|
22
|
100
|
|
|
|
56
|
next GUESS unless $guess % $divisor; |
120
|
|
|
|
|
|
|
} |
121
|
8
|
|
|
|
|
13
|
return $guess; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
__END__ |