aboutsummaryrefslogtreecommitdiff
path: root/challenge-055
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-04-12 18:22:02 +0200
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-04-12 18:22:02 +0200
commita6800294e5e1f28907698beea29bc8753996abe0 (patch)
tree7b043720beb0a7f132186f35e4ceb9e29e5fd47e /challenge-055
parentdca4c603016d8409087921ab43c4fe572d17d5af (diff)
downloadperlweeklychallenge-club-a6800294e5e1f28907698beea29bc8753996abe0.tar.gz
perlweeklychallenge-club-a6800294e5e1f28907698beea29bc8753996abe0.tar.bz2
perlweeklychallenge-club-a6800294e5e1f28907698beea29bc8753996abe0.zip
#2
Diffstat (limited to 'challenge-055')
-rw-r--r--challenge-055/markus-holzer/raku/ch-2.p630
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-055/markus-holzer/raku/ch-2.p6 b/challenge-055/markus-holzer/raku/ch-2.p6
new file mode 100644
index 0000000000..a2bdbe07a4
--- /dev/null
+++ b/challenge-055/markus-holzer/raku/ch-2.p6
@@ -0,0 +1,30 @@
+sub USAGE() {
+ print Q:c:to/EOH/;
+ ch-2.p6 <n1> <n2> <n3> ... <nn>
+
+ Example:
+ ch-2.p6 1 2 3 4
+ EOH
+}
+
+sub MAIN( *@input where *.elems > 1 )
+{
+ CATCH { USAGE() and exit -1; }
+
+ .say for ( @input>>.Int )
+ .permutations
+ .grep: &is-wavy;
+}
+
+sub is-wavy( @n ) returns Bool
+{
+ my $idx = 0;
+ my @cmp = ( * <= * ),
+ ( * >= * );
+
+ not so @n
+ .rotor( 2 => -1 )
+ .first({
+ not @cmp[ $idx = $idx +^ 1 ]( |$_ );
+ });
+} \ No newline at end of file