line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Games::Sudoku::OO::Cell; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1394
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
985
|
|
|
985
|
0
|
1463
|
my $proto = shift; |
9
|
985
|
|
33
|
|
|
4093
|
my $class = ref($proto) || $proto; |
10
|
985
|
|
|
|
|
2854
|
my %args = (possibles=>undef, @_); |
11
|
985
|
|
|
|
|
1749
|
my $self = {}; |
12
|
985
|
|
|
|
|
1319
|
%{$self->{POSSIBLES}} = %{$args{possibles}}; |
|
985
|
|
|
|
|
9843
|
|
|
985
|
|
|
|
|
4382
|
|
13
|
985
|
|
|
|
|
2839
|
$self->{VALUE} = undef; |
14
|
985
|
|
|
|
|
2604
|
bless ($self, $class); |
15
|
985
|
|
|
|
|
3095
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub getValue { |
19
|
44558
|
|
|
44558
|
0
|
58455
|
my $self = shift; |
20
|
44558
|
|
|
|
|
186162
|
return $self->{VALUE}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub setValue { |
24
|
985
|
|
|
985
|
0
|
1319
|
my $self = shift; |
25
|
985
|
|
|
|
|
1537
|
$self->{VALUE} = shift; |
26
|
985
|
|
|
|
|
3156
|
($self->{ROW})->notifySolved($self); |
27
|
985
|
|
|
|
|
3335
|
($self->{COLUMN})->notifySolved($self); |
28
|
985
|
|
|
|
|
3336
|
($self->{SQUARE})->notifySolved($self); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub setRow { |
32
|
985
|
|
|
985
|
0
|
1876
|
my $self=shift; |
33
|
985
|
|
|
|
|
2777
|
$self->{ROW} = shift; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getRow{ |
37
|
10504
|
|
|
10504
|
0
|
14430
|
my $self=shift; |
38
|
10504
|
|
|
|
|
27365
|
return $self->{ROW}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub setColumn{ |
42
|
985
|
|
|
985
|
0
|
1313
|
my $self=shift; |
43
|
985
|
|
|
|
|
4046
|
$self->{COLUMN} = shift; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub getColumn{ |
47
|
10504
|
|
|
10504
|
0
|
14311
|
my $self=shift; |
48
|
10504
|
|
|
|
|
26065
|
return $self->{COLUMN}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub setSquare{ |
52
|
985
|
|
|
985
|
0
|
1431
|
my $self=shift; |
53
|
985
|
|
|
|
|
3371
|
$self->{SQUARE} = shift; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub getSquare{ |
57
|
10504
|
|
|
10504
|
0
|
14737
|
my $self=shift; |
58
|
10504
|
|
|
|
|
26626
|
return $self->{SQUARE}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub couldBe{ |
62
|
17052
|
|
|
17052
|
0
|
22760
|
my $self=shift; |
63
|
17052
|
|
|
|
|
23296
|
my $value=shift; |
64
|
17052
|
|
|
|
|
72515
|
return $self->{POSSIBLES}{$value}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub notPossible { |
68
|
11800
|
|
|
11800
|
0
|
15150
|
my $self = shift; |
69
|
|
|
|
|
|
|
#no point in checking if we already have a value |
70
|
11800
|
50
|
|
|
|
30040
|
if (defined $self->{VALUE}) { |
71
|
0
|
|
|
|
|
0
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
11800
|
|
|
|
|
32328
|
my (@impossible_values) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#remove impossible values |
76
|
11800
|
|
|
|
|
17643
|
foreach my $value (@impossible_values){ |
77
|
11800
|
100
|
|
|
|
52137
|
if (exists $self->{POSSIBLES}{$value}){ |
78
|
|
|
|
|
|
|
#print "deleting $value\n"; |
79
|
4711
|
|
|
|
|
21381
|
delete $self->{POSSIBLES}{$value}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#if there is only one left, we win |
84
|
11800
|
|
|
|
|
16800
|
my @possible_values = keys(%{$self->{POSSIBLES}}); |
|
11800
|
|
|
|
|
46214
|
|
85
|
11800
|
100
|
|
|
|
35360
|
if ($#possible_values == 0){ |
86
|
297
|
|
|
|
|
724
|
$self->setValue($possible_values[0]); |
87
|
|
|
|
|
|
|
} |
88
|
11800
|
|
|
|
|
44651
|
return $#possible_values; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub toStr { |
92
|
961
|
|
|
961
|
0
|
1161
|
my $self = shift; |
93
|
961
|
50
|
|
|
|
2311
|
if (defined $self->{VALUE}){ |
94
|
961
|
|
|
|
|
35303
|
return sprintf ("%X", ($self->{VALUE})); |
95
|
|
|
|
|
|
|
}else { |
96
|
0
|
|
|
|
|
|
my @possibles = map {sprintf "%X", $_} sort { $a <=> $b} keys (%{$self->{POSSIBLES}}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return "(". join (':', @possibles) . ")"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |