From b2142f9dbfe0bec3146ea3ef6bd76241438b167e Mon Sep 17 00:00:00 2001 From: Garrett Goebel Date: Tue, 8 Dec 2020 18:43:48 -0500 Subject: challenge-090 Raku --- challenge-090/garrett-goebel/README | 1 + challenge-090/garrett-goebel/raku/ch-1.raku | 2 ++ challenge-090/garrett-goebel/raku/ch-2.raku | 2 ++ 3 files changed, 5 insertions(+) create mode 100644 challenge-090/garrett-goebel/README create mode 100644 challenge-090/garrett-goebel/raku/ch-1.raku create mode 100644 challenge-090/garrett-goebel/raku/ch-2.raku (limited to 'challenge-090') diff --git a/challenge-090/garrett-goebel/README b/challenge-090/garrett-goebel/README new file mode 100644 index 0000000000..a8aa246dbb --- /dev/null +++ b/challenge-090/garrett-goebel/README @@ -0,0 +1 @@ +Solution by Garrett Goebel diff --git a/challenge-090/garrett-goebel/raku/ch-1.raku b/challenge-090/garrett-goebel/raku/ch-1.raku new file mode 100644 index 0000000000..7c034427ea --- /dev/null +++ b/challenge-090/garrett-goebel/raku/ch-1.raku @@ -0,0 +1,2 @@ +#!/usr/bin/env raku +'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG'.comb.elems.say; diff --git a/challenge-090/garrett-goebel/raku/ch-2.raku b/challenge-090/garrett-goebel/raku/ch-2.raku new file mode 100644 index 0000000000..b955dd9446 --- /dev/null +++ b/challenge-090/garrett-goebel/raku/ch-2.raku @@ -0,0 +1,2 @@ +#!/usr/bin/env raku +say TR/TAGC/ATCG/ with 'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG'; -- cgit From e37762846b7c44fdcafb9d58edf3a7b5f2246747 Mon Sep 17 00:00:00 2001 From: Garrett Goebel Date: Tue, 8 Dec 2020 18:53:48 -0500 Subject: challenge-090 Task 1 Raku --- challenge-090/garrett-goebel/raku/ch-1.raku | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'challenge-090') diff --git a/challenge-090/garrett-goebel/raku/ch-1.raku b/challenge-090/garrett-goebel/raku/ch-1.raku index 7c034427ea..00c9d0df57 100644 --- a/challenge-090/garrett-goebel/raku/ch-1.raku +++ b/challenge-090/garrett-goebel/raku/ch-1.raku @@ -1,2 +1,5 @@ #!/usr/bin/env raku -'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG'.comb.elems.say; +'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG'.&{ + say 'Nucleiobase count: ' ~ .comb.elems; + say 'Complementary sequence: ' ~ TR/TAGC/ATCG/; +} -- cgit From 07d9a1cb90b8268487449bc1a109a001787ce3f1 Mon Sep 17 00:00:00 2001 From: Garrett Goebel Date: Tue, 8 Dec 2020 19:33:20 -0500 Subject: challenge-090 Task 2 Raku --- challenge-090/garrett-goebel/raku/ch-2.raku | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'challenge-090') diff --git a/challenge-090/garrett-goebel/raku/ch-2.raku b/challenge-090/garrett-goebel/raku/ch-2.raku index b955dd9446..35324621de 100644 --- a/challenge-090/garrett-goebel/raku/ch-2.raku +++ b/challenge-090/garrett-goebel/raku/ch-2.raku @@ -1,2 +1,17 @@ #!/usr/bin/env raku -say TR/TAGC/ATCG/ with 'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG'; + +unit sub MAIN (Int $A where {$A > 0} = 14, Int $B where {$B > 0} = 12); + +my ($a, $b, $r) = ($A, $B, 0); # command line args are immutable + +say "$a & $b"; + +if ($a > 1) { + repeat { + $r += $b if $a mod 2; + say "{ $a div= 2 } & { $b *= 2 } | r: $r"; + } while $a > 1; +} +$r += $b; + +say "r: $r"; -- cgit From 84fd44fc915d5ea833e83d2a91114553c18e9438 Mon Sep 17 00:00:00 2001 From: Garrett Goebel Date: Tue, 8 Dec 2020 19:51:18 -0500 Subject: challenge-090 Task 2 Raku tweaks --- challenge-090/garrett-goebel/raku/ch-2.raku | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'challenge-090') diff --git a/challenge-090/garrett-goebel/raku/ch-2.raku b/challenge-090/garrett-goebel/raku/ch-2.raku index 35324621de..dede70ec31 100644 --- a/challenge-090/garrett-goebel/raku/ch-2.raku +++ b/challenge-090/garrett-goebel/raku/ch-2.raku @@ -1,17 +1,19 @@ #!/usr/bin/env raku -unit sub MAIN (Int $A where {$A > 0} = 14, Int $B where {$B > 0} = 12); +unit sub MAIN ( + Int $A is copy where $A > 0 = 14, + Int $B is copy where $B > 0 = 12 +); -my ($a, $b, $r) = ($A, $B, 0); # command line args are immutable +my Int $r = 0; +my $format = "%10d & %10d | product: %10d\n"; +$format.printf($A,$B, $r); -say "$a & $b"; - -if ($a > 1) { +if ($A > 1) { repeat { - $r += $b if $a mod 2; - say "{ $a div= 2 } & { $b *= 2 } | r: $r"; - } while $a > 1; + $r += $B if $A mod 2; + $format.printf($A div= 2, $B *= 2, $r); + } while $A > 1; } -$r += $b; - -say "r: $r"; +$r += $B; +~(' ' x 24 ~ "| product: %10d\n").printf($r); -- cgit