diff options
author | Andinus <andinus@nand.sh> | 2021-01-20 22:50:59 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-01-20 22:50:59 +0530 |
commit | d744a939d05402d8cdcb5cfec3b2b3073849f8ba (patch) | |
tree | 7196a388519e875c08051d070a94321b227b8045 /lib/Octans/CLI.rakumod | |
parent | 5da030439368ed417694486a9c5275167db1b988 (diff) | |
download | octans-d744a939d05402d8cdcb5cfec3b2b3073849f8ba.tar.gz |
Allow the input puzzle to be of any size
It should still be a 2d grid but can have any number of grids, not necessarily MxN. Even this is a valid input: a b c s d e r c This input should be valid even when parsing the url. It will certainly be valid when the input is a file.
Diffstat (limited to 'lib/Octans/CLI.rakumod')
-rw-r--r-- | lib/Octans/CLI.rakumod | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/Octans/CLI.rakumod b/lib/Octans/CLI.rakumod index 46b1afd..075a57f 100644 --- a/lib/Octans/CLI.rakumod +++ b/lib/Octans/CLI.rakumod @@ -29,22 +29,23 @@ multi sub MAIN ( # @puzzle holds the puzzle. # # @gray-squares holds the list of indexes of valid starting - # positions in the puzzle. ($y, $x) + # positions in the puzzle. my (@puzzle, @gray-squares); # Set the sample puzzle if requested. if $sample { - parse-puzzle( - < n a t k - i m e c - a* r d e - t* e c h >, - @puzzle, @gray-squares - ); + @puzzle = [ + [<n a t k>], + [<i m e c>], + [<a* r d e>], + [<t* e c h>], + ]; } - # Get the puzzle from $path if it's passed. - get-puzzle($_, @puzzle, @gray-squares) with $path; + # Get the puzzle from $path if it's passed. And set @gray-squares. + @puzzle = get-puzzle($_) with $path; + # set-gray-squares also removes asterisks from @puzzle. + @gray-squares = set-gray-squares(@puzzle); # ($y, $x) if $verbose { # Don't print path if using the dictionary included with the |