about summary refs log tree commit diff stats
path: root/resources/solutions/DFS-32.fornax
Commit message (Expand)AuthorAgeFilesLines
* java/DFS: Don't walk on visited, Add DFS solutions, change colorsAndinus2021-11-031-0/+13
Allow the input puzzle to be of any size' href='/andinus/octans/commit/lib/Octans/Puzzle.rakumod?h=v0.2.1&id=d744a939d05402d8cdcb5cfec3b2b3073849f8ba'>d744a93 ^
02cd965 ^
5bb0f22 ^
02cd965 ^
4c77f33 ^

bdb1dbc ^

adba877 ^
bdb1dbc ^


5bb0f22 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26












                                                               
             
         
     
 

                                             

                                                              
                                                            


                                                
 
class Puzzle is export {
    has @.grids;
    has @!gray-squares;

    submethod TWEAK() {
        for 0 .. @!grids.end -> $y {
            for 0 .. @!grids[$y].end -> $x {
                # Remove the markers from the puzzle & push the
                # positions to @!gray-squares.
                if @!grids[$y][$x].match("*") -> $match {
                    @!grids[$y][$x] = $match.replace-with("");
                    push @!gray-squares, ($y, $x);
                }
            }
        }
    }

    # Accessor for @!gray-squares.
    method gray-squares() { @!gray-squares; }

    # Given $y, $x where $y is row index & $x is column index,
    # is-gray-square returns if the square is a gray square.
    method is-gray-square(Int $y, Int $x) {
        return so @!gray-squares.grep(($y, $x));
    }
}