aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2021-04-22 08:39:25 +0200
committerLuca Ferrari <fluca1978@gmail.com>2021-04-22 08:39:25 +0200
commit66c7224b6dc440254b7943e0dd2071859b9ad2ba (patch)
tree438998253f27dd029765cb45f9f4515cab5575a7
parent017d83232eceea139a731ac11c92229e42f2953b (diff)
downloadperlweeklychallenge-club-66c7224b6dc440254b7943e0dd2071859b9ad2ba.tar.gz
perlweeklychallenge-club-66c7224b6dc440254b7943e0dd2071859b9ad2ba.tar.bz2
perlweeklychallenge-club-66c7224b6dc440254b7943e0dd2071859b9ad2ba.zip
Use ranges everywhere
-rw-r--r--challenge-109/luca-ferrari/raku/ch-2.p612
1 files changed, 6 insertions, 6 deletions
diff --git a/challenge-109/luca-ferrari/raku/ch-2.p6 b/challenge-109/luca-ferrari/raku/ch-2.p6
index 15cc86739b..d25c5c1333 100644
--- a/challenge-109/luca-ferrari/raku/ch-2.p6
+++ b/challenge-109/luca-ferrari/raku/ch-2.p6
@@ -2,7 +2,7 @@
sub MAIN( *@nums where { @nums.grep( * ~~ Int ).elems == @nums.elems && @nums.elems == 7 } ) {
- my @letters = <a b c d e f g>;
+ my @letters = 'a' .. 'g';
my @solutions;
# permutate all numbers to find out the correct sum
@@ -13,14 +13,14 @@ sub MAIN( *@nums where { @nums.grep( * ~~ Int ).elems == @nums.elems && @nums.e
# compute the sums
my @sums;
- @sums.push: [+] %squares<a b>;
- @sums.push: [+] %squares<b c d>;
- @sums.push: [+] %squares<d e f>;
- @sums.push: [+] %squares<f g>;
+ @sums.push: [+] %squares{ 'a' .. 'b' };
+ @sums.push: [+] %squares{ 'b' .. 'd' };
+ @sums.push: [+] %squares{ 'd' .. 'f' };
+ @sums.push: [+] %squares{ 'f' .. 'g' };
# if the first sum is equal to all the others, push this solution
- @solutions.push: %squares if @sums[ 0 ] == all @sums;
+ @solutions.push: %squares if @sums[ 0 ] == all @sums[ 1 .. * ];
}