blob: 03576538cc87821ee22b5fc78b4c58b6ad3ac9cd (
plain)
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
|
#! /usr/bin/env raku
unit sub MAIN (*@integers where all(@integers) ~~ Int, :$verbose);
for @integers.permutations.unique(:with(&[eqv])) -> @list
{
say ": Checking @list[]" if $verbose;
say @list if is-wave(@list);
}
sub is-wave(@list)
{
my $current = @list[0];
my $greater = False;
for @list[1 .. *] -> $next
{
if $greater
{
($current = $next; return False) if $next < $current;
}
else
{
($current = $next; return False) if $next > $current;
}
$current = $next;
$greater = ! $greater;
}
return True;
}
|