From fa5731052dcccec7fd0c77d96266690d2841b815 Mon Sep 17 00:00:00 2001 From: Tyler Wardhaugh Date: Mon, 7 Dec 2020 12:06:06 -0800 Subject: Ch90: prep for challenge --- challenge-090/tyler-wardhaugh/clojure/README.md | 10 +++++----- challenge-090/tyler-wardhaugh/clojure/deps.edn | 10 +++------- challenge-090/tyler-wardhaugh/clojure/pom.xml | 24 +++++++----------------- challenge-090/tyler-wardhaugh/lua/README.md | 6 +++--- 4 files changed, 18 insertions(+), 32 deletions(-) diff --git a/challenge-090/tyler-wardhaugh/clojure/README.md b/challenge-090/tyler-wardhaugh/clojure/README.md index f5a89af18d..41000b8199 100644 --- a/challenge-090/tyler-wardhaugh/clojure/README.md +++ b/challenge-090/tyler-wardhaugh/clojure/README.md @@ -1,13 +1,13 @@ -# tw.weekly.c89 +# tw.weekly.c90 -The Weekly Challenge - #089 - Tyler Wardhaugh +The Weekly Challenge - #090 - Tyler Wardhaugh ## Usage Run the project directly (shows default output from both tasks): - $ clojure -M -m tw.weekly.c89.core + $ clojure -M -m tw.weekly.c90.core Run the project's tests (which are samples from the task descriptions): @@ -15,11 +15,11 @@ Run the project's tests (which are samples from the task descriptions): Run Task #1 with input - $ clojure -M -m tw.weekly.c89.t1 N + $ clojure -M -m tw.weekly.c90.t1 DNA Run Task #2: - $ clojure -M -m tw.weekly.c89.t2 + $ clojure -M -m tw.weekly.c90.t2 A B ## Project Template diff --git a/challenge-090/tyler-wardhaugh/clojure/deps.edn b/challenge-090/tyler-wardhaugh/clojure/deps.edn index cfd5d782d1..1fae9ef933 100644 --- a/challenge-090/tyler-wardhaugh/clojure/deps.edn +++ b/challenge-090/tyler-wardhaugh/clojure/deps.edn @@ -1,9 +1,5 @@ {:paths ["src" "resources"] - :deps {org.clojure/clojure {:mvn/version "1.10.1"} - org.clojure/core.logic {:mvn/version "1.0.0"} - org.clojure/math.combinatorics {:mvn/version "0.1.6"} - org.clojure/math.numeric-tower {:mvn/version "0.0.4"} - org.clojure/tools.macro {:mvn/version "0.1.2"}} + :deps {org.clojure/clojure {:mvn/version "1.10.1"}} :aliases {:test {:extra-paths ["test"] :extra-deps {org.clojure/test.check {:mvn/version "1.0.0"}}} @@ -14,5 +10,5 @@ :main-opts ["-m" "cognitect.test-runner" "-d" "test"]} :uberjar {:extra-deps {seancorfield/depstar {:mvn/version "1.0.94"}} - :main-opts ["-m" "hf.depstar.uberjar" "tw.weekly.c88.jar" - "-C" "-m" "tw.weekly.c88"]}}} + :main-opts ["-m" "hf.depstar.uberjar" "tw.weekly.c90.jar" + "-C" "-m" "tw.weekly.c90"]}}} diff --git a/challenge-090/tyler-wardhaugh/clojure/pom.xml b/challenge-090/tyler-wardhaugh/clojure/pom.xml index 3097f51f8e..bc8a82e4cd 100644 --- a/challenge-090/tyler-wardhaugh/clojure/pom.xml +++ b/challenge-090/tyler-wardhaugh/clojure/pom.xml @@ -2,11 +2,11 @@ 4.0.0 tw.weekly - tw.weekly.c89 + tw.weekly.c90 0.1.0-SNAPSHOT - tw.weekly.c89 - Challenge #089 - https://github.com/tw.weekly/tw.weekly.c89 + tw.weekly.c90 + Challenge #090 + https://github.com/tw.weekly/tw.weekly.c90 Eclipse Public License @@ -19,9 +19,9 @@ - https://github.com/tw.weekly/tw.weekly.c89 - scm:git:git://github.com/tw.weekly/tw.weekly.c89.git - scm:git:ssh://git@github.com/tw.weekly/tw.weekly.c89.git + https://github.com/tw.weekly/tw.weekly.c90 + scm:git:git://github.com/tw.weekly/tw.weekly.c90.git + scm:git:ssh://git@github.com/tw.weekly/tw.weekly.c90.git HEAD @@ -30,16 +30,6 @@ clojure 1.10.1 - - net.mikera - core.matrix - 0.62.0 - - - org.clojure - math.numeric-tower - 0.0.4 - src diff --git a/challenge-090/tyler-wardhaugh/lua/README.md b/challenge-090/tyler-wardhaugh/lua/README.md index d2f91b15fe..8772dac9c1 100644 --- a/challenge-090/tyler-wardhaugh/lua/README.md +++ b/challenge-090/tyler-wardhaugh/lua/README.md @@ -1,17 +1,17 @@ # The Weekly Challenge -The Weekly Challenge - #089 - Tyler Wardhaugh +The Weekly Challenge - #090 - Tyler Wardhaugh ## Usage Run Task 1: - $ ./run.lua ch-1 N + $ ./run.lua ch-1 DNA Run Task 2: - $ ./run.lua ch-2 MATRIX-FILE + $ ./run.lua ch-2 A B Run the project's tests (all the samples from the task descriptions plus some others): -- cgit From d6eeb2228b999315263e96d4b00bdf6f8d7c090e Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Mon, 7 Dec 2020 14:26:21 -0600 Subject: Challenge 90 Raku solutions --- challenge-090/aaronreidsmith/raku/ch-1.raku | 14 ++++++++++++++ challenge-090/aaronreidsmith/raku/ch-2.raku | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 challenge-090/aaronreidsmith/raku/ch-1.raku create mode 100644 challenge-090/aaronreidsmith/raku/ch-2.raku diff --git a/challenge-090/aaronreidsmith/raku/ch-1.raku b/challenge-090/aaronreidsmith/raku/ch-1.raku new file mode 100644 index 0000000000..96adad1541 --- /dev/null +++ b/challenge-090/aaronreidsmith/raku/ch-1.raku @@ -0,0 +1,14 @@ +#!/usr/bin/env perl6 + +subset ValidDna of Str where { $_ ~~ /^^[A|T|G|C]+$$/ } + +# Since DNA is generally read from 5' to 3', I included the option to find the +# reverse compliment in addition to the complement +sub MAIN($dna where $dna ~~ ValidDna, Bool :rc(:$reverse-complement) = False) { + my $translated = $dna.trans('ATGC' => 'TACG'); + if $reverse-complement { + say "5'-{$translated.reverse}-3'"; + } else { + say "3'-$translated-5'" + } +} diff --git a/challenge-090/aaronreidsmith/raku/ch-2.raku b/challenge-090/aaronreidsmith/raku/ch-2.raku new file mode 100644 index 0000000000..cc85350dc6 --- /dev/null +++ b/challenge-090/aaronreidsmith/raku/ch-2.raku @@ -0,0 +1,21 @@ +#!/usr/bin/env perl6 + +subset PositiveInt of Int where { $_ ~~ Int && $_ > 0 } + +sub generate-pairs($a, $b) { + sprintf("%02d, %02d", $a, $b).put; + if $a == 1 { + (($a, $b),); + } else { + (($a, $b), |generate-pairs($a div 2, $b * 2)); + } +} + +sub MAIN(PositiveInt $A, PositiveInt $B) { + say "Input: A: $A, B: $B"; + say "Divide A by 2 (ignoring remainders) until it is 1. Multiply B by 2 as we go:"; + my @pairs = generate-pairs($A, $B); + say "Then, wherever A is odd, we add the Bs together:"; + my @odd-bs = @pairs.grep(-> @pair { !(@pair[0] %% 2) }).map(-> @pair { @pair[1] }); + say "{@odd-bs.join(' + ')} = {@odd-bs.sum}"; +} -- cgit From f3bc094d3c6a7cfafdcdcb64298cb078a90e6d66 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Mon, 7 Dec 2020 14:53:35 -0600 Subject: reverse -> flip --- challenge-090/aaronreidsmith/raku/ch-1.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-090/aaronreidsmith/raku/ch-1.raku b/challenge-090/aaronreidsmith/raku/ch-1.raku index 96adad1541..b0c53e239a 100644 --- a/challenge-090/aaronreidsmith/raku/ch-1.raku +++ b/challenge-090/aaronreidsmith/raku/ch-1.raku @@ -7,7 +7,7 @@ subset ValidDna of Str where { $_ ~~ /^^[A|T|G|C]+$$/ } sub MAIN($dna where $dna ~~ ValidDna, Bool :rc(:$reverse-complement) = False) { my $translated = $dna.trans('ATGC' => 'TACG'); if $reverse-complement { - say "5'-{$translated.reverse}-3'"; + say "5'-{$translated.flip}-3'"; } else { say "3'-$translated-5'" } -- cgit From 0876e01a876b7e4a1cc523d2af1524663106f22f Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Mon, 7 Dec 2020 15:18:07 -0600 Subject: Format output --- challenge-090/aaronreidsmith/raku/ch-2.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-090/aaronreidsmith/raku/ch-2.raku b/challenge-090/aaronreidsmith/raku/ch-2.raku index cc85350dc6..fa5fe375c6 100644 --- a/challenge-090/aaronreidsmith/raku/ch-2.raku +++ b/challenge-090/aaronreidsmith/raku/ch-2.raku @@ -12,7 +12,7 @@ sub generate-pairs($a, $b) { } sub MAIN(PositiveInt $A, PositiveInt $B) { - say "Input: A: $A, B: $B"; + say "Input: A=$A, B=$B"; say "Divide A by 2 (ignoring remainders) until it is 1. Multiply B by 2 as we go:"; my @pairs = generate-pairs($A, $B); say "Then, wherever A is odd, we add the Bs together:"; -- cgit From 42e642d8c70a32352d990d8490a46fe10c0c9b86 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Mon, 7 Dec 2020 15:43:03 -0600 Subject: Add input stats --- challenge-090/aaronreidsmith/raku/ch-1.raku | 3 +++ 1 file changed, 3 insertions(+) diff --git a/challenge-090/aaronreidsmith/raku/ch-1.raku b/challenge-090/aaronreidsmith/raku/ch-1.raku index b0c53e239a..3c12a719c9 100644 --- a/challenge-090/aaronreidsmith/raku/ch-1.raku +++ b/challenge-090/aaronreidsmith/raku/ch-1.raku @@ -5,6 +5,9 @@ subset ValidDna of Str where { $_ ~~ /^^[A|T|G|C]+$$/ } # Since DNA is generally read from 5' to 3', I included the option to find the # reverse compliment in addition to the complement sub MAIN($dna where $dna ~~ ValidDna, Bool :rc(:$reverse-complement) = False) { + say "Input stats:\n{$dna.comb.Bag.Hash}\n"; + + say "Complement:"; my $translated = $dna.trans('ATGC' => 'TACG'); if $reverse-complement { say "5'-{$translated.flip}-3'"; -- cgit From 38277932edb4d62b034b9bc189fafc6fb432f1c4 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Mon, 7 Dec 2020 16:50:03 -0600 Subject: Add blog link --- challenge-090/aaronreidsmith/blog.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-090/aaronreidsmith/blog.txt diff --git a/challenge-090/aaronreidsmith/blog.txt b/challenge-090/aaronreidsmith/blog.txt new file mode 100644 index 0000000000..c0bf9276a7 --- /dev/null +++ b/challenge-090/aaronreidsmith/blog.txt @@ -0,0 +1 @@ +https://aaronreidsmith.github.io/blog/perl-weekly-challenge-090/ \ No newline at end of file -- cgit From 4e09c2a1bcfc3828ec9855f7f9a3fa15529118ba Mon Sep 17 00:00:00 2001 From: Dave Jacoby Date: Mon, 7 Dec 2020 22:45:47 -0500 Subject: Challenge 90 in Perl --- challenge-090/dave-jacoby/perl/ch-1.pl | 22 ++++++++++++++++++++ challenge-090/dave-jacoby/perl/ch-2.pl | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 challenge-090/dave-jacoby/perl/ch-1.pl create mode 100644 challenge-090/dave-jacoby/perl/ch-2.pl diff --git a/challenge-090/dave-jacoby/perl/ch-1.pl b/challenge-090/dave-jacoby/perl/ch-1.pl new file mode 100644 index 0000000000..ed5f5e8cc6 --- /dev/null +++ b/challenge-090/dave-jacoby/perl/ch-1.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature qw{ say signatures state }; +no warnings qw{ experimental }; + +my $sequence = 'GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG' ; +my $complement = $sequence; +$complement =~ tr/TACG/ATGC/; + +say <<"END"; + Sequence: $sequence + Complement: $complement +END + +for my $i ( qw( A T C G ) ) { + my $n = scalar grep {/$i/} split // , $sequence; + say qq( $i: $n ); +} + + diff --git a/challenge-090/dave-jacoby/perl/ch-2.pl b/challenge-090/dave-jacoby/perl/ch-2.pl new file mode 100644 index 0000000000..2973f52f1d --- /dev/null +++ b/challenge-090/dave-jacoby/perl/ch-2.pl @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature qw{ say signatures state }; +no warnings qw{ experimental }; + +use Scalar::Util qw{looks_like_number}; + +my ( $m, $n ) = map { abs $_ } grep { looks_like_number $_ } @ARGV; + +$m //= 17; +$n //= 38; + +say <<"END"; + + m $m + n $n +END + +say egyptian( $m, $n ); +say $m * $n; + +exit; + +sub egyptian ( $m, $n ) { + my $o = 0; + my $i = 1; + do { + my $e = $m % 2 != 0 ? 1 : 0; + say join "\t", $o, $e, $i, $m, $n; + $o += $n if $e; + $i *= 2; + $m = int $m / 2; + $n = $n * 2; + } while ( $m > 0 ); + return $o; +} -- cgit From 9e66df75dea2ac13f895a1006859af5d54e3efbb Mon Sep 17 00:00:00 2001 From: chirvasitua Date: Mon, 7 Dec 2020 23:33:56 -0500 Subject: 1st commit on 006 --- challenge-006/stuart-little/README | 1 + challenge-006/stuart-little/raku/ch-1.p6 | 10 ++++++++++ challenge-006/stuart-little/raku/ch-2.p6 | 15 +++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 challenge-006/stuart-little/README create mode 100755 challenge-006/stuart-little/raku/ch-1.p6 create mode 100755 challenge-006/stuart-little/raku/ch-2.p6 diff --git a/challenge-006/stuart-little/README b/challenge-006/stuart-little/README new file mode 100644 index 0000000000..78439907de --- /dev/null +++ b/challenge-006/stuart-little/README @@ -0,0 +1 @@ +Solutions by Stuart Little diff --git a/challenge-006/stuart-little/raku/ch-1.p6 b/challenge-006/stuart-little/raku/ch-1.p6 new file mode 100755 index 0000000000..c475bdde13 --- /dev/null +++ b/challenge-006/stuart-little/raku/ch-1.p6 @@ -0,0 +1,10 @@ +#!/usr/bin/env perl6 +use v6; + +# run as