line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::YASudoku::Square; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Andrew Wyllie |
4
|
|
|
|
|
|
|
# July 2005 |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 MODULE |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Games::YASudoku::Square |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
this object will be used to represent a single square |
13
|
|
|
|
|
|
|
on the sudoku board. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=over |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item B |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
create a new square on the board at location $id |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
327
|
|
|
327
|
1
|
2818
|
my $proto = shift; |
30
|
327
|
|
33
|
|
|
1330
|
my $class = ref ( $proto ) || $proto; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# this is the element_id |
33
|
327
|
|
|
|
|
382
|
my $id = shift; |
34
|
|
|
|
|
|
|
|
35
|
327
|
|
|
|
|
1148
|
my $self = { |
36
|
|
|
|
|
|
|
id => $id, |
37
|
|
|
|
|
|
|
value => undef, |
38
|
|
|
|
|
|
|
valid => {} |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
327
|
|
|
|
|
1362
|
bless $self, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item B |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
get the id of the element |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub id { |
52
|
5916
|
|
|
5916
|
1
|
6289
|
my $self = shift; |
53
|
5916
|
|
|
|
|
14474
|
return $self->{'id'}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item B |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
get or set the value for this square |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub value { |
64
|
70695
|
|
|
70695
|
1
|
91867
|
my $self = shift; |
65
|
70695
|
|
|
|
|
67110
|
my $value = shift; |
66
|
|
|
|
|
|
|
|
67
|
70695
|
100
|
|
|
|
106322
|
$self->{'value'} = $value if $value; |
68
|
|
|
|
|
|
|
|
69
|
70695
|
|
|
|
|
218132
|
return $self->{'value'}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item B |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
get the values in the valid array. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub valid { |
80
|
20994
|
|
|
20994
|
1
|
21946
|
my $self = shift; |
81
|
20994
|
|
|
|
|
20606
|
@valid = sort( keys %{$self->{'valid'}} ); |
|
20994
|
|
|
|
|
85807
|
|
82
|
20994
|
|
|
|
|
80482
|
return \@valid; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
add a number to the valid array |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub valid_add { |
93
|
733
|
|
|
733
|
1
|
3714
|
my $self = shift; |
94
|
733
|
|
|
|
|
747
|
my $number = shift; |
95
|
|
|
|
|
|
|
|
96
|
733
|
|
|
|
|
3208
|
$self->{'valid'}{ $number } = $number; |
97
|
733
|
|
|
|
|
1216
|
return $number; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item B |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
remove a number from the valid array |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub valid_del { |
108
|
16520
|
|
|
16520
|
1
|
18178
|
my $self = shift; |
109
|
16520
|
|
|
|
|
16805
|
my $number = shift; |
110
|
|
|
|
|
|
|
|
111
|
16520
|
100
|
|
|
|
52571
|
delete $self->{'valid'}{ $number } if $self->{'valid'}{ $number }; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Andrew Wyllie |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 BUGS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Please send any bugs to the author |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The Games::YASudoku moudule is free software and can be redistributed |
128
|
|
|
|
|
|
|
and/or modified under the same terms as Perl itself. |
129
|
|
|
|
|
|
|
|