Changeset 20772 for ext

Show
Ignore:
Timestamp:
06/12/08 21:36:49 (7 months ago)
Author:
moritz
Message:

[ext/Sudoku] no need for 'my' in pointy blocks

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ext/Sudoku/lib/Sudoku.pm

    r16634 r20772  
    8787    $!delimiter ~= "\n"; 
    8888 
    89     for (0 .. $!length - 1) -> my $i { 
     89    for (0 .. $!length - 1) > $i { 
    9090        #columns: 
    9191        push @!constraint, [($i xx $!length) Z (0 .. $!length - 1)]; 
     
    128128#        $s.chars == $!length*$!length; 
    129129#    } 
    130     for (0 .. $!length*$!length-1) -> my $i { 
     130    for (0 .. $!length*$!length-1) -> $i { 
    131131        if +$s.substr($i, 1) { 
    132132            self.set_item(+$s.substr($i, 1), $i % $!length, int($i / $!length)); 
     
    159159    # constraint propagation 
    160160    # no more numbers are allowed where the current number is set 
    161     for (0 .. $!length - 1) -> my $i { 
     161    for (0 .. $!length - 1) -> $i { 
    162162        @!allowed[$x][$y][$i] = 0; 
    163163    } 
    164164 
    165165    # propagation in the rest: 
    166     for @!constraint -> my $c { 
     166    for @!constraint -> $c { 
    167167        my $in = 0; 
    168         for @$c -> my $cell { 
     168        for @$c -> $cell { 
    169169            if $cell[0] == $x and $cell[1] == $y { 
    170170                $in = 1; 
     
    174174         
    175175        if $in { 
    176             for @$c -> my $cell { 
     176            for @$c -> $cell { 
    177177                @!allowed[$cell[0]][$cell[1]][$elem-1] = 0; 
    178178            } 
     
    286286method simple_solve1($self:) { 
    287287    my $success = 0; 
    288     for (0 .. $!length - 1) -> my $x { 
    289         for (0 .. $!length -1) -> my $y { 
     288    for (0 .. $!length - 1) -> $x { 
     289        for (0 .. $!length -1) -> $y { 
    290290            my $count = 0; 
    291291            my $pointer = 0; 
    292             for (0 .. $!length - 1) -> my $num { 
     292            for (0 .. $!length - 1) -> $num { 
    293293                if @!allowed[$x][$y][$num - 1] { 
    294294                    $count++; 
     
    316316    my $success = 0; 
    317317 
    318     for @!constraint -> my $c { 
    319         for (1 .. $!length)-> my $num { 
     318    for @!constraint -> $c { 
     319        for (1 .. $!length)-> $num { 
    320320            my $x; 
    321321            my $y; 
    322322            my $count = 0; 
    323             for @$c -> my $tupel { 
     323            for @$c -> $tupel { 
    324324                if @!allowed[$tupel[0]][$tupel[1]][$num - 1] { 
    325325                    $count++; 
     
    343343 
    344344method is_solved { 
    345     for (0 .. $!length - 1) -> my $x { 
    346         for (0 .. $!length - 1) -> my $y { 
     345    for (0 .. $!length - 1) -> $x { 
     346        for (0 .. $!length - 1) -> $y { 
    347347            return 0 if @.field[$x][$y] == 0; 
    348348        } 
     
    359359method backtrack($self:) { 
    360360#    say "backtracking..."; 
    361     for (0 .. $!length - 1) -> my $x { 
    362         for (0 .. $!length - 1) -> my $y { 
     361    for (0 .. $!length - 1) -> $x { 
     362        for (0 .. $!length - 1) -> $y { 
    363363            if @.field[$x][$y] == 0 { 
    364364                # found an empty positon, let's backtrack here! 
    365365#                say "Backtracking at ($x, $y)"; 
    366                 for (1 .. $!length) -> my $num { 
     366                for (1 .. $!length) -> $num { 
    367367                    if $self.is_allowed($num, $x, $y) { 
    368368#                        say "found";