/
ch-1.raku
46 lines (37 loc) · 838 Bytes
/
ch-1.raku
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env raku
=begin comment
----------------------------------------
AUTHOR: Robert DiCicco
DATE : 2023-08-21
Challenge 231 Min Max Task 1 ( Raku )
----------------------------------------
=end comment
use v6;
my @myints = ([3, 2, 1, 4],[3, 1],[2, 1, 3]);
for (@myints) -> @ints {
say "Input: \@ints = ",@ints;
print("Output: ");
if @ints.elems <= 2 {
say "-1\n";
next;
}
my $min = min(@ints);
my $max = max(@ints);
print("( ");
for @ints -> $i {
print("$i ") if ($i > $min and $i < $max);
}
say ")\n";
}
=begin comment
----------------------------------------
SAMPLE OUTPUT
raku .\MinMax.rk
Input: @ints = [3 2 1 4]
Output: ( 3 2 )
Input: @ints = [3 1]
Output: -1
Input: @ints = [2 1 3]
Output: ( 2 )
----------------------------------------
=end comment