aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-03-23 18:55:16 +0100
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-03-23 18:55:16 +0100
commitd6cdf3086d99b94882b09ed727a42ed3956484ef (patch)
treefd753f4db1f2e5e7777a4b84fe9c80848eee2d3b
parent8c3a7a20aed17e72ee49957028fb85d11cdbd8dd (diff)
downloadperlweeklychallenge-club-d6cdf3086d99b94882b09ed727a42ed3956484ef.tar.gz
perlweeklychallenge-club-d6cdf3086d99b94882b09ed727a42ed3956484ef.tar.bz2
perlweeklychallenge-club-d6cdf3086d99b94882b09ed727a42ed3956484ef.zip
boring solutions
-rw-r--r--challenge-053/markus-holzer/raku/ch-1.p631
-rw-r--r--challenge-053/markus-holzer/raku/ch-2.p633
2 files changed, 64 insertions, 0 deletions
diff --git a/challenge-053/markus-holzer/raku/ch-1.p6 b/challenge-053/markus-holzer/raku/ch-1.p6
new file mode 100644
index 0000000000..4b8305ab24
--- /dev/null
+++ b/challenge-053/markus-holzer/raku/ch-1.p6
@@ -0,0 +1,31 @@
+multi sub MAIN( Int:D $degrees where * ~~ 90|180|270|360 )
+{
+ my @matrix[3,3] = (1..9).batch(3);
+ my $times = $degrees / 90;
+
+ clockwise( @matrix ) for ^$times;
+
+ dd @matrix;
+}
+
+sub clockwise( @matrix )
+{
+ my $n = @matrix.elems;
+ my $x = ($n / 2).floor;
+ my $y = $n - 1;
+
+ for ^$x -> $i
+ {
+ for ^$y -> $j
+ {
+ my $dj = $y - $j;
+ my $di = $y - $i;
+ my $k = @matrix[$i;$j];
+
+ @matrix[ $i; $j ] = @matrix[ $dj; $i ];
+ @matrix[ $dj; $i ] = @matrix[ $di; $dj ];
+ @matrix[ $di; $dj ] = @matrix[ $j; $di ];
+ @matrix[ $j; $di ] = $k;
+ }
+ }
+}; \ No newline at end of file
diff --git a/challenge-053/markus-holzer/raku/ch-2.p6 b/challenge-053/markus-holzer/raku/ch-2.p6
new file mode 100644
index 0000000000..344c61963c
--- /dev/null
+++ b/challenge-053/markus-holzer/raku/ch-2.p6
@@ -0,0 +1,33 @@
+my %rules =
+ :a({ $_ ~~ 'i'|'o' }),
+ :e({ $_ ~~ 'a'|'i'|'u' }),
+ :i({ $_ ~~ 'a'|'e' }),
+ :o({ $_ ~~ 'i'|'u' }),
+ :u({ $_ ~~ 'o'|'i' })
+;
+
+my @vowels = <a e i o u>;
+
+sub MAIN(Int $n)
+{
+ .say for gather { build-str( $n, $_ ) for @vowels }
+}
+
+multi sub build-str( $n, $current )
+{
+ my $last = $current.substr( * - 1, 1 );
+
+ for <a e i o u> -> $vovel
+ {
+ next
+ unless %rules{ $vovel }( $last );
+
+ given $current ~ $vovel
+ {
+ take $_ and next
+ if .chars == $n;
+
+ build-str( $n, $_ );
+ }
+ }
+} \ No newline at end of file