diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-08-29 04:13:12 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-08-29 04:13:12 +0100 |
| commit | 877d5097cf503a2fc82a81e0ac5396a8530fbc78 (patch) | |
| tree | 1b1b352e0819f56f38b4c6cf375a7e529d0d4953 | |
| parent | 81d67d006a2d4006c98e9b9562f7c8e7040bfae9 (diff) | |
| download | perlweeklychallenge-club-877d5097cf503a2fc82a81e0ac5396a8530fbc78.tar.gz perlweeklychallenge-club-877d5097cf503a2fc82a81e0ac5396a8530fbc78.tar.bz2 perlweeklychallenge-club-877d5097cf503a2fc82a81e0ac5396a8530fbc78.zip | |
- Added solutions by Colin Crain.
| -rw-r--r-- | challenge-179/colin-crain/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-179/colin-crain/perl/ch-1.pl | 63 | ||||
| -rwxr-xr-x | challenge-179/colin-crain/perl/ch-2.pl | 116 | ||||
| -rw-r--r-- | stats/pwc-current.json | 227 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 74 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1164 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 728 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 96 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 94 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 60 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 570 |
17 files changed, 1946 insertions, 1747 deletions
diff --git a/challenge-179/colin-crain/blog.txt b/challenge-179/colin-crain/blog.txt new file mode 100644 index 0000000000..7199bbe557 --- /dev/null +++ b/challenge-179/colin-crain/blog.txt @@ -0,0 +1 @@ +https://colincrain.com/2022/08/26/glitter-bombs-and-sparkling-lines diff --git a/challenge-179/colin-crain/perl/ch-1.pl b/challenge-179/colin-crain/perl/ch-1.pl new file mode 100755 index 0000000000..95a4f90a8c --- /dev/null +++ b/challenge-179/colin-crain/perl/ch-1.pl @@ -0,0 +1,63 @@ +#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# ordinary_number_rules.pl
+#
+# Ordinal Number Spelling
+# Submitted by: Mohammad S Anwar
+# You are given a positive number, $n.
+#
+# Write a script to spell the ordinal number.
+#
+# For example,
+#
+# 11 => eleventh
+# 62 => sixty-second
+# 99 => ninety-ninth
+#
+# method:
+#
+# I am tempted to attempt this task from the ground up, but natural
+# language programming is a thicket of edge cases, and frankly
+# where do you stop?
+#
+# The breakdown really isn't *too* bad, though, with half the
+# requirement creating a written term for a number and then
+# adopting a set of special rules to the last term, which is
+# almost, but not always, "add -th and call it a day".
+#
+# Thus we get fourth, sixth and seventh, but also fifth, eighth,
+# and seventieth, which all require differrent letter conversions.
+# "eleven thousand six hundred and fifty-first" has an assorment of
+# these. All managable, but a somewhat tedious cascading of special
+# cases.
+#
+# Or we can turn to the venerable Niel Bowers, who has sorted all
+# of this stuff for us already, with every hairy detail overseen.
+#
+# We have things to do, so we will defer the added effort to allow
+# other goals. So we use Lingua::EN::Numbers and its num2en_ordinal()
+# function, which, as in most things involving NLP, is the correct
+# way to proceed.
+#
+# © 2022 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+
+
+use Lingua::EN::Numbers qw (num2en_ordinal);
+
+
+my $input = shift // 11_651; ## throw that delimiter in there just to
+ ## make things wonkier
+
+say num2en_ordinal( $input );
+
+
diff --git a/challenge-179/colin-crain/perl/ch-2.pl b/challenge-179/colin-crain/perl/ch-2.pl new file mode 100755 index 0000000000..1c8cc05452 --- /dev/null +++ b/challenge-179/colin-crain/perl/ch-2.pl @@ -0,0 +1,116 @@ +#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# sparkle.pl
+#
+# Unicode Sparkline
+# Submitted by: Mohammad S Anwar
+# You are given a list of positive numbers, @n.
+#
+# Write a script to print sparkline in Unicode for the given list of
+# numbers.
+
+# background
+#
+# Edward Tufte coined the term sparklines in 2006 for
+# "data-intense, design-simple, word-sized graphics", embedded
+# seamlessly within the words in a line of text. The idea is to
+# convey simple graphical information, such as data trending,
+# quickly and without breaking the reader's spatial attention on
+# the page.
+#
+# "Sparklines", Tufte says, "can be placed anywhere that words or
+# numbers or graphics can be placed: in sentences, maps, graphics,
+# tables."
+#
+# Individual words each contain small portions of information.
+# Generally the information content of a single word is imcomplete,
+# but by grouping words together in a linear way more complex ideas
+# can be developed. Similarly sparklines contain a similar kernel
+# of essential information that, incomplete on its own, can be
+# combined inline with a written context to add additional meaning
+# to a context. Rather than forcing the reader to jump back and
+# forth from sideboxed graphic to a textual foundation to provide
+# data context, the sparkline can provide a small significant part
+# of a larger data analysis immediately when required, with the
+# context self-evident.
+#
+# With the widespread adoption of Unicode and its greatly expanded
+# font sets, users of the technology have been able to construct
+# character-based "words" directly from the graphical elements
+# newly made available. The sparklines exist the same as any other
+# word, allowing them to be integrated directly into a lne of text.
+#
+# method
+#
+# The Unicode font-set provides 8 box graphics of gradient sizing
+# that can be used to construct bar-graphs, and these are commonly
+# used to create sparklines. Thus when given a data set og
+# numerical values the challenge is to divide the range into 8
+# segements and assign each element to a segment. From these a
+# sparkline can be constructed that will show general upward or
+# downward trending in the data, or concentrations of values, for
+# instance, without relying on specific axis values.
+#
+# The problem then becomes one of normalizing the data. We need an
+# overall range for the data provided, and then derive a conversion
+# factor to map this range to the range 1-8. We can then apply this
+# conversion factor (and offset) to the data and take the floor value, yielding
+# an index value 0-7. We then use this index to find the
+# appropriate character.
+#
+# The conversion is not unlike converting from Celsius to
+# Fahrenheit: °F are °C * 9/5, as 100 units in C map to 180 units
+# in F, however thre is an offset, in that the freezing point of
+# water, 0°C, starts at 32°F, because Fahrenheit used salted ice
+# slurry. So after we convert our scale from 0-100 to 0-180, we
+# need to add that 32 to get the proper result.
+#
+# So we get:
+#
+# input_range = input_max - input_min
+# output_range = output_max - output_min = 7 - 0 = 7
+# input_offset = input - input_min
+#
+# output = (output_range/input_range) + input_offset;
+#
+# From there we want the integer component to get range 0-7 for an
+# index
+#
+#
+#
+#
+#
+# © 2022 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+use open ':std', ':encoding(UTF-8)';
+
+use List::MoreUtils qw( minmax );
+
+my @input = (15,2500,35,-4500,55,65,75,8500);
+
+say "@input";
+say sparkle( \@input );
+
+
+sub sparkle( $arr ) {
+ my @sparks = qw( ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ █);
+
+ my ($min, $max) = minmax( $arr->@* );
+ my $out;
+
+ for ($arr->@*) {
+ ## output = (output_range/input_range) + input_offset;
+ my $idx = int( (7/($max - $min)) * ($_ - $min) );
+ $out .= $sparks[ $idx ];
+ }
+ return $out;
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 274877d069..f2fd641055 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,32 +1,40 @@ { - "legend" : { - "enabled" : 0 - }, "chart" : { "type" : "column" }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, "subtitle" : { - "text" : "[Champions: 23] Last updated at 2022-08-29 02:40:58 GMT" + "text" : "[Champions: 24] Last updated at 2022-08-29 03:11:45 GMT" + }, + "legend" : { + "enabled" : 0 + }, + "title" : { + "text" : "The Weekly Challenge - 179" }, "series" : [ { - "colorByPoint" : 1, "name" : "The Weekly Challenge - 179", + "colorByPoint" : 1, "data" : [ { + "name" : "Arne Sommer", "y" : 3, - "drilldown" : "Arne Sommer", - "name" : "Arne Sommer" + "drilldown" : "Arne Sommer" }, { - "name" : "Athanasius", + "drilldown" : "Athanasius", "y" : 4, - "drilldown" : "Athanasius" + "name" : "Athanasius" }, { "name" : "Aut0exec", - "drilldown" : "Aut0exec", - "y" : 1 + "y" : 1, + "drilldown" : "Aut0exec" }, { "y" : 1, @@ -34,39 +42,44 @@ "name" : "Cheok-Yin Fung" }, { + "drilldown" : "Colin Crain", + "y" : 3, + "name" : "Colin Crain" + }, + { + "name" : "Dario Mazzeo", "drilldown" : "Dario Mazzeo", - "y" : 1, - "name" : "Dario Mazzeo" + "y" : 1 }, { - "drilldown" : "Duncan C. White", + "name" : "Duncan C. White", "y" : 1, - "name" : "Duncan C. White" + "drilldown" : "Duncan C. White" }, { "name" : "E. Choroba", - "drilldown" : "E. Choroba", - "y" : 2 + "y" : 2, + "drilldown" : "E. Choroba" }, { + "name" : "Flavio Poletti", "drilldown" : "Flavio Poletti", - "y" : 6, - "name" : "Flavio Poletti" + "y" : 6 }, { + "name" : "James Smith", "y" : 3, - "drilldown" : "James Smith", - "name" : "James Smith" + "drilldown" : "James Smith" }, { - "name" : "Jan Krnavek", "y" : 1, - "drilldown" : "Jan Krnavek" + "drilldown" : "Jan Krnavek", + "name" : "Jan Krnavek" }, { - "name" : "Jorg Sommrey", "y" : 2, - "drilldown" : "Jorg Sommrey" + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey" }, { "drilldown" : "Laurent Rosenfeld", @@ -84,29 +97,29 @@ "name" : "Mark Anderson" }, { + "name" : "Robert DiCicco", "drilldown" : "Robert DiCicco", - "y" : 2, - "name" : "Robert DiCicco" + "y" : 2 }, { - "name" : "Robert Ransbottom", "y" : 2, - "drilldown" : "Robert Ransbottom" + "drilldown" : "Robert Ransbottom", + "name" : "Robert Ransbottom" }, { - "y" : 5, "drilldown" : "Roger Bell_West", + "y" : 5, "name" : "Roger Bell_West" }, { + "name" : "Simon Green", "y" : 3, - "drilldown" : "Simon Green", - "name" : "Simon Green" + "drilldown" : "Simon Green" }, { + "name" : "Simon Proctor", "y" : 1, - "drilldown" : "Simon Proctor", - "name" : "Simon Proctor" + "drilldown" : "Simon Proctor" }, { "name" : "Solathian", @@ -114,9 +127,9 @@ "drilldown" : "Solathian" }, { - "name" : "Stephen G Lynn", "y" : 5, - "drilldown" : "Stephen G Lynn" + "drilldown" : "Stephen G Lynn", + "name" : "Stephen G Lynn" }, { "y" : 3, @@ -125,27 +138,32 @@ }, { "name" : "W. Luis Mochan", - "y" : 3, - "drilldown" : "W. Luis Mochan" + "drilldown" : "W. Luis Mochan", + "y" : 3 } ] } ], + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, "xAxis" : { "type" : "category" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "title" : { - "text" : "The Weekly Challenge - 179" + "tooltip" : { + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", + "followPointer" : 1, + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" }, "drilldown" : { "series" : [ { - "name" : "Arne Sommer", "data" : [ [ "Raku", @@ -156,10 +174,12 @@ 1 ] ], - "id" : "Arne Sommer" + "id" : "Arne Sommer", + "name" : "Arne Sommer" }, { "id" : "Athanasius", + "name" : "Athanasius", "data" : [ [ "Perl", @@ -169,18 +189,17 @@ "Raku", 2 ] - ], - "name" : "Athanasius" + ] }, { + "name" : "Aut0exec", "id" : "Aut0exec", "data" : [ [ "Perl", 1 ] - ], - "name" : "Aut0exec" + ] }, { "id" : "Cheok-Yin Fung", @@ -193,37 +212,50 @@ ] }, { + "id" : "Colin Crain", + "name" : "Colin Crain", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { "id" : "Dario Mazzeo", + "name" : "Dario Mazzeo", "data" : [ [ "Perl", 1 ] - ], - "name" : "Dario Mazzeo" + ] }, { "id" : "Duncan C. White", + "name" : "Duncan C. White", "data" : [ [ "Perl", 1 ] - ], - "name" : "Duncan C. White" + ] }, { - "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], + "name" : "E. Choroba", "id" : "E. Choroba" }, { - "name" : "Flavio Poletti", "data" : [ [ "Perl", @@ -238,10 +270,10 @@ 2 ] ], - "id" : "Flavio Poletti" + "id" : "Flavio Poletti", + "name" : "Flavio Poletti" }, { - "name" : "James Smith", "data" : [ [ "Perl", @@ -252,29 +284,32 @@ 1 ] ], - "id" : "James Smith" + "id" : "James Smith", + "name" : "James Smith" }, { "name" : "Jan Krnavek", + "id" : "Jan Krnavek", "data" : [ [ "Raku", 1 ] - ], - "id" : "Jan Krnavek" + ] }, { + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] - ], - "name" : "Jorg Sommrey", - "id" : "Jorg Sommrey" + ] }, { + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -288,13 +323,9 @@ "Blog", 1 ] - ], - "name" : "Laurent Rosenfeld", - "id" : "Laurent Rosenfeld" + ] }, { - "id" : "Luca Ferrari", - "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -304,7 +335,9 @@ "Blog", 6 ] - ] + ], + "name" : "Luca Ferrari", + "id" : "Luca Ferrari" }, { "data" : [ @@ -313,11 +346,12 @@ 2 ] ], - "name" : "Mark Anderson", - "id" : "Mark Anderson" + "id" : "Mark Anderson", + "name" : "Mark Anderson" }, { "id" : "Robert DiCicco", + "name" : "Robert DiCicco", "data" : [ [ "Perl", @@ -327,22 +361,19 @@ "Raku", 1 ] - ], - "name" : "Robert DiCicco" + ] }, { - "name" : "Robert Ransbottom", "data" : [ [ "Raku", 2 ] ], - "id" : "Robert Ransbottom" + "id" : "Robert Ransbottom", + "name" : "Robert Ransbottom" }, { - "id" : "Roger Bell_West", - "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -356,7 +387,9 @@ "Blog", 1 ] - ] + ], + "name" : "Roger Bell_West", + "id" : "Roger Bell_West" }, { "id" : "Simon Green", @@ -383,18 +416,16 @@ ] }, { + "name" : "Solathian", "id" : "Solathian", "data" : [ [ "Perl", 1 ] - ], - "name" : "Solathian" + ] }, { - "id" : "Stephen G Lynn", - "name" : "Stephen G Lynn", "data" : [ [ "Perl", @@ -408,11 +439,11 @@ "Blog", 1 ] - ] + ], + "id" : "Stephen G Lynn", + "name" : "Stephen G Lynn" }, { - "id" : "Ulrich Rieke", - "name" : "Ulrich Rieke", "data" : [ [ "Perl", @@ -422,10 +453,13 @@ "Raku", 2 ] - ] + ], + "name" : "Ulrich Rieke", + "id" : "Ulrich Rieke" }, { "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -435,23 +469,8 @@ "Blog", 1 ] - ], - "name" : "W. Luis Mochan" + ] } ] - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "followPointer" : 1, - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 871c1b86fd..1b077e39a1 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,63 +1,63 @@ { - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "chart" : { - "type" : "column" - }, - "legend" : { - "enabled" : "false" - }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2022]" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, "series" : [ { - "dataLabels" : { - "enabled" : "true", - "align" : "right", - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - }, - "color" : "#FFFFFF", - "format" : "{point.y:.0f}", - "rotation" : -90, - "y" : 10 - }, - "name" : "Contributions", "data" : [ [ "Blog", - 2820 + 2821 ], [ "Perl", - 8704 + 8706 ], [ "Raku", 5205 ] - ] + ], + "dataLabels" : { + "y" : 10, + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "format" : "{point.y:.0f}", + "color" : "#FFFFFF", + "align" : "right", + "enabled" : "true", + "rotation" : -90 + }, + "name" : "Contributions" } ], "xAxis" : { "type" : "category", "labels" : { "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" } } }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, "subtitle" : { - "text" : "Last updated at 2022-08-29 02:40:58 GMT" + "text" : "Last updated at 2022-08-29 03:11:45 GMT" + }, + "legend" : { + "enabled" : "false" + }, + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2022]" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index f51359c285..e8fae04645 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,21 +1,8 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "tooltip" : { - "headerFormat" : "<span style=\"font-size:11px\"></span>", - "followPointer" : "true", - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>" - }, "drilldown" : { "series" : [ { + "name" : "001", "id" : "001", "data" : [ [ @@ -30,11 +17,9 @@ "Blog", 11 ] - ], - "name" : "001" + ] }, { - "name" : "002", "data" : [ [ "Perl", @@ -49,9 +34,11 @@ 10 ] ], - "id" : "002" + "id" : "002", + "name" : "002" }, { + "id" : "003", "name" : "003", "data" : [ [ @@ -66,11 +53,9 @@ "Blog", 9 ] - ], - "id" : "003" + ] }, { - "name" : "004", "data" : [ [ "Perl", @@ -85,10 +70,12 @@ 10 ] ], - "id" : "004" + "id" : "004", + "name" : "004" }, { "id" : "005", + "name" : "005", "data" : [ [ "Perl", @@ -102,8 +89,7 @@ "Blog", 12 ] - ], - "name" : "005" + ] }, { "data" : [ @@ -124,7 +110,6 @@ "id" : "006" }, { - "name" : "007", "data" : [ [ "Perl", @@ -139,10 +124,12 @@ 10 ] ], - "id" : "007" + "id" : "007", + "name" : "007" }, { "name" : "008", + "id" : "008", "data" : [ [ "Perl", @@ -156,11 +143,9 @@ "Blog", 12 ] - ], - "id" : "008" + ] }, { - "name" : "009", "data" : [ [ "Perl", @@ -175,7 +160,8 @@ 13 ] ], - "id" : "009" + "id" : "009", + "name" : "009" }, { "id" : "010", @@ -196,8 +182,6 @@ ] }, { - "id" : "011", - "name" : "011", "data" : [ [ "Perl", @@ -211,9 +195,12 @@ "Blog", 10 ] - ] + ], + "id" : "011", + "name" : "011" }, { + "id" : "012", "name" : "012", "data" : [ [ @@ -228,8 +215,7 @@ "Blog", 11 ] - ], - "id" : "012" + ] }, { "id" : "013", @@ -264,8 +250,8 @@ 15 ] ], - "name" : "014", - "id" : "014" + "id" : "014", + "name" : "014" }, { "data" : [ @@ -282,8 +268,8 @@ 15 ] ], - "name" : "015", - "id" : "015" + "id" : "015", + "name" : "015" }, { "data" : [ @@ -300,10 +286,12 @@ 12 ] ], - "name" : "016", - "id" : "016" + "id" : "016", + "name" : "016" }, { + "id" : "017", + "name" : "017", "data" : [ [ "Perl", @@ -317,12 +305,9 @@ "Blog", 12 ] - ], - "name" : "017", - "id" : "017" + |
