diff options
| author | juliodcs <julio.dcs@gmail.com> | 2020-11-14 12:17:47 +0100 |
|---|---|---|
| committer | juliodcs <julio.dcs@gmail.com> | 2020-11-14 12:17:47 +0100 |
| commit | 965ebcdfe343395ec7800d5dfe924ad4385b10b5 (patch) | |
| tree | d95e0d452752885fa2e85715e3dd48ee71e3560c | |
| parent | 0cb319be54788e0a76a791fc3c7cedab3e15fdf0 (diff) | |
| download | perlweeklychallenge-club-965ebcdfe343395ec7800d5dfe924ad4385b10b5.tar.gz perlweeklychallenge-club-965ebcdfe343395ec7800d5dfe924ad4385b10b5.tar.bz2 perlweeklychallenge-club-965ebcdfe343395ec7800d5dfe924ad4385b10b5.zip | |
juliodcs-week86
| -rw-r--r-- | challenge-086/juliodcs/raku/ch-2.raku | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/challenge-086/juliodcs/raku/ch-2.raku b/challenge-086/juliodcs/raku/ch-2.raku index ef6d7e99c7..194eab6a9e 100644 --- a/challenge-086/juliodcs/raku/ch-2.raku +++ b/challenge-086/juliodcs/raku/ch-2.raku @@ -65,17 +65,13 @@ sub get-guesses(@sudoku, $y, $x, $last-guess) { my @square := get-square @sudoku, $y, $x;
my @all-nums := (@cross-y, @cross-x, @square).flat.sort.unique.list;
- # This 2 things puzzled me:
- # 1)
- # `grep(-> $guess { 0 == elems @all-nums.grep: * == $guess })`
- # is almost twice as fast as:
- # `grep({ $_ == none @all-nums })`
- #
- # 2) Using `grep(* > $last-guess)` as the first grep, is VERY slow
+ # Using `grep(-> $guess { 0 == elems @all-nums.grep: * == $guess })`
+ # instead of `grep({ $_ == none @all-nums })`
+ # because first is twice as fast
eager (1 .. 9)
==> grep(-> $guess { 0 == elems @all-nums.grep: * == $guess })
- ==> grep(* > $last-guess)
+ ==> grep * > $last-guess
}
# For a (y,x) pair, it returns all the boxes of its inner square
|
