aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-090/simon-proctor/raku/ch-1.raku16
-rw-r--r--challenge-090/simon-proctor/raku/ch-2.raku17
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-090/simon-proctor/raku/ch-1.raku b/challenge-090/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..62d13ce95c
--- /dev/null
+++ b/challenge-090/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+
+use v6;
+
+my $sequence = "GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG";
+
+say nucleotide-count( $sequence );
+say complement( $sequence );
+
+sub nucleotide-count( $sequence ) {
+ return $sequence.comb.Bag.pairs.sort( *.value ).reverse.map( -> $p { "{$p.key} : {$p.value}" } ).join("\n");
+}
+
+sub complement( $sequence ) {
+ with $sequence { return TR/TAGC/ATCG/; }
+}
diff --git a/challenge-090/simon-proctor/raku/ch-2.raku b/challenge-090/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..a15b088f50
--- /dev/null
+++ b/challenge-090/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,17 @@
+#!/usr/bin/env raku
+
+use v6;
+
+#| Given two Integers demonstrate Ethiopian Multiplication with them
+sub MAIN ( UInt $A is copy, UInt $B is copy ) {
+ my @parts;
+ say "Given $A and $B {$A %% 2 ?? '' !! '*'}";
+ @parts.push($B) unless $A %% 2;
+ while ( $A > 1 ) {
+ $A div= 2;
+ $B *= 2;
+ say "Got $A and $B {$A %% 2 ?? '' !! '*'}";
+ @parts.push($B) unless $A %% 2;
+ }
+ say "Adding {@parts.join(",")} to get {[+] @parts}";
+}