Skip to content

Commit

Permalink
primitive horizontal solving
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Sep 5, 2010
1 parent 0f70649 commit fafb94f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Nonogram.pm
Expand Up @@ -82,13 +82,23 @@ method solve-one() {
for @.colspec.kv -> $idx, $col {
next unless $col.elems == 1;
my $c = $col[0];
my $overlaps = 2 * $c - @.rowspec;
my $overlaps = 2 * $c - @!rowspec;
if $overlaps > 0 {
my $lower = @.rowspec - $c;
my $lower = @!rowspec - $c;
my $upper = $lower + $overlaps - 1;
@!field-rows[$_][$idx] = '#' for $lower..$upper;
}
}
for @.rowspec.kv -> $idx, $row {
next unless $row.elems == 1;
my $r = $row[0];
my $overlaps = 2 * $r - @!colspec;
if $overlaps > 0 {
my $lower = @!colspec - $r;
my $upper = $lower + $overlaps - 1;
@!field-rows[$idx][$lower..$upper] = '#' xx $overlaps;
}
}

}

Expand Down

0 comments on commit fafb94f

Please sign in to comment.