diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-29 00:39:22 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-11-29 00:39:22 +0000 |
| commit | 10b5b817f805a4bd432671035afbe506a44361ec (patch) | |
| tree | fb8e8847cf4c5738c087a9bd622a999556c24a51 | |
| parent | c40837e0976c9bce74758c620ebc12807f83f1b8 (diff) | |
| download | perlweeklychallenge-club-10b5b817f805a4bd432671035afbe506a44361ec.tar.gz perlweeklychallenge-club-10b5b817f805a4bd432671035afbe506a44361ec.tar.bz2 perlweeklychallenge-club-10b5b817f805a4bd432671035afbe506a44361ec.zip | |
- Added solutions by Colin Crain.
| -rwxr-xr-x | challenge-140/colin-crain/perl/ch-1.pl | 61 | ||||
| -rwxr-xr-x | challenge-140/colin-crain/perl/ch-2.pl | 88 | ||||
| -rwxr-xr-x | challenge-140/colin-crain/raku/ch-1.raku | 26 | ||||
| -rwxr-xr-x | challenge-140/colin-crain/raku/ch-2.raku | 15 | ||||
| -rw-r--r-- | stats/pwc-current.json | 563 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 52 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 928 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 754 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 90 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 98 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 112 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 552 |
18 files changed, 1895 insertions, 1686 deletions
diff --git a/challenge-140/colin-crain/perl/ch-1.pl b/challenge-140/colin-crain/perl/ch-1.pl new file mode 100755 index 0000000000..0049b50613 --- /dev/null +++ b/challenge-140/colin-crain/perl/ch-1.pl @@ -0,0 +1,61 @@ +#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# super_bin_plus.pl
+#
+# Add Binary
+# Submitted by: Mohammad S Anwar
+# You are given two decimal-coded binary numbers, $a and $b.
+#
+# Write a script to simulate the addition of the given binary numbers.
+#
+# The script should simulate something like $a + $b. (operator overloading)
+#
+# Example 1
+# Input: $a = 11; $b = 1;
+# Output: 100
+# Example 2
+# Input: $a = 101; $b = 1;
+# Output: 110
+# Example 3
+# Input: $a = 100; $b = 11;
+# Output: 111
+
+# method:
+# Given two numbers in binary representation, we are asked to add
+# them. Specifically we are asked to simulate adding them, whatever
+# exactly that means.
+#
+# We could just add them: input each as binary stings prefixed by
+# '0b', add the values, then sprintf the result using "%b" again.
+# Dead simple. I think this is what is being requested. Provide a
+# function that takes two binary strings and returns a summed
+# result as a binary string.
+#
+# `+` after all is a function, and a function need not be infix,
+# that's just convention. In RPN we would, after all, write `+ 2 2`
+# instead of `2 + 2`. So we also need not call out summing function
+# `+`, but could use another name, like `super-bin-plus`, or maybe
+# just `binplus`. That's a little more normal. If we predeclare our
+# routine we can do away with parentheses.
+#
+#
+# © 2021 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+
+sub binplus;
+
+say binplus 1, 11 ;
+
+sub binplus ($b1, $b2) {
+ return sprintf "%b" , oct('0b' . $b1) + oct('0b' . $b2);
+}
+
diff --git a/challenge-140/colin-crain/perl/ch-2.pl b/challenge-140/colin-crain/perl/ch-2.pl new file mode 100755 index 0000000000..578efa3135 --- /dev/null +++ b/challenge-140/colin-crain/perl/ch-2.pl @@ -0,0 +1,88 @@ +#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# multi-list.pl
+#
+#
+# Multiplication Table
+# Submitted by: Mohammad S Anwar
+# You are given 3 positive integers, $i, $j and $k.
+#
+# Write a script to print the $kth element in the sorted
+# multiplication table of $i and $j.
+#
+# Example 1
+# Input: $i = 2; $j = 3; $k = 4
+# Output: 3
+#
+# Since the multiplication of 2 x 3 is as below:
+#
+# 1 2 3
+# 2 4 6
+#
+# The sorted multiplication table:
+#
+# 1 2 2 3 4 6
+#
+# Now the 4th element in the table is "3".
+#
+# Example 2
+# Input: $i = 3; $j = 3; $k = 6
+# Output: 4
+#
+# Since the multiplication of 3 x 3 is as below:
+#
+# 1 2 3
+# 2 4 6
+# 3 6 9
+#
+# The sorted multiplication table:
+#
+# 1 2 2 3 3 4 6 6 9
+#
+# Now the 6th element in the table is "4".
+#
+#
+# method:
+#
+# What an interesting puzzle.
+#
+#
+# © 2021 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+
+
+
+
+## sample data
+my $m = 3;
+my $n = 3;
+my $target_index = 6;
+
+say nth_multi( $m, $n, $target_index );
+
+my %mult;
+
+sub nth_multi ( $m, $n, $idx ) {
+ for my $i ( 1..$m ) {
+ $mult{$_}++ for map { $i * $_ } ( 1..$n );
+ }
+
+ my ($count, $out);
+ for ( sort {$a<=>$b} keys %mult ) {
+ $count += $mult{ $_ };
+ $out = $_;
+ return $_ if $count >= $idx;
+ }
+
+ return $out;
+}
+
diff --git a/challenge-140/colin-crain/raku/ch-1.raku b/challenge-140/colin-crain/raku/ch-1.raku new file mode 100755 index 0000000000..89b78b5614 --- /dev/null +++ b/challenge-140/colin-crain/raku/ch-1.raku @@ -0,0 +1,26 @@ +#!/usr/bin/env perl6 +# +# +# binplus.raku +# +# +# +# © 2021 colin crain +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + + + +unit sub MAIN ( Str $bin1 = "1", Str $bin2 = "11" ) ; + +## show your work... +# ($bin1.parse-base(2) + $bin2.parse-base(2)) .base(2).say; +# ($bin1, $bin2).reduce({ $^a.parse-base(2) + $^b.parse-base(2) }) .base(2).say; +# ($bin1, $bin2).reduce({ [+] ($^a,$^b).map({.parse-base(2)}) }) .base(2).say; + + +([+] ($bin1, $bin2).map({.parse-base(2)})) + .base(2) + .say; + + + diff --git a/challenge-140/colin-crain/raku/ch-2.raku b/challenge-140/colin-crain/raku/ch-2.raku new file mode 100755 index 0000000000..cdd7d30e89 --- /dev/null +++ b/challenge-140/colin-crain/raku/ch-2.raku @@ -0,0 +1,15 @@ +#!/usr/bin/env perl6 +# +# +# multi-pass.raku +# +# +# +# © 2021 colin crain +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + + + +unit sub MAIN (Int $m = 6, Int $n = 5, $idx = 6) ; + +((1..$m X* 1..$n).sort)[$idx].say ; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 9a91a023bc..4d5fa4d5f2 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,10 +1,218 @@ { - "title" : { - "text" : "The Weekly Challenge - 140" + "chart" : { + "type" : "column" + }, + "series" : [ + { + "data" : [ + { + "name" : "Abigail", + "drilldown" : "Abigail", + "y" : 4 + }, + { + "y" : 4, + "drilldown" : "Adam Russell", + "name" : "Adam Russell" + }, + { + "name" : "Alexander Pankoff", + "y" : 2, + "drilldown" : "Alexander Pankoff" + }, + { + "name" : "Andrew Shitov", + "y" : 2, + "drilldown" : "Andrew Shitov" + }, + { + "name" : "Arne Sommer", + "drilldown" : "Arne Sommer", + "y" : 3 + }, + { + "drilldown" : "Athanasius", + "y" : 4, + "name" : "Athanasius" + }, + { + "y" : 1, + "drilldown" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung" + }, + { + "y" : 4, + "drilldown" : "Colin Crain", + "name" : "Colin Crain" + }, + { + "drilldown" : "Cristina Heredia", + "y" : 1, + "name" : "Cristina Heredia" + }, + { + "name" : "Dave Jacoby", + "y" : 3, + "drilldown" : "Dave Jacoby" + }, + { + "y" : 2, + "drilldown" : "Duncan C. White", + "name" : "Duncan C. White" + }, + { + "drilldown" : "E. Choroba", + "y" : 2, + "name" : "E. Choroba" + }, + { + "name" : "Feng Chang", + "y" : 2, + "drilldown" : "Feng Chang" + }, + { + "y" : 2, + "drilldown" : "Jake", + "name" : "Jake" + }, + { + "y" : 3, + "drilldown" : "James Smith", + "name" : "James Smith" + }, + { + "name" : "Jan Krnavek", + "y" : 2, + "drilldown" : "Jan Krnavek" + }, + { + "y" : 2, + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey" + }, + { + "drilldown" : "Laurent Rosenfeld", + "y" : 6, + "name" : "Laurent Rosenfeld" + }, + { + "name" : "Lubos Kolouch", + "drilldown" : "Lubos Kolouch", + "y" : 2 + }, + { + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari", + "y" : 6 + }, + { + "drilldown" : "Mano Chandar", + "y" : 1, + "name" : "Mano Chandar" + }, + { + "drilldown" : "Matthew Neleigh", + "y" : 2, + "name" : "Matthew Neleigh" + }, + { + "y" : 2, + "drilldown" : "Mohammad S Anwar", + "name" : "Mohammad S Anwar" + }, + { + "name" : "Niels van Dijke", + "y" : 2, + "drilldown" : "Niels van Dijke" + }, + { + "name" : "Olivier Delouya", + "y" : 1, + "drilldown" : "Olivier Delouya" + }, + { + "drilldown" : "Paul Fajman", + "y" : 1, + "name" : "Paul Fajman" + }, + { + "y" : 2, + "drilldown" : "Paulo Custodio", + "name" : "Paulo Custodio" + }, + { + "y" : 2, + "drilldown" : "Pete Houston", + "name" : "Pete Houston" + }, + { + "name" : "Peter Campbell Smith", + "y" : 2, + "drilldown" : "Peter Campbell Smith" + }, + { + "name" : "Robert DiCicco", + "y" : 1, + "drilldown" : "Robert DiCicco" + }, + { + "drilldown" : "Roger Bell_West", + "y" : 5, + "name" : "Roger Bell_West" + }, + { + "drilldown" : "Simon Green", + "y" : 3, + "name" : "Simon Green" + }, + { + "name" : "Ulrich Rieke", + "y" : 3, + "drilldown" : "Ulrich Rieke" + }, + { + "name" : "W. Luis Mochan", + "y" : 3, + "drilldown" : "W. Luis Mochan" + }, + { + "name" : "Wanderdoc", + "drilldown" : "Wanderdoc", + "y" : 2 + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 140" + } + ], + "subtitle" : { + "text" : "[Champions: 35] Last updated at 2021-11-29 00:37:13 GMT" }, "xAxis" : { "type" : "category" }, + "title" : { + "text" : "The Weekly Challenge - 140" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "tooltip" : { + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", + "followPointer" : 1 + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, "drilldown" : { "series" : [ { @@ -18,12 +226,10 @@ 2 ] ], - "name" : "Abigail", - "id" : "Abigail" + "id" : "Abigail", + "name" : "Abigail" }, { - "name" : "Adam Russell", - "id" : "Adam Russell", "data" : [ [ "Perl", @@ -33,31 +239,31 @@ "Blog", 2 ] - ] + ], + "id" : "Adam Russell", + "name" : "Adam Russell" }, { "id" : "Alexander Pankoff", - "name" : "Alexander Pankoff", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Alexander Pankoff" }, { - "name" : "Andrew Shitov", - "id" : "Andrew Shitov", "data" : [ [ "Raku", 2 ] - ] + ], + "id" : "Andrew Shitov", + "name" : "Andrew Shitov" }, { - "name" : "Arne Sommer", - "id" : "Arne Sommer", "data" : [ [ "Raku", @@ -67,9 +273,12 @@ "Blog", 1 ] - ] + ], + "id" : "Arne Sommer", + "name" : "Arne Sommer" }, { + "id" : "Athanasius", "data" : [ [ "Perl", @@ -80,31 +289,43 @@ 2 ] ], - "name" : "Athanasius", - "id" : "Athanasius" + "name" : "Athanasius" }, { + "name" : "Cheok-Yin Fung", "data" : [ [ "Perl", 1 ] ], - "id" : "Cheok-Yin Fung", - "name" : "Cheok-Yin Fung" + "id" : "Cheok-Yin Fung" + }, + { + "name" : "Colin Crain", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Colin Crain" }, { - "name" : "Cristina Heredia", - "id" : "Cristina Heredia", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Cristina Heredia", + "name" : "Cristina Heredia" }, { - "name" : "Dave Jacoby", "id" : "Dave Jacoby", "data" : [ [ @@ -115,37 +336,38 @@ "Blog", 1 ] - ] + ], + "name" : "Dave Jacoby" }, { "id" : "Duncan C. White", - "name" : "Duncan C. White", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Duncan C. White" }, { - "name" : "E. Choroba", "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "E. Choroba" }, { "id" : "Feng Chang", - "name" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Feng Chang" }, { "name" : "Jake", @@ -158,7 +380,6 @@ ] }, { - "name" : "James Smith", "id" : "James Smith", "data" : [ [ @@ -169,29 +390,32 @@ "Blog", 1 ] - ] + ], + "name" : "James Smith" }, { "name" : "Jan Krnavek", - "id" : "Jan Krnavek", "data" : [ [ "Blog", 2 ] - ] + ], + "id" : "Jan Krnavek" }, { + "name" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] ], - "name" : "Jorg Sommrey", "id" : "Jorg Sommrey" }, { + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -205,23 +429,20 @@ "Blog", 2 ] - ], - "id" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" + ] }, { "name" : "Lubos Kolouch", - "id" : "Lubos Kolouch", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Lubos Kolouch" }, { "id" : "Luca Ferrari", - "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -231,57 +452,58 @@ "Blog", 4 ] - ] + ], + "name" : "Luca Ferrari" }, { - "id" : "Mano Chandar", "name" : "Mano Chandar", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Mano Chandar" }, { + "id" : "Matthew Neleigh", "data" : [ [ "Perl", 2 ] ], - "id" : "Matthew Neleigh", "name" : "Matthew Neleigh" }, { + "name" : "Mohammad S Anwar", + "id" : "Mohammad S Anwar", "data" : [ [ "Perl", 2 ] - ], - "name" : "Mohammad S Anwar", - "id" : "Mohammad S Anwar" + ] }, { - "id" : "Niels van Dijke", - "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" }, { + "name" : "Olivier Delouya", + "id" : "Olivier Delouya", "data" : [ [ "Perl", 1 ] - ], - "id" : "Olivier Delouya", - "name" : "Olivier Delouya" + ] }, { "data" : [ @@ -294,14 +516,14 @@ "name" : "Paul Fajman" }, { + "id" : "Paulo Custodio", "data" : [ [ "Perl", 2 ] ], - "name" : "Paulo Custodio", - "id" : "Paulo Custodio" + "name" : "Paulo Custodio" }, { "data" : [ @@ -314,27 +536,26 @@ "name" : "Pete Houston" }, { + "id" : "Peter Campbell Smith", "data" : [ [ "Perl", 2 ] ], - "name" : "Peter Campbell Smith", - "id" : "Peter Campbell Smith" + "name" : "Peter Campbell Smith" }, { - "name" : "Robert DiCicco", - "id" : "Robert DiCicco", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Robert DiCicco", + "name" : "Robert DiCicco" }, { - "id" : "Roger Bell_West", "name" : "Roger Bell_West", "data" : [ [ @@ -349,11 +570,11 @@ "Blog", 1 ] - ] + ], + "id" : "Roger Bell_West" }, { "name" : "Simon Green", - "id" : "Simon Green", "data" : [ [ "Perl", @@ -363,7 +584,8 @@ "Blog", 1 ] - ] + ], + "id" : "Simon Green" }, { "data" : [ @@ -380,6 +602,8 @@ "name" : "Ulrich Rieke" }, { + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -389,225 +613,20 @@ "Blog", 1 ] - ], - "id" : "W. Luis Mochan", - "name" : "W. Luis Mochan" + ] }, { + "id" : "Wanderdoc", "data" : [ [ "Perl", 2 ] ], - "id" : "Wanderdoc", "name" : "Wanderdoc" } ] }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } - }, - "series" : [ - { - "data" : [ - { - "y" : 4, - "drilldown" : "Abigail", - "name" : "Abigail" - }, - { - "name" : "Adam Russell", - "y" : 4, - "drilldown" : "Adam Russell" - }, - { - "name" : "Alexander Pankoff", - "drilldown" : "Alexander Pankoff", - "y" : 2 - }, - { - "name" : "Andrew Shitov", - "drilldown" : "Andrew Shitov", - "y" : 2 - }, - { - "y" : 3, - "drilldown" : "Arne Sommer", - "name" : "Arne Sommer" - }, - { - "drilldown" : "Athanasius", - "y" : 4, - "name" : "Athanasius" - }, - { - "drilldown" : "Cheok-Yin Fung", - "y" : 1, - "name" : "Cheok-Yin Fung" - }, - { - "drilldown" : "Cristina Heredia", - "y" : 1, - "name" : "Cristina Heredia" - }, - { - "drilldown" : "Dave Jacoby", - "y" : 3, - "name" : "Dave Jacoby" - }, - { - "name" : "Duncan C. White", - "y" : 2, - "drilldown" : "Duncan C. White" - }, - { - "name" : "E. Choroba", - "drilldown" : "E. Choroba", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Feng Chang", - "name" : "Feng Chang" - }, - { - "name" : "Jake", - "y" : 2, - "drilldown" : "Jake" - }, - { - "drilldown" : "James Smith", - "y" : 3, - "name" : "James Smith" - }, - { - "name" : "Jan Krnavek", - "drilldown" : "Jan Krnavek", - "y" : 2 - }, - { - "name" : "Jorg Sommrey", - "y" : 2, - "drilldown" : "Jorg Sommrey" - }, - { - "y" : 6, - "drilldown" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" - }, - { - "y" : 2, - "drilldown" : "Lubos Kolouch", - "name" : "Lubos Kolouch" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 6, - "name" : "Luca Ferrari" - }, - { - "y" : 1, - "drilldown" : "Mano Chandar", - "name" : "Mano Chandar" - }, - { - "drilldown" : "Matthew Neleigh", - "y" : 2, - "name" : "Matthew Neleigh" - }, - { - "name" : "Mohammad S Anwar", - "drilldown" : "Mohammad S Anwar", - "y" : 2 - }, - { - "name" : "Niels van Dijke", - "y" : 2, - "drilldown" : "Niels van Dijke" - }, - { - "name" : "Olivier Delouya", - "y" : 1, - "drilldown" : "Olivier Delouya" - }, - { - "name" : "Paul Fajman", - "drilldown" : "Paul Fajman", - "y" : 1 - }, - { - "name" : "Paulo Custodio", - "y" : 2, - "drilldown" : "Paulo Custodio" - }, - { - "name" : "Pete Houston", - "drilldown" : "Pete Houston", - "y" : 2 - }, - { - "name" : "Peter Campbell Smith", - "y" : 2, - "drilldown" : "Peter Campbell Smith" - }, - { - "drilldown" : "Robert DiCicco", - "y" : 1, - "name" : "Robert DiCicco" - }, - { - "drilldown" : "Roger Bell_West", - "y" : 5, - "name" : "Roger Bell_West" - }, - { - "name" : "Simon Green", - "y" : 3, - "drilldown" : "Simon Green" - }, - { - "name" : "Ulrich Rieke", - "drilldown" : "Ulrich Rieke", - "y" : 3 - }, - { - "y" : 3, - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan" - }, - { - "y" : 2, - "drilldown" : "Wanderdoc", - "name" : "Wanderdoc" - } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 140" - } - ], - "tooltip" : { - "followPointer" : 1, - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" - }, - "chart" : { - "type" : "column" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, |
