| 1 | # Copyright 2012, 2015 Kevin Ryde | ||||||||||||
| 2 | |||||||||||||
| 3 | # This file is part of Math-NumSeq-Alpha. | ||||||||||||
| 4 | # | ||||||||||||
| 5 | # Math-NumSeq-Alpha is free software; you can redistribute it and/or modify | ||||||||||||
| 6 | # it under the terms of the GNU General Public License as published by the | ||||||||||||
| 7 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||||
| 8 | # version. | ||||||||||||
| 9 | # | ||||||||||||
| 10 | # Math-NumSeq-Alpha is distributed in the hope that it will be useful, but | ||||||||||||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||
| 13 | # for more details. | ||||||||||||
| 14 | # | ||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||
| 16 | # with Math-NumSeq-Alpha. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||
| 17 | |||||||||||||
| 18 | |||||||||||||
| 19 | |||||||||||||
| 20 | # Should values in cycles be all 0 ? | ||||||||||||
| 21 | |||||||||||||
| 22 | |||||||||||||
| 23 | |||||||||||||
| 24 | |||||||||||||
| 25 | |||||||||||||
| 26 | package Math::NumSeq::AlphabeticalLengthSteps; | ||||||||||||
| 27 | 2 | ▶ | use 5.004; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 2 | ▶ | use List::Util 'min'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | |||||||||||||
| 31 | 2 | ▶ | use vars '$VERSION', '@ISA'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 32 | 2 | $VERSION = 4; | |||||||||||
| 33 | 2 | ▶ | use Math::NumSeq; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 34 | 2 | ▶ | use Math::NumSeq::Base::IterateIth; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 35 | 2 | @ISA = ('Math::NumSeq::Base::IterateIth', | |||||||||||
| 36 | 'Math::NumSeq'); | ||||||||||||
| 37 | 2 | *_is_infinite = \&Math::NumSeq::_is_infinite; | |||||||||||
| 38 | |||||||||||||
| 39 | 2 | ▶ | use Math::NumSeq::AlphabeticalLength; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 40 | |||||||||||||
| 41 | # uncomment this to run the ### lines | ||||||||||||
| 42 | #use Smart::Comments; | ||||||||||||
| 43 | |||||||||||||
| 44 | |||||||||||||
| 45 | # use constant name => Math::NumSeq::__('...'); | ||||||||||||
| 46 | 2 | ▶ | use constant description => Math::NumSeq::__('Steps of alphabetical length until reaching a cycle.'); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 47 | 2 | ▶ | use constant default_i_start => 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 48 | 2 | ▶ | use constant characteristic_count => 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 49 | 2 | ▶ | use constant characteristic_smaller => 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 50 | 2 | ▶ | use constant characteristic_integer => 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 51 | |||||||||||||
| 52 | 2 | *parameter_info_array | |||||||||||
| 53 | = \&Math::NumSeq::AlphabeticalLength::parameter_info_array; | ||||||||||||
| 54 | |||||||||||||
| 55 | 1 | ▶ | sub values_min { | ||||||||||
|
Subroutine
values_min: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||
| 56 | 1 | my ($self) = @_; | |||||||||||
| 57 | ### oeis_anum: $self | ||||||||||||
| 58 | 1 | ▶ | if (defined (my $values_min = $self->{'values_min'})) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | 0 | return $values_min; | |||||||||||
| 60 | } | ||||||||||||
| 61 | 1 | my $i_start = $self->i_start; | |||||||||||
| 62 | return ($self->{'values_min'} | ||||||||||||
| 63 | 1 | = min (map {$self->ith($_)} | |||||||||||
| 64 | $i_start .. $i_start + 20)); | ||||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | #------------------------------------------------------------------------------ | ||||||||||||
| 68 | # A133418 single step towards 4 | ||||||||||||
| 69 | |||||||||||||
| 70 | 2 | my %oeis_anum = (A005589 => 'A016037', # en cardinals | |||||||||||
| 71 | ); | ||||||||||||
| 72 | 0 | ▶ | sub oeis_anum { | ||||||||||
|
Subroutine
oeis_anum: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 73 | 0 | my ($self) = @_; | |||||||||||
| 74 | 0 | ▶ | return $oeis_anum{$self->{'lenseq'}->oeis_anum || ''}; | ||||||||||
|
Condition0%0/2
$self->{'lenseq'}->oeis_anum || ''
MC/DC0%0/1
$self->{'lenseq'}->oeis_anum || ''
$self->{'lenseq'}->oeis_anum
Truth table0%0/2
A
A= $self->{'lenseq'}->oeis_anum
| |||||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | # forty two = 8 | ||||||||||||
| 78 | # eight = 5 | ||||||||||||
| 79 | # five = 4 | ||||||||||||
| 80 | # four = 4 | ||||||||||||
| 81 | |||||||||||||
| 82 | # forty three = 10 | ||||||||||||
| 83 | # ten = 3 | ||||||||||||
| 84 | # three = 5 | ||||||||||||
| 85 | # five = 4 | ||||||||||||
| 86 | # four = 4 | ||||||||||||
| 87 | # | ||||||||||||
| 88 | # forty three = 11 ... is 5 steps | ||||||||||||
| 89 | |||||||||||||
| 90 | # forty four = 9 | ||||||||||||
| 91 | # nine = 4 | ||||||||||||
| 92 | # four = 4 | ||||||||||||
| 93 | |||||||||||||
| 94 | # fifty seven = 11 | ||||||||||||
| 95 | # eleven = 6 | ||||||||||||
| 96 | # size = 3 | ||||||||||||
| 97 | # three = 5 | ||||||||||||
| 98 | # five = 4 | ||||||||||||
| 99 | # four = 4 is 5 steps | ||||||||||||
| 100 | # | ||||||||||||
| 101 | # fifty seven = 10 ... is 4 steps | ||||||||||||
| 102 | |||||||||||||
| 103 | |||||||||||||
| 104 | #------------------------------------------------------------------------------ | ||||||||||||
| 105 | |||||||||||||
| 106 | 2 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 107 | ### AlphabeticalLengthSteps new(): @_ | ||||||||||||
| 108 | 2 | my $self = shift->SUPER::new(@_); | |||||||||||
| 109 | 2 | $self->{'lenseq'} = Math::NumSeq::AlphabeticalLength->new(@_); | |||||||||||
| 110 | 2 | return $self; | |||||||||||
| 111 | } | ||||||||||||
| 112 | |||||||||||||
| 113 | 72 | ▶ | sub ith { | ||||||||||
|
Subroutine
ith: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||
| 114 | 72 | my ($self, $i) = @_; | |||||||||||
| 115 | ### AlphabeticalLengthSteps ith(): $i | ||||||||||||
| 116 | |||||||||||||
| 117 | 72 | ▶ | if (_is_infinite($i)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 118 | 0 | return undef; | |||||||||||
| 119 | } | ||||||||||||
| 120 | |||||||||||||
| 121 | 72 | my $count = 0; | |||||||||||
| 122 | 72 | my %seen; | |||||||||||
| 123 | 72 | for (;;) { | |||||||||||
| 124 | 260 | $seen{$i} = undef; | |||||||||||
| 125 | 260 | $i = $self->{'lenseq'}->ith($i); | |||||||||||
| 126 | 260 | ▶ | if (! defined $i) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 127 | 0 | return undef; | |||||||||||
| 128 | } | ||||||||||||
| 129 | ### to: $i | ||||||||||||
| 130 | 260 | ▶ | last if exists $seen{$i}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 131 | 188 | $count++; | |||||||||||
| 132 | } | ||||||||||||
| 133 | |||||||||||||
| 134 | 72 | return $count; | |||||||||||
| 135 | } | ||||||||||||
| 136 | |||||||||||||
| 137 | 2 | 1; | |||||||||||
| 138 | __END__ | ||||||||||||