1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
#!/usr/bin/perl -w
# Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019 Kevin Ryde
# This file is part of Math-PlanePath.
#
# Math-PlanePath is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# Math-PlanePath is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
use 5.004;
use strict;
use Math::BigInt;
use Test;
plan tests => 12;
use lib 't','xt';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings(); }
use MyOEIS;
use Math::PlanePath::R5DragonCurve;
my $path = Math::PlanePath::R5DragonCurve->new;
#------------------------------------------------------------------------------
# A135518 -- Odistinct sum distinct abs(n-other(n))
MyOEIS::compare_values
(anum => 'A135518',
max_count => 5,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 1; @got < $count; $k++) {
my ($n_lo, $n_hi) = $path->level_to_n_range($k);
my $total = 0;
my %seen;
foreach my $n ($n_lo .. $n_hi) {
my @n_list = $path->n_to_n_list($n);
@n_list == 2 or next;
my $d = abs($n_list[0]-$n_list[1]);
next if $seen{$d}++;
$total += $d;
}
push @got, $total/4;
}
return \@got;
});
#------------------------------------------------------------------------------
# A006495 -- level end X, b^k
MyOEIS::compare_values
(anum => 'A006495',
func => sub {
my ($count) = @_;
my @got;
for (my $k = Math::BigInt->new(0); @got < $count; $k++) {
my ($n_lo, $n_hi) = $path->level_to_n_range($k);
my ($x,$y) = $path->n_to_xy($n_hi);
push @got, $x;
}
return \@got;
});
# A006496 -- level end Y, b^k
MyOEIS::compare_values
(anum => 'A006496',
func => sub {
my ($count) = @_;
my @got;
for (my $k = Math::BigInt->new(0); @got < $count; $k++) {
my ($n_lo, $n_hi) = $path->level_to_n_range($k);
my ($x,$y) = $path->n_to_xy($n_hi);
push @got, $y;
}
return \@got;
});
#------------------------------------------------------------------------------
# A008776 single-visited points to N=5^k
MyOEIS::compare_values
(anum => 'A008776',
max_value => 10_0,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 0; @got < $count; $k++) {
push @got, MyOEIS::path_n_to_singles ($path, 5**$k);
}
return \@got;
});
#------------------------------------------------------------------------------
# A198859 boundary, one side only, N=0 to 25^k, even levels
foreach my $side ('right', 'left') {
MyOEIS::compare_values
(anum => 'A198859',
max_value => 50_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 0; @got < $count; $k++) {
push @got, MyOEIS::path_boundary_length($path, 25**$k,
side => $side);
}
return \@got;
});
}
# A198963 boundary, one side only, N=0 to 5*25^k, odd levels
foreach my $side ('right', 'left') {
MyOEIS::compare_values
(anum => 'A198963',
max_value => 50_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 0; @got < $count; $k++) {
push @got, MyOEIS::path_boundary_length($path, 5*25**$k,
side => $side);
}
return \@got;
});
}
# A048473 right or left side boundary for points N <= 5^k
# which is 1/2 of whole boundary
foreach my $side ('right', 'left') {
MyOEIS::compare_values
(anum => 'A048473',
max_value => 50_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 0; @got < $count; $k++) {
push @got, MyOEIS::path_boundary_length($path, 5**$k,
side => $side);
}
return \@got;
});
}
#------------------------------------------------------------------------------
# A079004 boundary length for points N <= 5^k
MyOEIS::compare_values
(anum => 'A079004',
max_value => 50_000,
func => sub {
my ($count) = @_;
my @got = (7,10);
for (my $k = 1; @got < $count; $k++) {
push @got, MyOEIS::path_boundary_length($path, 5**$k);
}
return \@got;
});
#------------------------------------------------------------------------------
# A005058 1/2 * enclosed area to N <= 5^k, first differences
# A005059 1/4 * enclosed area to N <= 5^k, first differences
MyOEIS::compare_values
(anum => 'A005059',
max_value => 50_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 0; @got < $count; $k++) {
push @got, (MyOEIS::path_enclosed_area($path, 5**($k+1))
- MyOEIS::path_enclosed_area($path, 5**$k)) / 4;
}
return \@got;
});
MyOEIS::compare_values
(anum => 'A005058',
max_value => 50_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 0; @got < $count; $k++) {
push @got, (MyOEIS::path_enclosed_area($path, 5**($k+1))
- MyOEIS::path_enclosed_area($path, 5**$k)) / 2;
}
return \@got;
});
# A007798 1/2 * enclosed area to N <= 5^k
# A016209 1/4 * enclosed area to N <= 5^k
MyOEIS::compare_values
(anum => 'A007798',
max_value => 100_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 1; @got < $count; $k++) {
push @got, MyOEIS::path_enclosed_area($path, 5**$k) / 2;
}
return \@got;
});
MyOEIS::compare_values
(anum => 'A016209',
max_value => 100_000,
func => sub {
my ($count) = @_;
my @got;
for (my $k = 2; @got < $count; $k++) {
push @got, MyOEIS::path_enclosed_area($path, 5**$k) / 4;
}
return \@got;
});
#------------------------------------------------------------------------------
# A175337 -- turn 0=left,1=right
MyOEIS::compare_values
(anum => 'A175337',
func => sub {
my ($count) = @_;
require Math::NumSeq::PlanePathTurn;
my $seq = Math::NumSeq::PlanePathTurn->new (planepath => 'R5DragonCurve',
turn_type => 'Right');
my @got;
while (@got < $count) {
my ($i,$value) = $seq->next;
push @got, $value;
}
return \@got;
});
#------------------------------------------------------------------------------
exit 0;
|