diff options
| author | bagheera-sands <git@sandsscouts.org.uk> | 2019-04-22 22:33:48 +0100 |
|---|---|---|
| committer | bagheera-sands <git@sandsscouts.org.uk> | 2019-04-22 22:33:48 +0100 |
| commit | 5ee061e57de12fb9071bb2fcd3a26ea7ce2cecf6 (patch) | |
| tree | a41dbc8ac591126520b152b19ee7186a6503875b | |
| parent | 7d54035074ef1c522c3d0460ba828ef69f8efd7e (diff) | |
| parent | ef12b6bb075c198fb775acf5d2dc04e25cf9c283 (diff) | |
| download | perlweeklychallenge-club-5ee061e57de12fb9071bb2fcd3a26ea7ce2cecf6.tar.gz perlweeklychallenge-club-5ee061e57de12fb9071bb2fcd3a26ea7ce2cecf6.tar.bz2 perlweeklychallenge-club-5ee061e57de12fb9071bb2fcd3a26ea7ce2cecf6.zip | |
Merge branch 'master' of github.com:manwar/perlweeklychallenge-club
| -rw-r--r-- | README.md | 103 | ||||
| -rw-r--r-- | challenge-005/fjwhittle/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-005/fjwhittle/perl6/ch-1.p6 | 17 | ||||
| -rw-r--r-- | challenge-005/fjwhittle/perl6/ch-2.p6 | 19 | ||||
| -rwxr-xr-x | challenge-005/gustavo-chaves/perl5/ch-1.pl | 16 | ||||
| -rwxr-xr-x | challenge-005/gustavo-chaves/perl5/ch-2.pl | 26 | ||||
| -rw-r--r-- | challenge-005/joelle-maslak/perl6/ch-1-readme | 2 | ||||
| -rw-r--r-- | challenge-005/john-barrett/perl5/README.md | 8 | ||||
| -rw-r--r-- | challenge-005/rob4t/perl6/ch-1.p6 | 16 | ||||
| -rw-r--r-- | challenge-005/rob4t/perl6/ch-2.p6 | 11 | ||||
| -rw-r--r-- | stats/pwc-challenge-004.json | 560 | ||||
| -rw-r--r-- | stats/pwc-current.json | 539 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 460 | ||||
| -rw-r--r-- | stats/pwc-master-stats.json | 253 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 32 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 68 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 48 |
18 files changed, 1291 insertions, 990 deletions
@@ -41,3 +41,106 @@ Let us assume you want to subtmit solutions for **Challenge 002** and your Githu 13. Now go to your fork repository in GitHub web portal **https://github.com/joe-blog/perlweeklychallenge-club** 14. You should see a button to submit **Pull Request**. + +## How to add new solution when you already have a fork? + +Let us assume you already have a fork. If this is the first time you are using the same fork for submitting subsequent challenges solution. I also assume your GitHub user name is **joe-blog**. + +1. Checkout out the **master** branch first. + ``` + $ git checkout master + ``` + +2. Check if you have setup **upstream**. + ``` + $ git remote -v + ``` + + You should see something similar: + ``` + origin https://github.com/joe-blog/perlweeklychallenge-club (fetch) + origin https://github.com/joe-blog/perlweeklychallenge-club (push) + upstream https://github.com/manwar/perlweeklychallenge-club (fetch) + upstream https://github.com/manwar/perlweeklychallenge-club (push) + ``` + + If you don't see **upstream** as above then you need to setup your **upstream** like below: + + ``` + $ git remote add upstream https://github.com/manwar/perlweeklychallenge-club + ``` + + Check if you have everything setup correctly. + + ``` + $ git remote -v + ``` + + If you see similar output as above then you have setup **upstream** correctly. + You only need to do it **once**. + +3. Now we need to **fetch** latest changes from the **upstream**. + + ``` + $ git fetch upstream + ``` + +4. We will now merge the changes into your local **master** branch. + + ``` + $ git merge upstream/master --ff-only + ``` + +5. Then push your **master** changes back to the repository. + + ``` + $ git push -u origin master + ``` + +6. Now it is time create new branch for new challenge + + ``` + $ git checkout -b branch-for-challenge-005 + ``` + +7. Once you have a new **branch** ready, you can start adding your solutions or blog information. + + ``` + $ cd challenge-005/joe-blog + + $ echo "URL to the blog" > blog.txt + + $ cd perl5 + + Add script like ch-1.pl or ch-2.pl or ch-1.sh or ch-2.sh + + $ cd perl6 + + Add script like ch-1.p6 or ch-2.p6 or ch-1.sh or ch-2.sh + ``` + + Test your script now. + +8. Commit your changes. + + ``` + $ git add challenge-005/joe-blog + + $ git commit + ``` + +9. Now push the newly created branh **branch-for-challenge-005** + + ``` + $ git push -u origin branch-for-challenge-005 + ``` + +10. Time to submit your changes as **Pull Request**. + + Go to GitHub web profile + + https://github.com/joe-blog/perlweeklychallenge-club + + You should button to create **Pull Request**. + +If you have any trouble with the above instructions then please get in touch with me anytime (mohammad.anwar@yahoo.com). diff --git a/challenge-005/fjwhittle/blog.txt b/challenge-005/fjwhittle/blog.txt new file mode 100644 index 0000000000..afa4b8a4ba --- /dev/null +++ b/challenge-005/fjwhittle/blog.txt @@ -0,0 +1 @@ +https://rage.powered.ninja/2019/04/22/anagramming-max.html diff --git a/challenge-005/fjwhittle/perl6/ch-1.p6 b/challenge-005/fjwhittle/perl6/ch-1.p6 new file mode 100644 index 0000000000..ffee42f289 --- /dev/null +++ b/challenge-005/fjwhittle/perl6/ch-1.p6 @@ -0,0 +1,17 @@ +#!/usr/bin/env perl6 + +use v6; + +#| Find anagrams of a word in given file +unit sub MAIN( + Str $file #= file containing list of words + where { given .IO { .r && ( .l || .f) or die "Cannot read from $_" } }, + $word #= word to find anagrams of +); + +my $word-bag := $word.lc.comb(/ \w /).Bag; + +my @words = $file.IO.lines.unique.hyper.grep(*.chars > 2) + .map: { .lc.comb(/ \w /).Bag => $_ }; + +@words.race.grep(*.key === $word-bag)».value.unique(with => *.lc eq *.lc).join(', ').put; diff --git a/challenge-005/fjwhittle/perl6/ch-2.p6 b/challenge-005/fjwhittle/perl6/ch-2.p6 new file mode 100644 index 0000000000..75cdfa6a55 --- /dev/null +++ b/challenge-005/fjwhittle/perl6/ch-2.p6 @@ -0,0 +1,19 @@ +#!/usr/bin/env perl6 + +use v6; + +#| Find the sequence of letters with the most anagrams in a given file +unit sub MAIN( + IO(Str) $file #= file containing list of words + where { given .IO { .r && ( .l || .f) or die "Cannot read from $_" } }; +); + +my SetHash %sequences{Str}; + +for $file.lines -> $word { + my $seq = $word.lc.comb(/\w/).sort.join(',') and %sequences{$seq}{$word.lc}++; +} + +my $maxwords = %sequences.values».elems.max; + +.fmt('%1$s(%2$d): %2$s').say for %sequences.pairs.grep: *.value.elems == $maxwords diff --git a/challenge-005/gustavo-chaves/perl5/ch-1.pl b/challenge-005/gustavo-chaves/perl5/ch-1.pl new file mode 100755 index 0000000000..6024ea5656 --- /dev/null +++ b/challenge-005/gustavo-chaves/perl5/ch-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl + +# Write a program which prints out all anagrams for a given word. For more +# information about Anagram, please check this: +# https://en.wikipedia.org/wiki/Anagram + +use 5.026; +use strict; +use autodie; +use warnings; + +my $word = shift or die "usage: $0 WORD [WORDFILE...]\n"; + +my $key = join('', sort split //, lc $word); + +say foreach grep { chomp; $key eq join('', sort split //, lc $_) } <>; diff --git a/challenge-005/gustavo-chaves/perl5/ch-2.pl b/challenge-005/gustavo-chaves/perl5/ch-2.pl new file mode 100755 index 0000000000..cbcc7370cc --- /dev/null +++ b/challenge-005/gustavo-chaves/perl5/ch-2.pl @@ -0,0 +1,26 @@ +#!/usr/bin/env perl + +# Write a program to find the sequence of characters that has the most anagrams. + +use 5.026; +use strict; +use autodie; +use warnings; +use List::Util 'max'; + +my %anagrams; + +# Read list of words and classify them by anagrams +while (<>) { + chomp; + my $key = join('', sort split //, lc $_); + push @{$anagrams{$key}}, $_; +} + +# Find out the cardinality of the biggest anagram set +my $max = max map {scalar @$_} values %anagrams; + +# Print all sequences of letters with most anagrams +while (my ($key, $words) = each %anagrams) { + say $key if @$words == $max; +} diff --git a/challenge-005/joelle-maslak/perl6/ch-1-readme b/challenge-005/joelle-maslak/perl6/ch-1-readme deleted file mode 100644 index d3f6e261ab..0000000000 --- a/challenge-005/joelle-maslak/perl6/ch-1-readme +++ /dev/null @@ -1,2 +0,0 @@ -The program, including line feeds, is 46 bytes long. -The output on Unix is 46 pi digits. diff --git a/challenge-005/john-barrett/perl5/README.md b/challenge-005/john-barrett/perl5/README.md deleted file mode 100644 index 9a98597b12..0000000000 --- a/challenge-005/john-barrett/perl5/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# How I cheated this week... - -## Part 1: - -You need to run... - -`$ perl -MMath::Trig ch-1.pl` - diff --git a/challenge-005/rob4t/perl6/ch-1.p6 b/challenge-005/rob4t/perl6/ch-1.p6 new file mode 100644 index 0000000000..d4f5295fbe --- /dev/null +++ b/challenge-005/rob4t/perl6/ch-1.p6 @@ -0,0 +1,16 @@ +#!/usr/bin/env perl6 +use v6; + +sub MAIN(Str $word, Str $file where *.IO.r = '/usr/share/dict/words') { + my $word_bag = $word.lc.comb.Bag; + + my @found_words = $file.IO.lines.grep: { + # not the same word + .lc ne $word.lc + and + # look for words AND phrases + .lc.words.map({.comb}).flat.Bag eqv $word_bag + }; + + .say for @found_words; +} diff --git a/challenge-005/rob4t/perl6/ch-2.p6 b/challenge-005/rob4t/perl6/ch-2.p6 new file mode 100644 index 0000000000..d705130729 --- /dev/null +++ b/challenge-005/rob4t/perl6/ch-2.p6 @@ -0,0 +1,11 @@ +#!/usr/bin/env perl6 +use v6; + +sub MAIN(Str $file where *.IO.r = '/usr/share/dict/words' ) { + my %a is Bag = $file.IO.lines.map({.words.map({.comb}).flat.Bag}); + + my $max_val = %a.values.max; + for %a.pairs.grep: *.value == $max_val { + say join(": ", .value, .key.kxxv.sort.join); + } +} diff --git a/stats/pwc-challenge-004.json b/stats/pwc-challenge-004.json new file mode 100644 index 0000000000..b64c3b0f43 --- /dev/null +++ b/stats/pwc-challenge-004.json @@ -0,0 +1,560 @@ +{ + "chart" : { + "type" : "column" + }, + "drilldown" : { + "series" : [ + { + "name" : "Abigail", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Abigail" + }, + { + "name" : "Adam Russell", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Adam Russell" + }, + { + "id" : "Alicia Bielsa", + "name" : "Alicia Bielsa", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "name" : "Andrezgz", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Andrezgz" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Arne Sommer", + "id" : "Arne Sommer" + }, + { + "id" : "Athanasius", + "name" : "Athanasius", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "name" : "Daniel Mantovani", + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "id" : "Daniel Mantovani" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Doug Schrag", + "id" : "Doug Schrag" + }, + { + "id" : "Duncan C. White", + "name" : "Duncan C. White", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "name" : "Francis Whittle", + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Francis Whittle" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Gustavo Chaves", + "id" : "Gustavo Chaves" + }, + { + "id" : "Jaldhar H. Vyas", + "name" : "Jaldhar H. Vyas", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "name" : "Dr James A. Smith", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ], + "id" : "Dr James A. Smith" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ], + "name" : "Jo Christian Oterhals", + "id" : "Jo Christian Oterhals" + }, + { + "name" : "Joelle Maslak", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ], + "id" : "Joelle Maslak" + }, + { + "id" : "John Barrett", + "name" : "John Barrett", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Kian-Meng Ang", + "id" : "Kian-Meng Ang" + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "name" : "Kivanc Yazan", + "id" : "Kivanc Yazan" + }, + { + "name" : "Lars Balker", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Lars Balker" + }, + { + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "id" : "Mark Senn", + "name" : "Mark Senn", + "data" : [ + [ + "Perl 6", + 2 + ] + ] + }, + { + "name" : "Matt Latusek", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Matt Latusek" + }, + { + "id" : "Maxim Kolodyazhny", + "name" : "Maxim Kolodyazhny", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "id" : "Neil Bowers", + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "name" : "Neil Bowers" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ], + "name" : "Nick Logan", + "id" : "Nick Logan" + }, + { + "id" : "Robert Gratza", + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Robert Gratza" + }, + { + "id" : "Ruben Westerberg", + "name" : "Ruben Westerberg", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "id" : "Sergio Iglesias", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Sergio Iglesias" + }, + { + "name" : "Simon Proctor", + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Simon Proctor" + }, + { + "id" : "Tim Smith", + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Tim Smith" + }, + { + "id" : "Veesh Goldman", + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Veesh Goldman" + }, + { + "id" : "Yary H", + "data" : [ + [ + "Perl 5", + 1 + ], + [ + "Perl 6", + 1 + ] + ], + "name" : "Yary H" + } + ] + }, + "title" : { + "text" : "Perl Weekly Challenge - 004" + }, + "tooltip" : { + "pointerFormat" : "<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/>" + }, + "series" : [ + { + "name" : "Champions", + "data" : [ + { + "drilldown" : "Abigail", + "y" : 2, + "name" : "Abigail" + }, + { + "y" : 2, + "name" : "Adam Russell", + "drilldown" : "Adam Russell" + }, + { + "name" : "Alicia Bielsa", + "y" : 2, + "drilldown" : "Alicia Bielsa" + }, + { + "drilldown" : "Andrezgz", + "y" : 2, + "name" : "Andrezgz" + }, + { + "drilldown" : "Arne Sommer", + "name" : "Arne Sommer", + "y" : 2 + }, + { + "drilldown" : "Athanasius", + "y" : 2, + "name" : "Athanasius" + }, + { + "name" : "Daniel Mantovani", + "y" : 1, + "drilldown" : "Daniel Mantovani" + }, + { + "drilldown" : "Doug Schrag", + "y" : 2, + "name" : "Doug Schrag" + }, + { + "drilldown" : "Duncan C. White", + "y" : 2, + "name" : "Duncan C. White" + }, + { + "name" : "Francis Whittle", + "y" : 2, + "drilldown" : "Francis Whittle" + }, + { + "name" : "Gustavo Chaves", + "y" : 2, + "drilldown" : "Gustavo Chaves" + }, + { + "drilldown" : "Jaldhar H. Vyas", + "y" : 4, + "name" : "Jaldhar H. Vyas" + }, + { + "drilldown" : "Dr James A. Smith", + "y" : 4, + "name" : "Dr James A. Smith" + }, + { + "drilldown" : "Jo Christian Oterhals", + "name" : "Jo Christian Oterhals", + "y" : 4 + }, + { + "drilldown" : "Joelle Maslak", + "y" : 4, + "name" : "Joelle Maslak" + }, + { + "name" : "John Barrett", + "y" : 2, + "drilldown" : "John Barrett" + }, + { + "drilldown" : "Kian-Meng Ang", + "name" : "Kian-Meng Ang", + "y" : 2 + }, + { + "name" : "Kivanc Yazan", + "y" : 1, + "drilldown" : "Kivanc Yazan" + }, + { + "name" : "Lars Balker", + "y" : 2, + "drilldown" : "Lars Balker" + }, + { + "drilldown" : "Laurent Rosenfeld", + "y" : 4, + "name" : "Laurent Rosenfeld" + }, + { + "name" : "Mark Senn", + "y" : 2, + "drilldown" : "Mark Senn" + }, + { + "name" : "Matt Latusek", + "y" : 2, + "drilldown" : "Matt Latusek" + }, + { + "name" : "Maxim Kolodyazhny", + "y" : 2, + "drilldown" : "Maxim Kolodyazhny" + }, + { + "y" : 1, + "name" : "Neil Bowers", + "drilldown" : "Neil Bowers" + }, + { + "drilldown" : "Nick Logan", + "name" : "Nick Logan", + "y" : 4 + }, + { + "drilldown" : "Robert Gratza", + "name" : "Robert Gratza", + "y" : 2 + }, + { + "drilldown" : "Ruben Westerberg", + "y" : 4, + "name" : "Ruben Westerberg" + }, + { + "drilldown" : "Sergio Iglesias", + "name" : "Sergio Iglesias", + "y" : 2 + }, + { + "drilldown" : "Simon Proctor", + "name" : "Simon Proctor", + "y" : 2 + }, + { + "name" : "Tim Smith", + "y" : 2, + "drilldown" : "Tim Smith" + }, + { + "name" : "Veesh Goldman", + "y" : 2, + "drilldown" : "Veesh Goldman" + }, + { + "drilldown" : "Yary H", + "y" : 2, + "name" : "Yary H" + } + ], + "colorByPoint" : 1 + } + ], + "xAxis" : { + "type" : "category" + }, + "subtitle" : { + "text" : "[Champions: 32] Last updated at 2019-04-22 01:10:35 GMT" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "legend" : { + "enabled" : 0 + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 8e4aa23598..b1b8b642e0 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,560 +1,93 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } - }, - "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "pointerFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : 1 - }, "chart" : { "type" : "column" }, "drilldown" : { "series" : [ { - "id" : "Abigail", - "data" : [ - [ - "Perl 5", - 2 - ] - ], - "name" : "Abigail" - }, - { - "name" : "Adam Russell", - "data" : [ - [ - "Perl 5", - 2 - ] - ], - "id" : "Adam Russell" - }, - { - "data" : [ - [ - "Perl 5", - 2 - ] - ], - "name" : "Alicia Bielsa", - "id" : "Alicia Bielsa" - }, - { - "id" : "Andrezgz", - "name" : "Andrezgz", - "data" : [ - [ - "Perl 5", - 2 - ] - ] - }, - { - "id" : "Arne Sommer", "data" : [ [ "Perl 6", 2 ] ], - "name" : "Arne Sommer" - }, - { - "name" : "Athanasius", - "data" : [ - [ - "Perl 5", - 2 - ] - ], - "id" : "Athanasius" - }, - { - "data" : [ - [ - "Perl 5", - 1 - ] - ], - "name" : "Daniel Mantovani", - "id" : "Daniel Mantovani" - }, - { - "data" : [ - [ - "Perl 6", - 2 - ] - ], - "name" : "Doug Schrag", - "id" : "Doug Schrag" - }, - { - "data" : [ - [ - "Perl 5", - 2 - ] - ], - "name" : "Duncan C. White", - "id" : "Duncan C. White" - }, - { - "id" : "Francis Whittle", "name" : "Francis Whittle", - "data" : [ - [ - "Perl 6", - 2 - ] - ] + "id" : "Francis Whittle" }, { "id" : "Gustavo Chaves", - "name" : "Gustavo Chaves", "data" : [ [ "Perl 5", 2 ] - ] - }, - { - "id" : "Jaldhar H. Vyas", - "name" : "Jaldhar H. Vyas", - "data" : [ - [ - "Perl 5", - 2 - ], - [ - "Perl 6", - 2 - ] - ] - }, - { - "name" : "Dr James A. Smith", - "data" : [ - [ - "Perl 5", - 2 - ], - [ - "Perl 6", - 2 - ] - ], - "id" : "Dr James A. Smith" - }, - { - "data" : [ - [ - "Perl 5", - 2 - ], - [ - "Perl 6", - 2 - ] - ], - "name" : "Jo Christian Oterhals", - "id" : "Jo Christian Oterhals" - }, - { - "id" : "Joelle Maslak", - "data" : [ - [ - "Perl 5", - 2 - ], - [ - "Perl 6", - 2 - ] - ], - "name" : "Joelle Maslak" - }, - { - "data" : [ - [ - "Perl 5", - 2 - ] - ], - "name" : "John Barrett", - |
