Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

primitive horizontal solving

  • Loading branch information...
commit fafb94f5a801a410548915c28cd43d3227d27aa2 1 parent 0f70649
Moritz Lenz authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/Nonogram.pm
14 lib/Nonogram.pm
View
@@ -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;
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.