line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Sudoku::Component::Table::Item;
|
2
|
|
|
|
|
|
|
{
|
3
|
6
|
|
|
6
|
|
23445
|
use strict;
|
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
225
|
|
4
|
6
|
|
|
6
|
|
31
|
use warnings;
|
|
6
|
|
|
|
|
26
|
|
|
6
|
|
|
|
|
164
|
|
5
|
6
|
|
|
6
|
|
29
|
use Carp;
|
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
3316
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new {
|
10
|
576
|
|
|
576
|
1
|
1903
|
my $class = shift;
|
11
|
576
|
|
33
|
|
|
4198
|
my $this = bless {}, (ref $class || $class);
|
12
|
|
|
|
|
|
|
|
13
|
576
|
100
|
|
|
|
1595
|
my %options = ref $_[0] ? %{ $_[0] } : @_;
|
|
449
|
|
|
|
|
2617
|
|
14
|
|
|
|
|
|
|
|
15
|
576
|
50
|
|
|
|
1661
|
croak "Row is undefined" unless defined $options{row};
|
16
|
576
|
50
|
|
|
|
1351
|
croak "Col is undefined" unless defined $options{col};
|
17
|
576
|
50
|
|
|
|
1232
|
croak "Allowed is undefined" unless defined $options{allowed};
|
18
|
576
|
50
|
|
|
|
1539
|
croak "Allowed should be array_ref"
|
19
|
|
|
|
|
|
|
if ref $options{allowed} ne 'ARRAY';
|
20
|
|
|
|
|
|
|
|
21
|
576
|
|
|
|
|
1338
|
$this->{row} = $options{row};
|
22
|
576
|
|
|
|
|
945
|
$this->{col} = $options{col};
|
23
|
576
|
|
|
|
|
935
|
$this->{allowed} = $options{allowed};
|
24
|
576
|
|
|
|
|
935
|
$this->{value} = $options{value};
|
25
|
|
|
|
|
|
|
|
26
|
576
|
|
|
|
|
4039
|
$this;
|
27
|
|
|
|
|
|
|
}
|
28
|
|
|
|
|
|
|
|
29
|
718
|
|
|
718
|
1
|
7271
|
sub row { $_[0]->{row} }
|
30
|
718
|
|
|
718
|
1
|
8376
|
sub col { $_[0]->{col} }
|
31
|
83
|
|
|
83
|
1
|
5467
|
sub value { $_[0]->{value} }
|
32
|
87
|
|
|
87
|
1
|
1175
|
sub allowed { @{ $_[0]->{allowed} } }
|
|
87
|
|
|
|
|
370
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub random_value {
|
35
|
461
|
|
|
461
|
1
|
975
|
my $this = shift;
|
36
|
|
|
|
|
|
|
|
37
|
461
|
|
|
|
|
668
|
my @allowed = @{ $this->{allowed} };
|
|
461
|
|
|
|
|
1384
|
|
38
|
461
|
|
|
|
|
1837
|
my $value = splice(@allowed, int(rand(@allowed)), 1);
|
39
|
|
|
|
|
|
|
|
40
|
461
|
|
|
|
|
965
|
$this->{allowed} = \@allowed;
|
41
|
461
|
|
|
|
|
963
|
$this->{value} = $value;
|
42
|
|
|
|
|
|
|
|
43
|
461
|
|
|
|
|
2068
|
$value;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub as_string {
|
47
|
1
|
|
|
1
|
1
|
416
|
my $this = shift;
|
48
|
|
|
|
|
|
|
|
49
|
1
|
|
50
|
|
|
6
|
my $row = $this->{row} || 0;
|
50
|
1
|
|
50
|
|
|
4
|
my $col = $this->{col} || 0;
|
51
|
1
|
|
50
|
|
|
5
|
my $value = $this->{value} || 0;
|
52
|
1
|
|
|
|
|
1
|
my @allowed = @{ $this->{allowed} };
|
|
1
|
|
|
|
|
4
|
|
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
12
|
sprintf('(%d, %d): %d (allowed: %s)',
|
55
|
|
|
|
|
|
|
$row, $col, $value, join(', ', @allowed),
|
56
|
|
|
|
|
|
|
);
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1;
|
61
|
|
|
|
|
|
|
__END__
|