diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-08 17:05:26 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-08 17:05:26 +0100 |
| commit | b00f1358ac9f6cfaf330efa46cca25a54390e64d (patch) | |
| tree | 1bfe803d3fdbdfe80bcafc23b98d96005e5f6038 | |
| parent | f1086ad23bcadd866c3dce3ca66e9ce85482fac5 (diff) | |
| download | perlweeklychallenge-club-b00f1358ac9f6cfaf330efa46cca25a54390e64d.tar.gz perlweeklychallenge-club-b00f1358ac9f6cfaf330efa46cca25a54390e64d.tar.bz2 perlweeklychallenge-club-b00f1358ac9f6cfaf330efa46cca25a54390e64d.zip | |
- Added solutions by Guillermo Ramos.
| -rw-r--r-- | challenge-024/guillermo-ramos/perl5/ch-1.pl | 8 | ||||
| -rw-r--r-- | challenge-024/guillermo-ramos/perl5/ch-2.pl | 65 | ||||
| -rw-r--r-- | stats/pwc-current.json | 261 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 60 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 206 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 916 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 92 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 122 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 84 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 290 |
11 files changed, 1118 insertions, 1030 deletions
diff --git a/challenge-024/guillermo-ramos/perl5/ch-1.pl b/challenge-024/guillermo-ramos/perl5/ch-1.pl new file mode 100644 index 0000000000..fd9a28b936 --- /dev/null +++ b/challenge-024/guillermo-ramos/perl5/ch-1.pl @@ -0,0 +1,8 @@ +#!/usr/bin/env perl +# +# Create a smallest script in terms of size that on execution doesn’t throw any +# error. The script doesn’t have to do anything special. You could even come up +# with smallest one-liner. +################################################################################ + +$|++ diff --git a/challenge-024/guillermo-ramos/perl5/ch-2.pl b/challenge-024/guillermo-ramos/perl5/ch-2.pl new file mode 100644 index 0000000000..0ba06b256d --- /dev/null +++ b/challenge-024/guillermo-ramos/perl5/ch-2.pl @@ -0,0 +1,65 @@ +#!/usr/bin/env perl +# +# Create a script to implement full text search functionality using Inverted +# Index. According to wikipedia: +# +# In computer science, an inverted index (also referred to as a postings file or +# inverted file) is a database index storing a mapping from content, such as +# words or numbers, to its locations in a table, or in a document or a set of +# documents (named in contrast to a forward index, which maps from documents to +# content). The purpose of an inverted index is to allow fast full-text +# searches, at a cost of increased processing when a document is added to the +# database. +# +# Here is a nice example of Inverted Index. +# +# (https://en.wikipedia.org/wiki/Search_engine_indexing#Inverted_indices). +################################################################################ + +use strict; +use warnings; + +use autodie; + +use DBI; + +my $DBFILE = 'ii.db'; +my $USAGE = "Usage: $0 [--index-doc <doc_path> | --search <word>]\n"; + +my $opt = shift or die $USAGE; + +# Connect to database +my $dbh = DBI->connect("dbi:SQLite:dbname=$DBFILE","","", { AutoCommit => 0 }); + +# Initialize database +$dbh->prepare('CREATE TABLE IF NOT EXISTS ii (word TEXT, docpath TEXT, PRIMARY KEY (word, docpath));') + ->execute(); +$dbh->prepare('CREATE INDEX IF NOT EXISTS word_idx ON ii (word);') + ->execute(); +$dbh->commit(); + +if ($opt eq '--index-doc') { + # Index the given document + my $doc_path = shift; + open(my $dh, '<:encoding(UTF-8)', $doc_path); + $/ = undef; + my @words = map { lc($_) } <$dh> =~ /(\w+)/g; + my $sth = $dbh->prepare("INSERT OR IGNORE INTO ii VALUES (?, \"$doc_path\");"); + $sth->execute($_) foreach @words; + $dbh->commit(); +} elsif ($opt eq '--search') { + # Search the given word + my $word = shift; + my $sth = $dbh->prepare('SELECT DISTINCT docpath FROM ii WHERE word = ?'); + $sth->execute($word); + my @files = map { $_->[0] } @{$sth->fetchall_arrayref()}; + if (@files) { + printf "Word '$word' appears in documents: %s\n", join(', ', @files); + } else { + print "Word '$word' does not appear in any document\n"; + } +} else { + die $USAGE; +} + +$dbh->disconnect(); diff --git a/stats/pwc-current.json b/stats/pwc-current.json index b338bc2e1e..33240ee1cd 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,29 +1,117 @@ { "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 + "enabled" : 1, + "format" : "{point.y}" + } } }, - "subtitle" : { - "text" : "[Champions: 16] Last updated at 2019-09-08 14:58:06 GMT" + "xAxis" : { + "type" : "category" }, "chart" : { "type" : "column" }, - "xAxis" : { - "type" : "category" - }, "title" : { "text" : "Perl Weekly Challenge - 024" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + "series" : [ + { + "data" : [ + { + "name" : "Adam Russell", + "y" : 4, + "drilldown" : "Adam Russell" + }, + { + "drilldown" : "Andrezgz", + "y" : 2, + "name" : "Andrezgz" + }, + { + "drilldown" : "Athanasius", + "name" : "Athanasius", + "y" : 2 + }, + { + "y" : 1, + "name" : "Dave Cross", + "drilldown" : "Dave Cross" + }, + { + "y" : 2, + "name" : "Duane Powell", + "drilldown" : "Duane Powell" + }, + { + "y" : 2, + "name" : "Guillermo Ramos", + "drilldown" : "Guillermo Ramos" + }, + { + "y" : 5, + "name" : "Joelle Maslak", + "drilldown" : "Joelle Maslak" + }, + { + "name" : "Kevin Colyer", + "y" : 2, + "drilldown" : "Kevin Colyer" + }, + { + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "y" : 5 + }, + { + "name" : "Lubos Kolouch", + "y" : 2, + "drilldown" : "Lubos Kolouch" + }, + { + "drilldown" : "Noud", + "name" : "Noud", + "y" : 2 + }, + { + "drilldown" : "Randy Lauen", + "name" : "Randy Lauen", + "y" : 4 + }, + { + "drilldown" : "Roger Bell West", + "y" : 4, + "name" : "Roger Bell West" + }, + { + "name" : "Ruben Westerberg", + "y" : 4, + "drilldown" : "Ruben Westerberg" + }, + { + "drilldown" : "Simon Proctor", + "name" : "Simon Proctor", + "y" : 3 + }, + { + "name" : "Steven Wilson", + "y" : 1, + "drilldown" : "Steven Wilson" + }, + { + "drilldown" : "Yet Ebreo", + "y" : 5, + "name" : "Yet Ebreo" + } + ], + "name" : "Perl Weekly Challenge - 024", + "colorByPoint" : 1 } + ], + "subtitle" : { + "text" : "[Champions: 17] Last updated at 2019-09-08 16:03:39 GMT" }, "legend" : { "enabled" : 0 @@ -55,6 +143,7 @@ ] }, { + "id" : "Athanasius", "data" : [ [ "Perl 5", @@ -65,8 +154,7 @@ 1 ] ], - "name" : "Athanasius", - "id" : "Athanasius" + "name" : "Athanasius" }, { "data" : [ @@ -79,14 +167,24 @@ "id" : "Dave Cross" }, { - "id" : "Duane Powell", "data" : [ [ "Perl 5", 2 ] ], - "name" : "Duane Powell" + "name" : "Duane Powell", + "id" : "Duane Powell" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Guillermo Ramos", + "id" : "Guillermo Ramos" }, { "id" : "Joelle Maslak", @@ -107,17 +205,18 @@ ] }, { + "id" : "Kevin Colyer", + "name" : "Kevin Colyer", "data" : [ [ "Perl 6", 2 ] - ], - "name" : "Kevin Colyer", - "id" : "Kevin Colyer" + ] }, { "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", "data" : [ [ "Perl 5", @@ -131,17 +230,16 @@ "Blog", 1 ] - ], - "name" : "Laurent Rosenfeld" + ] }, { - "name" : "Lubos Kolouch", "data" : [ [ "Perl 5", 2 ] ], + "name" : "Lubos Kolouch", "id" : "Lubos Kolouch" }, { @@ -155,7 +253,6 @@ "name" : "Noud" }, { - "id" : "Randy Lauen", "data" : [ [ "Perl 5", @@ -166,10 +263,10 @@ 2 ] ], - "name" : "Randy Lauen" + "name" : "Randy Lauen", + "id" : "Randy Lauen" }, { - "id" : "Roger Bell West", "name" : "Roger Bell West", "data" : [ [ @@ -184,10 +281,11 @@ "Blog", 1 ] - ] + ], + "id" : "Roger Bell West" }, { - "name" : "Ruben Westerberg", + "id" : "Ruben Westerberg", "data" : [ [ "Perl 5", @@ -198,10 +296,10 @@ 2 ] ], - "id" : "Ruben Westerberg" + "name" : "Ruben Westerberg" }, { - "id" : "Simon Proctor", + "name" : "Simon Proctor", "data" : [ [ "Perl 5", @@ -212,20 +310,19 @@ 2 ] ], - "name" : "Simon Proctor" + "id" : "Simon Proctor" }, { - "id" : "Steven Wilson", "data" : [ [ "Perl 5", 1 ] ], - "name" : "Steven Wilson" + "name" : "Steven Wilson", + "id" : "Steven Wilson" }, { - "id" : "Yet Ebreo", "name" : "Yet Ebreo", "data" : [ [ @@ -240,101 +337,19 @@ "Blog", 1 ] - ] + ], + "id" : "Yet Ebreo" } ] }, - "series" : [ - { - "colorByPoint" : 1, - "data" : [ - { - "name" : "Adam Russell", - "drilldown" : "Adam Russell", - "y" : 4 - }, - { - "name" : "Andrezgz", - "y" : 2, - "drilldown" : "Andrezgz" - }, - { - "drilldown" : "Athanasius", - "y" : 2, - "name" : "Athanasius" - }, - { - "y" : 1, - "drilldown" : "Dave Cross", - "name" : "Dave Cross" - }, - { - "name" : "Duane Powell", - "drilldown" : "Duane Powell", - "y" : 2 - }, - { - "name" : "Joelle Maslak", - "y" : 5, - "drilldown" : "Joelle Maslak" - }, - { - "y" : 2, - "drilldown" : "Kevin Colyer", - "name" : "Kevin Colyer" - }, - { - "drilldown" : "Laurent Rosenfeld", - "y" : 5, - "name" : "Laurent Rosenfeld" - }, - { - "name" : "Lubos Kolouch", - "y" : 2, - "drilldown" : "Lubos Kolouch" - }, - { - "drilldown" : "Noud", - "y" : 2, - "name" : "Noud" - }, - { - "name" : "Randy Lauen", - "y" : 4, - "drilldown" : "Randy Lauen" - }, - { - "y" : 4, - "drilldown" : "Roger Bell West", - "name" : "Roger Bell West" - }, - { - "drilldown" : "Ruben Westerberg", - "y" : 4, - "name" : "Ruben Westerberg" - }, - { - "y" : 3, - "drilldown" : "Simon Proctor", - "name" : "Simon Proctor" - }, - { - "name" : "Steven Wilson", - "drilldown" : "Steven Wilson", - "y" : 1 - }, - { - "y" : 5, - "drilldown" : "Yet Ebreo", - "name" : "Yet Ebreo" - } - ], - "name" : "Perl Weekly Challenge - 024" + "yAxis" : { + "title" : { + "text" : "Total Solutions" } - ], + }, "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/>", - "followPointer" : 1 + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 9c5979389f..ae4e6a1e81 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,13 +1,22 @@ { + "title" : { + "text" : "Perl Weekly Challenge Contributions - 2019" + }, + "legend" : { + "enabled" : "false" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + } + }, "tooltip" : { "pointFormat" : "<b>{point.y:.0f}</b>" }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, "chart" : { "type" : "column" }, @@ -20,44 +29,35 @@ ], [ "Perl 5", - 995 + 997 ], [ "Perl 6", 600 ] ], - "name" : "Contributions", "dataLabels" : { - "format" : "{point.y:.0f}", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, "align" : "right", - "y" : 10, "rotation" : -90, + "enabled" : "true", + "y" : 10, "color" : "#FFFFFF", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "enabled" : "true" - } + "format" : "{point.y:.0f}" + }, + "name" : "Contributions" } ], - "legend" : { - "enabled" : "false" - }, "subtitle" : { - "text" : "Last updated at 2019-09-08 14:58:17 GMT" - }, - "title" : { - "text" : "Perl Weekly Challenge Contributions - 2019" + "text" : "Last updated at 2019-09-08 16:03:47 GMT" }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } + "yAxis" : { + "min" : 0, + "title" : { + "text" : null } } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 145e3c8823..2e130c52e1 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,21 +1,38 @@ { + "title" : { + "text" : "Perl Weekly Challenge Language" + }, "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { "format" : "{point.y}", "enabled" : 1 - }, - "borderWidth" : 0 + } } }, + "legend" : { + "enabled" : "false" + }, + "xAxis" : { + "type" : "category" + }, + "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/>" + }, + "chart" : { + "type" : "column" + }, "series" : [ { - "name" : "Perl Weekly Challenge Languages", + "colorByPoint" : "true", "data" : [ { + "drilldown" : "001", "name" : "#001", - "y" : 132, - "drilldown" : "001" + "y" : 132 }, { "y" : 104, @@ -23,78 +40,78 @@ "name" : "#002" }, { - "name" : "#003", "y" : 66, + "name" : "#003", "drilldown" : "003" }, { - "name" : "#004", "drilldown" : "004", + "name" : "#004", "y" : 86 }, { "y" : 66, - "drilldown" : "005", - "name" : "#005" + "name" : "#005", + "drilldown" : "005" }, { - "drilldown" : "006", "y" : 47, + "drilldown" : "006", "name" : "#006" }, { - "y" : 55, + "name" : "#007", "drilldown" : "007", - "name" : "#007" + "y" : 55 }, { "y" : 68, - "drilldown" : "008", - "name" : "#008" + "name" : "#008", + "drilldown" : "008" }, { + "drilldown" : "009", "name" : "#009", - "y" : 66, - "drilldown" : "009" + "y" : 66 }, { - "name" : "#010", "y" : 59, - "drilldown" : "010" + "drilldown" : "010", + "name" : "#010" }, { + "y" : 78, "name" : "#011", - "drilldown" : "011", - "y" : 78 + "drilldown" : "011" }, { - "y" : 82, "drilldown" : "012", - "name" : "#012" + "name" : "#012", + "y" : 82 }, { "name" : "#013", - "y" : 75, - "drilldown" : "013" + "drilldown" : "013", + "y" : 75 }, { - "name" : "#014", "y" : 95, + "name" : "#014", "drilldown" : "014" }, { "y" : 93, - "drilldown" : "015", - "name" : "#015" + "name" : "#015", + "drilldown" : "015" }, { - "drilldown" : "016", "y" : 66, + "drilldown" : "016", "name" : "#016" }, { - "name" : "#017", "drilldown" : "017", + "name" : "#017", "y" : 79 }, { @@ -103,65 +120,45 @@ "y" : 76 }, { + "name" : "#019", "drilldown" : "019", - "y" : 95, - "name" : "#019" + "y" : 95 }, { - "y" : 95, + "name" : "#020", "drilldown" : "020", - "name" : "#020" + "y" : 95 }, { - "name" : "#021", "drilldown" : "021", + "name" : "#021", "y" : 66 }, { - "drilldown" : "022", "y" : 62, + "drilldown" : "022", "name" : "#022" }, { "name" : "#023", - "y" : 88, - "drilldown" : "023" + "drilldown" : "023", + "y" : 88 }, { + "y" : 50, "name" : "#024", - "y" : 48, "drilldown" : "024" } ], - "colorByPoint" : "true" + "name" : "Perl Weekly Challenge Languages" } ], - "chart" : { - "type" : "column" - }, - "tooltip" : { - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : "true", - "headerFormat" : "<span style=\"font-size:11px\"></span>" - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-08 14:58:17 GMT" - }, - "legend" : { - "enabled" : "false" - }, - "title" : { - "text" : "Perl Weekly Challenge Language" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-08 16:03:47 GMT" }, "drilldown" : { "series" : [ { - "id" : "001", "name" : "001", "data" : [ [ @@ -176,7 +173,8 @@ "Blog", 11 ] - ] + ], + "id" : "001" }, { "id" : "002", @@ -211,11 +209,10 @@ 8 ] ], - "name" : "003", - "id" : "003" + "id" : "003", + "name" : "003" }, { - "name" : "004", "data" : [ [ "Perl 5", @@ -230,9 +227,11 @@ 9 ] ], - "id" : "004" + "id" : "004", + "name" : "004" }, { + "name" : "005", "data" : [ [ "Perl 5", @@ -247,12 +246,11 @@ 11 ] ], - "name" : "005", "id" : "005" }, { - "id" : "006", "name" : "006", + "id" : "006", "data" : [ [ "Perl 5", @@ -269,8 +267,6 @@ ] }, { - "id" : "007", - "name" : "007", "data" : [ [ "Perl 5", @@ -284,11 +280,11 @@ "Blog", 9 ] - ] + ], + "id" : "007", + "name" : "007" }, { - "id" : "008", - "name" : "008", "data" : [ [ "Perl 5", @@ -302,11 +298,13 @@ "Blog", 10 ] - ] + ], + "id" : "008", + "name" : "008" }, { - "id" : "009", "name" : "009", + "id" : "009", "data" : [ [ "Perl 5", @@ -323,7 +321,7 @@ ] }, { - "id" : "010", + "name" : "010", "data" : [ [ "Perl 5", @@ -338,11 +336,11 @@ 10 ] ], - "name" : "010" + "id" : "010" }, { - "id" : "011", "name" : "011", + "id" : "011", "data" : [ [ "Perl 5", @@ -373,10 +371,11 @@ 10 ] ], - "name" : "012", - "id" : "012" + "id" : "012", + "name" : "012" }, { + "name" : "013", "data" : [ [ "Perl 5", @@ -391,10 +390,10 @@ 12 ] ], - "name" : "013", "id" : "013" }, { + "name" : "014", "data" : [ [ "Perl 5", @@ -409,12 +408,10 @@ 14 ] ], - "name" : "014", "id" : "014" }, { "id" : "015", - "name" : "015", "data" : [ [ "Perl 5", @@ -428,10 +425,11 @@ "Blog", 15 ] - ] + ], + "name" : "015" }, { - "name" : "016", + "id" : "016", "data" : [ [ "Perl 5", @@ -446,11 +444,11 @@ 12 ] ], - "id" : "016" + "name" : "016" }, { - "id" : "017", "name" : "017", + "id" : "017", "data" : [ [ "Perl 5", @@ -467,8 +465,6 @@ ] }, { - "id" : "018", - "name" : "018", "data" : [ [ "Perl 5", @@ -482,9 +478,12 @@ "Blog", 14 ] - ] + ], + "id" : "018", + "name" : "018" }, { + "id" : "019", "data" : [ [ "Perl 5", @@ -499,11 +498,10 @@ 13 ] ], - "name" : "019", - "id" : "019" + "name" : "019" }, { - "id" : "020", + "name" : "020", "data" : [ [ "Perl 5", @@ -518,10 +516,9 @@ 13 ] ], - "name" : "020" + "id" : "020" }, { - "id" : "021", "data" : [ [ "Perl 5", @@ -536,11 +533,11 @@ 9 ] ], + "id" : "021", "name" : "021" }, { "id" : "022", - "name" : "022", "data" : [ [ "Perl 5", @@ -554,10 +551,10 @@ "Blog", 9 ] - ] + ], + "name" : "022" }, { - "id" : "023", "name" : "023", "data" : [ [ @@ -572,15 +569,15 @@ "Blog", 9 ] - ] + ], + "id" : "023" }, { - "id" : "024", "name" : "024", "data" : [ [ "Perl 5", - 24 + 26 ], [ "Perl 6", @@ -590,11 +587,14 @@ "Blog", 6 ] - ] + ], + "id" : "024" } ] }, - "xAxis" : { - "type" : "category" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } } } diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 772f9e46f4..ab501d5c70 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -1,319 +1,26 @@ { - "xAxis" : { - "type" : "category" - }, - "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2019-09-08 14:58:14 GMT" - }, - "plotOptions" : { - "series" : { - |
