diff options
| -rw-r--r-- | challenge-086/simon-proctor/raku/ch-1.raku | 16 | ||||
| -rw-r--r-- | challenge-086/simon-proctor/raku/ch-2.raku | 21 |
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-086/simon-proctor/raku/ch-1.raku b/challenge-086/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..5a78185a28 --- /dev/null +++ b/challenge-086/simon-proctor/raku/ch-1.raku @@ -0,0 +1,16 @@ +#!/usr/bin/env raku + +use v6; + +#| Given a number and a list of integers return 1 if the numbert is the difference of any two +#| of the integers. Otherwise return 0. +sub MAIN ( + Int $A, #= Difference to look for + *@N where { $_.all ~~ Int }, #= List of integers to check +) { + # First attempt + #say +so (any(@N) - any(@N) == $A); + + # This is about twice as fast when dealing with long lists + say +so any(@N X- @N) == $A; +} diff --git a/challenge-086/simon-proctor/raku/ch-2.raku b/challenge-086/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..bd47d39195 --- /dev/null +++ b/challenge-086/simon-proctor/raku/ch-2.raku @@ -0,0 +1,21 @@ +#!/usr/bin/env raku + +use v6; + +# So.... I wrote a whole module to do this and really can't be bothered doing it again ;) +use Game::Sudoku; +use Game::Sudoku::Solver; + +my %*SUB-MAIN-OPTS = :named-anywhere; + +#! Given a 81 character string of numeric values (with 0 to represent a space) solve the sudoku puzzle +sub MAIN ( + Str $code where {$_ ~~ m/^ \d ** 81 $/ }, #= String of 81 0 to 9's representing the puzzle +) { + my $game = Game::Sudoku.new( :$code ); + say "Starting Grid"; + say $game; + $game = solve-puzzle( $game ); + say "Solution"; + say $game; +} |
