Skip to content

Commit 013e597

Browse files
authored
Merge pull request #1 from ash/ash-231
231 solved in Raku by ash
2 parents 94bfe5c + 6761564 commit 013e597

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

challenge-231/ash/raku/blog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://andrewshitov.com/2023/08/21/a-couple-of-tasks-solved-in-raku/

challenge-231/ash/raku/ch-1.raku

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Solution to Task 1 of the Weekly Challenge 231
2+
# https://theweeklychallenge.org/blog/perl-weekly-challenge-231/#TASK1
3+
4+
# Description:
5+
# https://andrewshitov.com/2023/08/21/a-couple-of-tasks-solved-in-raku/
6+
7+
# Test run:
8+
# $ raku ch-1.raku
9+
# (3 2)
10+
# -1
11+
# (2)
12+
13+
14+
# sub solve(@data) {
15+
# @data.grep: * != (@data.min, @data.max).any
16+
# }
17+
18+
# sub solve(@data) {
19+
# (@data.grep: * != (@data.min, @data.max).any) || -1
20+
# }
21+
22+
sub solve(@data) {
23+
(@data.grep: * (@data.min, @data.max)) || -1
24+
}
25+
26+
my @tests = (3, 2, 1, 4), (3, 1), (2, 1, 3);
27+
say solve($_) for @tests;

challenge-231/ash/raku/ch-2.raku

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Solution to Task 2 of the Weekly Challenge 231
2+
# https://theweeklychallenge.org/blog/perl-weekly-challenge-231/#TASK2
3+
4+
# Description:
5+
# https://andrewshitov.com/2023/08/21/a-couple-of-tasks-solved-in-raku/
6+
7+
# Test run:
8+
# $ raku ch-2.raku
9+
# 2
10+
# 0
11+
12+
13+
sub is-sinior($ticket) {
14+
~($ticket ~~ / <alpha> (\d\d) /)[0] >= 75
15+
}
16+
17+
my @tests = ('7868190130M7522', '5303914400F9211', '9273338290F4010'),
18+
('1313579440F2036', '2921522980M5644');
19+
20+
21+
for @tests -> @tickets {
22+
say +@tickets.grep({is-sinior($_)});
23+
}

0 commit comments

Comments
 (0)