aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-03-23 18:13:50 +0000
committerGitHub <noreply@github.com>2020-03-23 18:13:50 +0000
commit3de6c1046b20cb6c29aee17a454365f5f5bf5f96 (patch)
treee1f7246d00f0133a466f748b5d77c4ed8f765bed
parent6734e291854856fc3229a8213cad1976ac89efba (diff)
parent59dfb47fb0716ff17bfc9889eb7f2e4dbf347d78 (diff)
downloadperlweeklychallenge-club-3de6c1046b20cb6c29aee17a454365f5f5bf5f96.tar.gz
perlweeklychallenge-club-3de6c1046b20cb6c29aee17a454365f5f5bf5f96.tar.bz2
perlweeklychallenge-club-3de6c1046b20cb6c29aee17a454365f5f5bf5f96.zip
Merge pull request #1455 from holli-holzer/master
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..b9998bf735
--- /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..ff0d8689a6
--- /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 @vowels
+ {
+ next
+ unless %rules{ $_ }( $last );
+
+ given $current ~ $_
+ {
+ take $_ and next
+ if .chars == $n;
+
+ build-str( $n, $_ );
+ }
+ }
+} \ No newline at end of file