diff options
| author | k-mx <cppfero@gmail.com> | 2021-04-26 08:33:11 +0500 |
|---|---|---|
| committer | k-mx <cppfero@gmail.com> | 2021-04-26 08:33:11 +0500 |
| commit | 7c85b9cbd2810d85025495c46ebf4db9c73b0ed9 (patch) | |
| tree | c7ab2cf7b38117b2f6c57d1d6cee8477c93fb9d6 /challenge-109 | |
| parent | 895a9d76deaaebf7e0d63a3e2551b0c1fb1bcd11 (diff) | |
| download | perlweeklychallenge-club-7c85b9cbd2810d85025495c46ebf4db9c73b0ed9.tar.gz perlweeklychallenge-club-7c85b9cbd2810d85025495c46ebf4db9c73b0ed9.tar.bz2 perlweeklychallenge-club-7c85b9cbd2810d85025495c46ebf4db9c73b0ed9.zip | |
Improvement for ch-2.raku by Maxim Kolodyazhny
+space separated arguments list
Diffstat (limited to 'challenge-109')
| -rwxr-xr-x | challenge-109/maxim-kolodyazhny/raku/ch-2.raku | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/challenge-109/maxim-kolodyazhny/raku/ch-2.raku b/challenge-109/maxim-kolodyazhny/raku/ch-2.raku index bc524a2fef..fb1dc3adfe 100755 --- a/challenge-109/maxim-kolodyazhny/raku/ch-2.raku +++ b/challenge-109/maxim-kolodyazhny/raku/ch-2.raku @@ -1,8 +1,8 @@ #!/usr/bin/env raku multi sub MAIN ( $_ where { /\,/ } ) { samewith .split: <,> } -multi sub MAIN ( $_ where { .unique and .all ~~ /^ \d+ $/ and .elems == 7 }) { - .permutations +multi sub MAIN ( *@n where { .unique and .all ~~ /^ \d+ $/ and .elems == 7 }) { + @n.permutations .first({ [==] .rotor( <2 -1 3 -1 3 -1>.pairup )>>.sum }) @@ -11,9 +11,8 @@ multi sub MAIN ( $_ where { .unique and .all ~~ /^ \d+ $/ and .elems == 7 }) { sub USAGE() { print qq:to/EOH/; - Usage: {$*PROGRAM-NAME} [1,2,3...,7] + Usage: {$*PROGRAM-NAME} [1,2,3,...,7] or [1 2 3 ... 7] Prints the answer for "Four Squares Puzzle" EOH } - |
