File: R5DragonCurve-oeis.t

package info (click to toggle)
libmath-planepath-perl 117-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,988 kB
  • ctags: 5,587
  • sloc: perl: 99,131; ansic: 299; sh: 233; lisp: 73; makefile: 4
file content (188 lines) | stat: -rw-r--r-- 5,435 bytes parent folder | download
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
#!/usr/bin/perl -w

# Copyright 2011, 2012, 2013, 2014 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 Test;
plan tests => 12;

use lib 't','xt';
use MyTestHelpers;
BEGIN { MyTestHelpers::nowarnings(); }
use MyOEIS;

use Math::PlanePath::R5DragonCurve;

# uncomment this to run the ### lines
#use Smart::Comments '###';

my $path = Math::PlanePath::R5DragonCurve->new;

#------------------------------------------------------------------------------
# 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;