| 1 | package Games::Nonogram::Clue; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use base qw( Games::Nonogram::Base ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Games::Nonogram::Line; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Games::Nonogram::Block; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | my $size = $options{size}; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | my $line = Games::Nonogram::Line->new( size => $size ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||
| 17 | id => $options{id}, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | size => $size, | |||||||||||||||||||||||||||||||||||||||||
| 19 | line => $line, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | is_done => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | if ( $options{blocks} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | $self->set( @{ $options{blocks} || [] } ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{'blocks'} || []
MC/DC0%0/1
$options{'blocks'} || []
$options{'blocks'}
Truth table50%1/2
A
A= $options{'blocks'}
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 8 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | sub id { shift->{id} || '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 8 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 8 | my ($self, @clues) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 8 | my $id = 0; | |||||||||||||||||||||||||||||||||||||||||
| 36 | my @blocks = map { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 8 | Games::Nonogram::Block->new( | |||||||||||||||||||||||||||||||||||||||||
| 38 | id => ++$id, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | length => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | line_size => $self->size, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } @clues; | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | $self->{blocks} = \@blocks; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | $self->reset_blocks; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | my $free; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | ▶ | unless ( @blocks ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self->line->off( from => 1, length => $self->size ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $free = 0; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | $free = $blocks[0]->right - $blocks[0]->length; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | $self->{free} = $free; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 13 | ▶ | sub reset_blocks { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_blocks: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 13 | my $left = 1; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 34 | $block->clear; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 34 | $block->left( $left ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 34 | $left += ( $block->length + 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 13 | my $right = $self->size; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 13 | foreach my $block ( reverse $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 71 | 34 | $block->right( $right ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 34 | $right -= ( $block->length + 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 13 | $self->{is_done} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 236 | ▶ | sub blocks { @{ shift->{blocks} || [] } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blocks: called CC=2 SCAR=7.2
Pod
documented
Condition50%1/2
+(shift())->{'blocks'} || []
MC/DC0%0/1
+(shift())->{'blocks'} || []
+(shift())->{'blocks'}
Truth table50%1/2
A
A= +(shift())->{'blocks'}
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 84 | ▶ | sub size { shift->{size} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 264 | ▶ | sub line { shift->{line} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 138 | ▶ | sub block { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
block: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 138 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 138 | $self->{blocks}->[$id]; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 3 | my $str = $self->line->as_string; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | if ( $self->debug ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $str .= ' '. join ' ', map { $_->length } $self->blocks; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | ▶ | sub dump_blocks { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_blocks: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | my $str = $self->id . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 103 | 6 | for my $ct ( 1 .. $self->size ) { | |||||||||||||||||||||||||||||||||||||||||
| 104 | 120 | ▶ | if ( $block->must_have( $ct ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | $str .= "X"; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | elsif ( $block->might_have( $ct ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 38 | $str .= "_"; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 79 | $str .= "."; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | $str .= sprintf " (%s, %s: %s)\n", $block->left, $block->right, $block->length; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | $str .= $self->as_string . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | defined wantarray ? return $str : print $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub is_done { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_done: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | unless ( $self->{is_done} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return unless $self->line->is_done; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->die_if_invalid; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->{is_done} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->{is_done}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub die_if_invalid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
die_if_invalid: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $ct = 1; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | while ( $ct < $block->left ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $value = $self->line->value( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( $value != 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $self->dump_blocks if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | die "failed at $ct: $value != 0"; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $ct++; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | while ( $ct <= $block->right ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $value = $self->line->value( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( $value != 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $self->dump_blocks if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | die "failed at $ct: $value != 1"; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $ct++; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | while ( $ct <= $self->size ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $value = $self->line->value( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( $value != 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $self->dump_blocks if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | die "failed at $ct: $value != 0"; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $ct++; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 8 | ▶ | sub on { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 8 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | $self->line->on( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 8 | my $block = $self->might_have( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | ▶ | return unless ref $block; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 7 | my $offset = $block->length - 1; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 7 | my $left = $id - $offset; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 7 | ▶ | $block->left( $left ) if $block->left < $left; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | my $right = $id + $offset; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 7 | ▶ | $block->right( $right ) if $block->right > $right; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 7 | ▶ | if ( $block->left == $id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | my $left = $block->left; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | $self->line->on( $_ ) for ( $left .. $left + $offset ); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 7 | ▶ | if ( $block->right == $id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | my $right = $block->right; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | $self->line->on( $_ ) for ( $right - $offset .. $right ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 42 | ▶ | sub off { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
off: called CC=5 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 42 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 42 | $self->line->off( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 42 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 201 | 97 | $block->cant_have( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 42 | my $block = $self->might_have( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 42 | ▶ | return unless ref $block; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $offset = $block->length - 1; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $left = $id + 1; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $block->left( $left ) if $block->left + $offset > $left; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $right = $id - 1; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $block->right( $right ) if $block->right - $offset < $right; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my ($self, $id, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( $value == 0 ) { $self->off( $id ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | elsif ( $value == 1 ) { $self->on( $id ) } | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->line->value( $id ); | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 140 | ▶ | sub might_have { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
might_have: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 140 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 140 | my $hit; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 140 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 234 | 347 | ▶ | if ( $block->might_have( $id ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 77 | ▶ | return -1 if $hit; # multiple candidates; cannot decide | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 67 | $hit = $block; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 130 | ▶ | return $hit ? $hit : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 7 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=11 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 7 | my ($self, $mode) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 7 | ▶ | unless ( $mode ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 7 | $self->_update_basic; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | elsif ( $mode eq 'more' ) { | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self->_update_more; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 7 | foreach my $ct ( 1 .. $self->size ) { | |||||||||||||||||||||||||||||||||||||||||
| 254 | 90 | my $block = $self->might_have( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 90 | ▶ | unless ( $block ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 31 | $self->off( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | elsif ( ref $block ) { | |||||||||||||||||||||||||||||||||||||||||
| 260 | 50 | my $value = $self->line->value( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | 50 | ▶ | if ( $value == -1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 43 | ▶ | $self->on( $ct ) if $block->must_have( $ct ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | elsif ( $value == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->off( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | elsif ( $value == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 7 | ▶ | $self->on( $ct ) unless $block->must_have( $ct ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 7 | ▶ | sub _update_basic { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_basic: called CC=17 SCAR=28.8
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 7 | my $left = 1; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 7 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 279 | 19 | ▶ | $left = $block->left if $block->left > $left; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 19 | ▶ | while ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->line->value($left) == 0 or $left > 1 and $self->line->value($left - 1) == 1
$left > 1 and $self->line->value($left - 1) == 1
MC/DC66%2/3
$self->line->value($left) == 0 or $left > 1 and $self->line->value($left - 1) == 1
$self->line->value($left) == 0
$left > 1
$self->line->value($left - 1) == 1
Truth table75%3/4
A or B and C
A= $self->line->value($left) == 0B= $left > 1C= $self->line->value($left - 1) == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | $self->line->value( $left ) == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 282 | or | ||||||||||||||||||||||||||||||||||||||||||
| 283 | $left > 1 && $self->line->value( $left - 1 ) == 1 | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | $left++; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | ▶ | if ( $left > $self->size ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | die "puzzle data may be broken, unless you're trying to solve by brute force"; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 19 | $block->left( $left ); | |||||||||||||||||||||||||||||||||||||||||
| 292 | 19 | $left += ( $block->length + 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 7 | my $right = $self->size; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 7 | foreach my $block ( reverse $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 297 | 19 | ▶ | $right = $block->right if $block->right < $right; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 19 | ▶ | while ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->line->value($right) == 0 or $right < $self->size and $self->line->value($right + 1) == 1
$right < $self->size and $self->line->value($right + 1) == 1
MC/DC33%1/3
$self->line->value($right) == 0 or $right < $self->size and $self->line->value($right + 1) == 1
$self->line->value($right) == 0
$right < $self->size
$self->line->value($right + 1) == 1
Truth table75%3/4
A or B and C
A= $self->line->value($right) == 0B= $right < $self->sizeC= $self->line->value($right + 1) == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | $self->line->value( $right ) == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 301 | or | ||||||||||||||||||||||||||||||||||||||||||
| 302 | $right < $self->size && $self->line->value( $right + 1 ) == 1 | ||||||||||||||||||||||||||||||||||||||||||
| 303 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | $right--; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | if ( $right < 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | die "puzzle data may be broken, unless you're trying to solve by brute force"; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 19 | $block->right( $right ); | |||||||||||||||||||||||||||||||||||||||||
| 311 | 19 | $right -= ( $block->length + 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 7 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 315 | 19 | my ($from, $length) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 19 | foreach my $ct ( $block->left .. $block->right ) { | |||||||||||||||||||||||||||||||||||||||||
| 317 | 76 | my $value = $self->line->value( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 318 | 76 | ▶ | if ( $value == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 9 | ▶ | $from ||= $ct; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$from ||= $ct
MC/DC0%0/2
$from ||= $ct
$from
$ct
Truth table66%2/3
A ||= B
A= $fromB= $ct
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 9 | $length++; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 67 | $block->try( $from, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 67 | ($from, $length) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 19 | $block->try( $from, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub _update_more { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_more: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my ($toggle, $from, @blocks); | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | foreach my $ct ( 1 .. $self->size ) { | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | $from ||= $ct; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$from ||= $ct
MC/DC0%0/2
$from ||= $ct
$from
$ct
Truth table0%0/3
A ||= B
A= $fromB= $ct
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $value = $self->line->value( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | if ( $value == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $toggle = 1; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | elsif ( $value == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ( $toggle ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | push @blocks, { from => $from, to => $ct - 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $from = $toggle = 0; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if ( $toggle ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | push @blocks, { from => $from, to => $self->size }; | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ( @blocks == $self->blocks ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | foreach my $block ( $self->blocks ) { | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $href = shift @blocks; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | $block->left( $href->{from} ) if $block->left < $href->{from}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | $block->right( $href->{to} ) if $block->right > $href->{to}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | ▶ | sub candidates { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
candidates: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | my @candidates = $self->_candidates( | ||||||||||||||||||||||||||||||||||||||||||
| 366 | $self->line->clone, | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 1, | ||||||||||||||||||||||||||||||||||||||||||
| 368 | $self->{free}, | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | $self->blocks | |||||||||||||||||||||||||||||||||||||||||
| 370 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | ▶ | sub _candidates { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_candidates: called CC=17 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 6 | my ($self, $line, $pos, $free, @blocks) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 6 | my $clone = $line->clone; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 6 | ▶ | unless ( $free ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | ▶ | while( my $block = shift @blocks ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 3 | foreach my $ct ( 0 .. $block->length - 1 ) { | |||||||||||||||||||||||||||||||||||||||||
| 380 | 9 | ▶ | return if $clone->value( $pos + $ct ) == 0; # conflicted; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 9 | $clone->on( $pos + $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | $pos += $block->length; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 3 | ▶ | unless ( $pos > $self->size ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | ▶ | return if $clone->value( $pos ) == 1; # conflicted; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | $clone->off( $pos ); | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | $pos++; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 6 | ▶ | unless ( @blocks ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 3 | foreach my $ct ( $pos .. $self->size ) { | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | return if $clone->value( $ct ) == 1; # conflicted | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $clone->off( $ct ); | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | return $clone->as_vec; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | my @candidates; | |||||||||||||||||||||||||||||||||||||||||
| 400 | LOOP: | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | foreach my $ct ( 0 .. $free ) { | |||||||||||||||||||||||||||||||||||||||||
| 402 | 6 | $clone = $line->clone; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 6 | my @clone_blocks = @blocks; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 6 | my $clone_pos = $pos; | |||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 6 | foreach my $space_ct ( 1 .. $ct ) { | |||||||||||||||||||||||||||||||||||||||||
| 407 | 3 | ▶ | next LOOP if $clone->value( $clone_pos ) == 1; # conflicted | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 3 | $clone->off( $clone_pos ); | |||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | $clone_pos++; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 6 | my $block = shift @clone_blocks; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 6 | foreach my $block_ct ( 1 .. $block->length ) { | |||||||||||||||||||||||||||||||||||||||||
| 414 | 14 | ▶ | next LOOP if $clone->value( $clone_pos ) == 0; # conflicted | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 14 | $clone->on( $clone_pos ); | |||||||||||||||||||||||||||||||||||||||||
| 416 | 14 | $clone_pos++; | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 6 | ▶ | unless ( $clone_pos > $self->size ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 5 | ▶ | next LOOP if $clone->value( $clone_pos ) == 1; # conflicted | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 5 | $clone->off( $clone_pos ); | |||||||||||||||||||||||||||||||||||||||||
| 421 | 5 | $clone_pos++; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 5 | push @candidates, $self->_candidates( | |||||||||||||||||||||||||||||||||||||||||
| 424 | $clone, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | $clone_pos, | ||||||||||||||||||||||||||||||||||||||||||
| 426 | $free - $ct, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | @clone_blocks | ||||||||||||||||||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | push @candidates, $clone->as_vec; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | return @candidates; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | __END__ | ||||||||||||||||||||||||||||||||||||||||||