From ca4a69f929246b55ca5390723123b874cd1d3efa Mon Sep 17 00:00:00 2001 From: John Barrett Date: Mon, 1 Apr 2019 14:39:23 +0100 Subject: Add gist to challenge-001 answer --- challenge-001/john-barrett/perl5/README.md | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 challenge-001/john-barrett/perl5/README.md diff --git a/challenge-001/john-barrett/perl5/README.md b/challenge-001/john-barrett/perl5/README.md new file mode 100644 index 0000000000..65a2fb6106 --- /dev/null +++ b/challenge-001/john-barrett/perl5/README.md @@ -0,0 +1,75 @@ +As published on https://perlweeklychallenge.org/blog/a-new-week-a-new-challenge/
+Submissions demonstrated here using [Reply](https://metacpan.org/pod/Reply). + +> Write a script to replace the character ‘e’ with ‘E’ in the string ‘Perl Weekly Challenge’. Also print the number of times the character ‘e’ is found in the string. + +I didn't write a script so I fail this challenge already. + +``` +0> my $foo = 'Perl Weekly Challenge' +$res[0] = "Perl Weekly Challenge" +1> $foo =~ s/e/E/g; +$res[1] = 5 +2> $foo +$res[2] = "PErl WEEkly ChallEngE" +3> +``` + +> Write a one-liner to solve the FizzBuzz problem and print the numbers 1 through 20. However, any number divisible by 3 should be replaced by the word ‘fizz’ and any divisible by 5 by the word ‘buzz’. Those numbers that are both divisible by 3 and 5 become ‘fizzbuzz’. + +I don't remember where I saw this, but it is my favourite Perl5 FizzBuzz: + +``` +4> { no strict; no warnings; map { (fizz)[$_%3].(buzz)[$_%5]||$_ } 1..20 } +$res[4] = [ + [0] 1, + [1] 2, + [2] "fizz", + [3] 4, + [4] "buzz", + [5] "fizz", + [6] 7, + [7] 8, + [8] "fizz", + [9] "buzz", + [10] 11, + [11] "fizz", + [12] 13, + [13] 14, + [14] "fizzbuzz", + [15] 16, + [16] 17, + [17] "fizz", + [18] 19, + [19] "buzz" +] +``` + +Since I didn't write that myself I also fail the second part of the challenge. Not going well. Let's see... + +``` +$ perl -MAcme::FizzBuzz -e '1' | head -n 20 | tr '[:upper:]' '[:lower:]' +1 +2 +fizz +4 +buzz +fizz +7 +8 +fizz +buzz +11 +fizz +13 +14 +fizzbuzz +16 +17 +fizz +19 +buzz +``` + + There! + -- cgit From 5bc984c14147eacb7ad21a6bfe2fbe5393bba54f Mon Sep 17 00:00:00 2001 From: Gratza Date: Mon, 1 Apr 2019 16:15:26 +0200 Subject: solutions to challenge-002 --- challenge-002/rob4t/perl5/ch-1.sh | 1 + challenge-002/rob4t/perl5/ch-2.pl | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 challenge-002/rob4t/perl5/ch-1.sh create mode 100644 challenge-002/rob4t/perl5/ch-2.pl diff --git a/challenge-002/rob4t/perl5/ch-1.sh b/challenge-002/rob4t/perl5/ch-1.sh new file mode 100644 index 0000000000..97787b238f --- /dev/null +++ b/challenge-002/rob4t/perl5/ch-1.sh @@ -0,0 +1 @@ +echo "0002345" | perl -pE 's/(? Date: Mon, 1 Apr 2019 17:00:30 +0000 Subject: Week 2 Challenge #1 solution to Perl Weekly Challenge Week 2 Challenge #1 --- challenge-002/sean-meininger/pwc2.p6 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 challenge-002/sean-meininger/pwc2.p6 diff --git a/challenge-002/sean-meininger/pwc2.p6 b/challenge-002/sean-meininger/pwc2.p6 new file mode 100644 index 0000000000..1ec70b76fb --- /dev/null +++ b/challenge-002/sean-meininger/pwc2.p6 @@ -0,0 +1,5 @@ +my @numbers = <01 002 000 008 0234 55 03 1780>; +for @numbers { +say "0" and next unless $_ ~~ /<-[0]> +/; #in case of zero(es) +$_ ~~ /^^0+/ ?? say $/.postmatch !! put $_; +} -- cgit From d92febd5e800e3d64c37c13415ae53ebeeeba090 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 1 Apr 2019 10:03:11 -0700 Subject: Add a couple comments --- challenge-002/sean-meininger/pwc2.p6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-002/sean-meininger/pwc2.p6 b/challenge-002/sean-meininger/pwc2.p6 index 1ec70b76fb..3a4fd0b259 100644 --- a/challenge-002/sean-meininger/pwc2.p6 +++ b/challenge-002/sean-meininger/pwc2.p6 @@ -1,4 +1,4 @@ -my @numbers = <01 002 000 008 0234 55 03 1780>; +my @numbers = <01 002 000 008 0234 55 03 1780>; #test cases for reference for @numbers { say "0" and next unless $_ ~~ /<-[0]> +/; #in case of zero(es) $_ ~~ /^^0+/ ?? say $/.postmatch !! put $_; -- cgit From 3399a560c617590169660d034c729e620af4e7fb Mon Sep 17 00:00:00 2001 From: Daniel Mantovani Date: Mon, 1 Apr 2019 16:06:03 -0300 Subject: Create ch-2.sh --- challenge-002/daniel-mantovani/perl5/ch-2.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 challenge-002/daniel-mantovani/perl5/ch-2.sh diff --git a/challenge-002/daniel-mantovani/perl5/ch-2.sh b/challenge-002/daniel-mantovani/perl5/ch-2.sh new file mode 100644 index 0000000000..0507c39f1c --- /dev/null +++ b/challenge-002/daniel-mantovani/perl5/ch-2.sh @@ -0,0 +1,3 @@ +perl -E '$r=$r*35 + ($_ gt '9' ? -55 + ord : $_) for split "", shift;say $r' 'PERL5' + +perl -E '$_=shift;while ($_) {unshift @m, $_ % 35;$_=int($_/35)};say map {$_>9?chr 55+$_:$_} @m' 38149690 -- cgit From f7d4fa08a24cad3ca2f7e8ee7692548b058f18ab Mon Sep 17 00:00:00 2001 From: Bob Kleemann Date: Mon, 1 Apr 2019 13:16:27 -0700 Subject: Corrected spelling of my last name It's a common mistake to spell it without the proper number of n's. --- challenge-001/bob-kleemann/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-001/bob-kleemann/README b/challenge-001/bob-kleemann/README index 51a81ba0b7..78680e4035 100644 --- a/challenge-001/bob-kleemann/README +++ b/challenge-001/bob-kleemann/README @@ -1 +1 @@ -Solution by Bob Kleeman +Solution by Bob Kleemann -- cgit From 2fe9496c18a26ba9dbad2b0678f399458c09eb58 Mon Sep 17 00:00:00 2001 From: Bob Kleemann Date: Mon, 1 Apr 2019 13:19:11 -0700 Subject: Corrected spelling of my last name It's a common mistake to misspell my last name without the proper number of n's. --- challenge-002/bob-kleemann/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-002/bob-kleemann/README b/challenge-002/bob-kleemann/README index 51a81ba0b7..78680e4035 100644 --- a/challenge-002/bob-kleemann/README +++ b/challenge-002/bob-kleemann/README @@ -1 +1 @@ -Solution by Bob Kleeman +Solution by Bob Kleemann -- cgit From 0910c851c89e3da165ad33a3454f1f330ec9f1c5 Mon Sep 17 00:00:00 2001 From: John Barrett Date: Mon, 1 Apr 2019 22:05:39 +0100 Subject: Challenge 2, part 1 --- challenge-002/john-barrett/perl5/ch-1.pl | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 challenge-002/john-barrett/perl5/ch-1.pl diff --git a/challenge-002/john-barrett/perl5/ch-1.pl b/challenge-002/john-barrett/perl5/ch-1.pl new file mode 100755 index 0000000000..1567a4ba3c --- /dev/null +++ b/challenge-002/john-barrett/perl5/ch-1.pl @@ -0,0 +1,9 @@ +#!/usr/bin/env perl + +# ./ch-1.pl 00123 + +$ARGV[0] > 0 && printf ( + ( $ARGV[0] =~ /\./ + ? "%g\n" + : "%d\n" ), $ARGV[0] +); -- cgit From f572002dfb9a3a01778dbecbfa44a22c5198a325 Mon Sep 17 00:00:00 2001 From: John Barrett Date: Mon, 1 Apr 2019 22:37:41 +0100 Subject: To base35 --- challenge-002/john-barrett/perl5/ch-2.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 challenge-002/john-barrett/perl5/ch-2.pl diff --git a/challenge-002/john-barrett/perl5/ch-2.pl b/challenge-002/john-barrett/perl5/ch-2.pl new file mode 100755 index 0000000000..3293529824 --- /dev/null +++ b/challenge-002/john-barrett/perl5/ch-2.pl @@ -0,0 +1,30 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature 'say'; + +# Usage, e.g. +# ./ch-2.pl -to-base35 123 +# ./ch-2.pl -from-base35 ABCD + +my %args = @ARGV; +my @charset = ( 0..9, 'A'..'Y' ); +my $base = @charset; + +say to_base35( $args{'-to-base35'} ) if $args{'-to-base35'}; +#say to_base35( $args{'-to-base35'} ) if $args{'-to-base35'}; + +sub to_base35 { + my ( $int ) = @_; + my $sign = ( $int < 0 ) ? '-' : ''; + my @digits; + $int = abs( $int ); + do { + push @digits, $charset[ $int % $base ]; + $int = int( $int / $base ); + say $int; + } while ( $int > 0 ); + $sign . join '', reverse @digits; +} + -- cgit From b6d10413a6a81c95f44ba5df5fbf5284e8ed1f7f Mon Sep 17 00:00:00 2001 From: John Barrett Date: Mon, 1 Apr 2019 23:05:45 +0100 Subject: From base35 --- challenge-002/john-barrett/perl5/ch-2.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/challenge-002/john-barrett/perl5/ch-2.pl b/challenge-002/john-barrett/perl5/ch-2.pl index 3293529824..f18215e4f0 100755 --- a/challenge-002/john-barrett/perl5/ch-2.pl +++ b/challenge-002/john-barrett/perl5/ch-2.pl @@ -2,7 +2,7 @@ use strict; use warnings; -use feature 'say'; +use feature qw/ say /; # Usage, e.g. # ./ch-2.pl -to-base35 123 @@ -13,7 +13,21 @@ my @charset = ( 0..9, 'A'..'Y' ); my $base = @charset; say to_base35( $args{'-to-base35'} ) if $args{'-to-base35'}; -#say to_base35( $args{'-to-base35'} ) if $args{'-to-base35'}; +say from_base35( $args{'-from-base35'} ) if $args{'-from-base35'}; + +sub from_base35 { + my ( $base35 ) = @_; + my $sign = $base35 =~ s/-//g ? '-' : ''; + my @digits = split '', $base35; + my $idx = join '', @charset; + my $pos = 0; + my $val; + while ( my $char = pop @digits ) { + $val += index( $idx, $char ) * ( $base ** $pos ); + $pos++; + } + $sign . $val; +} sub to_base35 { my ( $int ) = @_; @@ -23,7 +37,6 @@ sub to_base35 { do { push @digits, $charset[ $int % $base ]; $int = int( $int / $base ); - say $int; } while ( $int > 0 ); $sign . join '', reverse @digits; } -- cgit From e52e552b878378ac6728a9004b916ac174c5b517 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 1 Apr 2019 18:02:38 -0700 Subject: Fixed filename --- challenge-002/sean-meininger/ch-1.p6 | 5 +++++ challenge-002/sean-meininger/pwc2.p6 | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 challenge-002/sean-meininger/ch-1.p6 delete mode 100644 challenge-002/sean-meininger/pwc2.p6 diff --git a/challenge-002/sean-meininger/ch-1.p6 b/challenge-002/sean-meininger/ch-1.p6 new file mode 100644 index 0000000000..3a4fd0b259 --- /dev/null +++ b/challenge-002/sean-meininger/ch-1.p6 @@ -0,0 +1,5 @@ +my @numbers = <01 002 000 008 0234 55 03 1780>; #test cases for reference +for @numbers { +say "0" and next unless $_ ~~ /<-[0]> +/; #in case of zero(es) +$_ ~~ /^^0+/ ?? say $/.postmatch !! put $_; +} diff --git a/challenge-002/sean-meininger/pwc2.p6 b/challenge-002/sean-meininger/pwc2.p6 deleted file mode 100644 index 3a4fd0b259..0000000000 --- a/challenge-002/sean-meininger/pwc2.p6 +++ /dev/null @@ -1,5 +0,0 @@ -my @numbers = <01 002 000 008 0234 55 03 1780>; #test cases for reference -for @numbers { -say "0" and next unless $_ ~~ /<-[0]> +/; #in case of zero(es) -$_ ~~ /^^0+/ ?? say $/.postmatch !! put $_; -} -- cgit From fbd6d572b00b556a79743154886d3719e3816cb5 Mon Sep 17 00:00:00 2001 From: Magnus Woldrich Date: Tue, 2 Apr 2019 08:27:22 +0200 Subject: add challenge-02 --- challenge-002/magnus-woldrich/perl5/challenge-02.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 challenge-002/magnus-woldrich/perl5/challenge-02.pl diff --git a/challenge-002/magnus-woldrich/perl5/challenge-02.pl b/challenge-002/magnus-woldrich/perl5/challenge-02.pl new file mode 100644 index 0000000000..68440ccbdf --- /dev/null +++ b/challenge-002/magnus-woldrich/perl5/challenge-02.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: +use strict; +use warnings FATAL => 'all'; + + +print for map { sprintf "%d\n", $_ } @ARGV ? @ARGV : (@ARGV = readline); + +__END__ + +$ printf "%02d\n%04d\n%042d\n" 1 2 3 | perl challenge-02.pl +1 +2 +3 -- cgit From 606855b5dacc00b2eb4e630f38484a1d8ddacf4b Mon Sep 17 00:00:00 2001 From: Magnus Woldrich Date: Tue, 2 Apr 2019 08:30:35 +0200 Subject: fix filename to follow naming convention --- challenge-002/magnus-woldrich/perl5/ch-2.pl | 14 ++++++++++++++ challenge-002/magnus-woldrich/perl5/challenge-02.pl | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 challenge-002/magnus-woldrich/perl5/ch-2.pl delete mode 100644 challenge-002/magnus-woldrich/perl5/challenge-02.pl diff --git a/challenge-002/magnus-woldrich/perl5/ch-2.pl b/challenge-002/magnus-woldrich/perl5/ch-2.pl new file mode 100644 index 0000000000..68440ccbdf --- /dev/null +++ b/challenge-002/magnus-woldrich/perl5/ch-2.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: +use strict; +use warnings FATAL => 'all'; + + +print for map { sprintf "%d\n", $_ } @ARGV ? @ARGV : (@ARGV = readline); + +__END__ + +$ printf "%02d\n%04d\n%042d\n" 1 2 3 | perl challenge-02.pl +1 +2 +3 diff --git a/challenge-002/magnus-woldrich/perl5/challenge-02.pl b/challenge-002/magnus-woldrich/perl5/challenge-02.pl deleted file mode 100644 index 68440ccbdf..0000000000 --- a/challenge-002/magnus-woldrich/perl5/challenge-02.pl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/perl -# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2: -use strict; -use warnings FATAL => 'all'; - - -print for map { sprintf "%d\n", $_ } @ARGV ? @ARGV : (@ARGV = readline); - -__END__ - -$ printf "%02d\n%04d\n%042d\n" 1 2 3 | perl challenge-02.pl -1 -2 -3 -- cgit From 536145b289b04b68218cef58a9158e7942988ecc Mon Sep 17 00:00:00 2001 From: Magnus Woldrich Date: Tue, 2 Apr 2019 10:55:09 +0200 Subject: add ch-2.p6 --- challenge-002/magnus-woldrich/perl6/ch-2.p6 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 challenge-002/magnus-woldrich/perl6/ch-2.p6 diff --git a/challenge-002/magnus-woldrich/perl6/ch-2.p6 b/challenge-002/magnus-woldrich/perl6/ch-2.p6 new file mode 100644 index 0000000000..0682e85732 --- /dev/null +++ b/challenge-002/magnus-woldrich/perl6/ch-2.p6 @@ -0,0 +1,12 @@ +#!/bin/perl6 +# my first ever perl6 script +# 10/10 would do again + +if @*ARGS { + for @*ARGS -> $arg { + printf "%d\n", $arg; + } +} +else { + printf "%d\n", $_ for lines(); +} -- cgit From 668c471461e736b09a893d9abcadbf1467d95613 Mon Sep 17 00:00:00 2001 From: Alexander <39702500+threadless-screw@users.noreply.github.com> Date: Tue, 2 Apr 2019 09:00:11 +0000 Subject: Update README --- challenge-002/ozzy/README | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/challenge-002/ozzy/README b/challenge-002/ozzy/README index 44e39371ef..40d33b4f43 100644 --- a/challenge-002/ozzy/README +++ b/challenge-002/ozzy/README @@ -1 +1,36 @@ Solution by Ozzy + +------------ +Challenge 1: +------------ +The simplest solution I could think of was conversion of a numeric (integer) string through +the use of the built-in Int method: + + my $a = "004" # Example string representing positive integer with leading zeros + my $b = $a.Int # Convert string to Int using built-in method Int, and so strip zeros + say $b # Print the Int; OUTPUT: 4 + +In a Perl6/Bash one-liner, this would look something like this: + + perl6 -pe '$_=.Int' <<< 004 + +but this, in itself, isn't very practical since Bash can do it with even less fuzz: + + a="004" + echo ${a##+(0)} + +------------ +Challenge 2: +------------ +The obvious way to go is probably the use of Perl6' .base and .parse-base methods: + +loop { + + my Str $a = prompt("\nPlease, give me a decimal (base-10) number : "); + say("$a in decimal notation is { $a.Int.base(35) } in base-35 notation."); + + $a = prompt("\nNow give me a base-35 number [A-Y0-9]: "); + say("$a in base-35 notation is { $a.parse-base(35) } in base-10 notation.") + +} + -- cgit From f0d2dd082b1b82fa52d692030a81a33c307e5c7e Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 14:47:31 +0100 Subject: - Saved master summary stats as well as challenge 001 stats. --- stats/pwc-challenge-001.json | 819 +++++++++++++++++++++++++++++++++++++++++++ stats/pwc-master-stats.json | 210 +++++++++++ 2 files changed, 1029 insertions(+) create mode 100644 stats/pwc-challenge-001.json create mode 100644 stats/pwc-master-stats.json diff --git a/stats/pwc-challenge-001.json b/stats/pwc-challenge-001.json new file mode 100644 index 0000000000..2e6e58f4bd --- /dev/null +++ b/stats/pwc-challenge-001.json @@ -0,0 +1,819 @@ +{ + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, + "chart" : { + "type" : "column" + }, + "series" : [ + { + "name" : "Champions", + "colorByPoint" : 1, + "data" : [ + { + "name" : "Alex Daniel", + "drilldown" : "Alex Daniel", + "y" : 2 + }, + { + "name" : "Antonio Gamiz", + "drilldown" : "Antonio Gamiz", + "y" : 2 + }, + { + "drilldown" : "Arpad Toth", + "name" : "Arpad Toth", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Athanasius", + "name" : "Athanasius" + }, + { + "y" : 2, + "name" : "Bob Kleemann", + "drilldown" : "Bob Kleemann" + }, + { + "y" : 1, + "name" : "Daniel Mantovani", + "drilldown" : "Daniel Mantovani" + }, + { + "y" : 2, + "name" : "Dave Cross", + "drilldown" : "Dave Cross" + }, + { + "y" : 1, + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby" + }, + { + "drilldown" : "David Kayal", + "name" : "David Kayal", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Doug Schrag", + "name" : "Doug Schrag" + }, + { + "y" : 2, + "drilldown" : "Duncan C. White", + "name" : "Duncan C. White" + }, + { + "name" : "Eddy HS", + "drilldown" : "Eddy HS", + "y" : 2 + }, + { + "name" : "Finley", + "drilldown" : "Finley", + "y" : 2 + }, + { + "y" : 1, + "drilldown" : "Fred Zinn", + "name" : "Fred Zinn" + }, + { + "name" : "Freddie B", + "drilldown" : "Freddie B", + "y" : 2 + }, + { + "y" : 1, + "name" : "Gustavo Chaves", + "drilldown" : "Gustavo Chaves" + }, + { + "name" : "Jaldhar H. Vyas", + "drilldown" : "Jaldhar H. Vyas", + "y" : 4 + }, + { + "y" : 2, + "name" : "Jeff", + "drilldown" : "Jeff" + }, + { + "y" : 2, + "drilldown" : "Jeremy Carman", + "name" : "Jeremy Carman" + }, + { + "y" : 1, + "name" : "Jim Bacon", + "drilldown" : "Jim Bacon" + }, + { + "y" : 1, + "name" : "JJ Merelo", + "drilldown" : "JJ Merelo" + }, + { + "drilldown" : "Jo Christian Oterhals", + "name" : "Jo Christian Oterhals", + "y" : 4 + }, + { + "y" : 4, + "drilldown" : "Joelle Maslak", + "name" : "Joelle Maslak" + }, + { + "name" : "John Barrett", + "drilldown" : "John Barrett", + "y" : 1 + }, + { + "drilldown" : "Juan Caballero", + "name" : "Juan Caballero", + "y" : 2 + }, + { + "y" : 2, + "name" : "Khalid", + "drilldown" : "Khalid" + }, + { + "y" : 2, + "drilldown" : "Kian-Meng Ang", + "name" : "Kian-Meng Ang" + }, + { + "y" : 2, + "drilldown" : "Kivanc Yazan", + "name" : "Kivanc Yazan" + }, + { + "y" : 4, + "drilldown" : "Lars Balkar", + "name" : "Lars Balkar" + }, + { + "y" : 3, + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld" + }, + { + "y" : 2, + "drilldown" : "Mark Senn", + "name" : "Mark Senn" + }, + { + "y" : 2, + "drilldown" : "Martin Mugeni", + "name" : "Martin Mugeni" + }, + { + "name" : "Neil Bowers", + "drilldown" : "Neil Bowers", + "y" : 1 + }, + { + "y" : 4, + "name" : "Nick Logan", + "drilldown" : "Nick Logan" + }, + { + "name" : "Oleskii Tsvitenov", + "drilldown" : "Oleskii Tsvitenov", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Ozzy", + "name" : "Ozzy" + }, + { + "name" : "Pavel Jurca", + "drilldown" : "Pavel Jurca", + "y" : 2 + }, + { + "y" : 2, + "name" : "Pete Houston", + "drilldown" : "Pete Houston" + }, + { + "drilldown" : "Philippe Bruhat", + "name" : "Philippe Bruhat", + "y" : 2 + }, + { + "y" : 1, + "name" : "Prajith P", + "drilldown" : "Prajith P" + }, + { + "y" : 2, + "drilldown" : "Sean Meininger", + "name" : "Sean Meininger" + }, + { + "y" : 4, + "name" : "Simon Proctor", + "drilldown" : "Simon Proctor" + }, + { + "drilldown" : "Simon Reinhardt", + "name" : "Simon Reinhardt", + "y" : 2 + }, + { + "y" : 4, + "drilldown" : "Steve Rogerson", + "name" : "Steve Rogerson" + }, + { + "name" : "Steven Wilson", + "drilldown" : "Steven Wilson", + "y" : 2 + }, + { + "y" : 1, + "drilldown" : "Tiago Stock", + "name" : "Tiago Stock" + }, + { + "y" : 2, + "drilldown" : "Tore Andersson", + "name" : "Tore Andersson" + }, + { + "name" : "Veesh Goldman", + "drilldown" : "Veesh Goldman", + "y" : 1 + }, + { + "y" : 1, + "drilldown" : "William Gilmore", + "name" : "William Gilmore" + } + ] + } + ], + "legend" : { + "enabled" : 0 + }, + "drilldown" : { + "series" : [ + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Alex Daniel", + "name" : "Alex Daniel" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Antonio Gamiz", + "name" : "Antonio Gamiz" + }, + { + "name" : "Arpad Toth", + "id" : "Arpad Toth", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "name" : "Athanasius", + "id" : "Athanasius", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "name" : "Bob Kleemann", + "id" : "Bob Kleemann", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "id" : "Daniel Mantovani", + "name" : "Daniel Mantovani" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Dave Cross", + "id" : "Dave Cross" + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "id" : "Dave Jacoby", + "name" : "Dave Jacoby" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "David Kayal", + "id" : "David Kayal" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Doug Schrag", + "id" : "Doug Schrag" + }, + { + "id" : "Duncan C. White", + "name" : "Duncan C. White", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Eddy HS", + "id" : "Eddy HS" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Finley", + "name" : "Finley" + }, + { + "name" : "Fred Zinn", + "id" : "Fred Zinn", + "data" : [ + [ + "Perl 5", + 1 + ] + ] + }, + { + "id" : "Freddie B", + "name" : "Freddie B", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "name" : "Gustavo Chaves", + "id" : "Gustavo Chaves" + }, + { + "name" : "Jaldhar H. Vyas", + "id" : "Jaldhar H. Vyas", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "name" : "Jeff", + "id" : "Jeff", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "name" : "Jeremy Carman", + "id" : "Jeremy Carman", + "data" : [ + [ + "Perl 5", + 1 + ], + [ + "Perl 6", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "name" : "Jim Bacon", + "id" : "Jim Bacon" + }, + { + "name" : "JJ Merelo", + "id" : "JJ Merelo", + "data" : [ + [ + "Perl 6", + 1 + ] + ] + }, + { + "name" : "Jo Christian Oterhals", + "id" : "Jo Christian Oterhals", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "name" : "Joelle Maslak", + "id" : "Joelle Maslak", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "name" : "John Barrett", + "id" : "John Barrett" + }, + { + "id" : "Juan Caballero", + "name" : "Juan Caballero", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Khalid", + "name" : "Khalid" + }, + { + "id" : "Kian-Meng Ang", + "name" : "Kian-Meng Ang", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Kivanc Yazan", + "name" : "Kivanc Yazan" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ], + "id" : "Lars Balkar", + "name" : "Lars Balkar" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 1 + ] + ], + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Mark Senn", + "name" : "Mark Senn" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Martin Mugeni", + "id" : "Martin Mugeni" + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "name" : "Neil Bowers", + "id" : "Neil Bowers" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ], + "id" : "Nick Logan", + "name" : "Nick Logan" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Oleskii Tsvitenov", + "id" : "Oleskii Tsvitenov" + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Ozzy", + "id" : "Ozzy" + }, + { + "id" : "Pavel Jurca", + "name" : "Pavel Jurca", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "name" : "Pete Houston", + "id" : "Pete Houston" + }, + { + "id" : "Philippe Bruhat", + "name" : "Philippe Bruhat", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "id" : "Prajith P", + "name" : "Prajith P", + "data" : [ + [ + "Perl 5", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "name" : "Sean Meininger", + "id" : "Sean Meininger" + }, + { + "name" : "Simon Proctor", + "id" : "Simon Proctor", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "id" : "Simon Reinhardt", + "name" : "Simon Reinhardt", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "id" : "Steve Rogerson", + "name" : "Steve Rogerson", + "data" : [ + [ + "Perl 5", + 2 + ], + [ + "Perl 6", + 2 + ] + ] + }, + { + "id" : "Steven Wilson", + "name" : "Steven Wilson", + "data" : [ + [ + "Perl 5", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "id" : "Tiago Stock", + "name" : "Tiago Stock" + }, + { + "data" : [ + [ + "Perl 5", + 2 + ] + ], + "id" : "Tore Andersson", + "name" : "Tore Andersson" + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] + ], + "id" : "Veesh Goldman", + "name" : "Veesh Goldman" + }, + { + "id" : "William Gilmore", + "name" : "William Gilmore", + "data" : [ + [ + "Perl 5", + 1 + ] + ] + } + ] + }, + "subtitle" : { + "text" : "[Champions: 49] Last updated at 2019-04-01 16:05:52 GMT" + }, + "title" : { + "text" : "Perl Weekly Challenge - CURRENT" + }, + "tooltip" : { + "followPointer" : 1, + "headerFormat" : "{series.name}
", + "pointerFormat" : "{point.name}: {point.y:f}
" + }, + "xAxis" : { + "type" : "category" + } +} diff --git a/stats/pwc-master-stats.json b/stats/pwc-master-stats.json new file mode 100644 index 0000000000..7ced8ec40f --- /dev/null +++ b/stats/pwc-master-stats.json @@ -0,0 +1,210 @@ +{ + "title" : { + "text" : "Perl Weekly Challenge - 2019" + }, + "chart" : { + "type" : "column" + }, + "xAxis" : { + "categories" : [ + "Alex Daniel", + "Alexander Karelas", + "Alexey Melezhik", + "Antonio Gamiz", + "Arpad Toth", + "Athanasius", + "Aubrey Quarcoo", + "Bob Kleemann", + "Daniel Mantovani", + "Dave Cross", + "Dave Jacoby", + "David Kayal", + "Doug Schrag", + "Duncan C. White", + "Eddy HS", + "Finley", + "Fred Zinn", + "Freddie B", + "Gustavo Chaves", + "Jaldhar H. Vyas", + "Jeff", + "Jeremy Carman", + "Jim Bacon", + "JJ Merelo", + "Jo Christian Oterhals", + "Joelle Maslak", + "John Barrett", + "Juan Caballero", + "Khalid", + "Kian-Meng Ang", + "Kivanc Yazan", + "Lars Balkar", + "Laurent Rosenfeld", + "Magnus Woldrich", + "Mark Senn", + "Martin Mugeni", + "Michael Schaap", + "Neil Bowers", + "Nick Logan", + "Oleskii Tsvitenov", + "Ozzy", + "Pavel Jurca", + "Pete Houston", + "Philippe Bruhat", + "Prajith P", + "Ruben Westerberg", + "Sean Meininger", + "Simon Proctor", + "Simon Reinhardt", + "Steve Rogerson", + "Steven Lembark", + "Steven Wilson", + "Tiago Stock", + "Tore Andersson", + "Veesh Goldman", + "William Gilmore" + ] + }, + "subtitle" : { + "text" : "[Champions: 56] Last updated at 2019-04-01 16:05:25 GMT" + }, + "series" : [ + { + "name" : "Perl 5", + "data" : [ + 0, + 0, + 0, + 0, + 2, + 2, + 0, + 2, + 1, + 2, + 1, + 2, + 0, + 2, + 2, + 0, + 1, + 2, + 1, + 2, + 2, + 1, + 1, + 0, + 2, + 2, + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 0, + 0, + 0, + 0, + 1, + 2, + 2, + 0, + 2, + 2, + 2, + 1, + 0, + 0, + 2, + 2, + 2, + 0, + 2, + 1, + 2, + 1, + 1 + ] + }, + { + "name" : "Perl 6", + "data" : [ + 2, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 2, + 0, + 0, + 0, + 2, + 0, + 1, + 0, + 1, + 2, + 2, + 0, + 0, + 0, + 0, + 0, + 2, + 1, + 0, + 2, + 2, + 0, + 0, + 2, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 2, + 2, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ], + "yAxis" : { + "min" : 0, + "title" : { + "text" : "" + } + }, + "tooltip" : { + "pointFormat" : "{series.name}: {point.y}
", + "shared" : 1 + }, + "plotOptions" : { + "column" : { + "stacking" : "percent" + } + } +} -- cgit From 196d77de093fced6d75c3322b703588eaf5d9d4f Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 15:01:06 +0100 Subject: - Corrected member name. --- members.json | 2 +- stats/pwc-challenge-001.json | 8 ++++---- stats/pwc-master-stats.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/members.json b/members.json index e1d655f485..c0d9ffdd31 100755 --- a/members.json +++ b/members.json @@ -30,7 +30,7 @@ "khalid" : "Khalid", "kian-meng-ang" : "Kian-Meng Ang", "kivanc-yazan" : "Kivanc Yazan", - "lars-balker" : "Lars Balkar", + "lars-balker" : "Lars Balker", "laurent-rosenfeld" : "Laurent Rosenfeld", "magnus-woldrich" : "Magnus Woldrich", "mark-senn" : "Mark Senn", diff --git a/stats/pwc-challenge-001.json b/stats/pwc-challenge-001.json index 2e6e58f4bd..646a5b24fb 100644 --- a/stats/pwc-challenge-001.json +++ b/stats/pwc-challenge-001.json @@ -163,8 +163,8 @@ }, { "y" : 4, - "drilldown" : "Lars Balkar", - "name" : "Lars Balkar" + "drilldown" : "Lars Balker", + "name" : "Lars Balker" }, { "y" : 3, @@ -581,8 +581,8 @@ 2 ] ], - "id" : "Lars Balkar", - "name" : "Lars Balkar" + "id" : "Lars Balker", + "name" : "Lars Balker" }, { "data" : [ diff --git a/stats/pwc-master-stats.json b/stats/pwc-master-stats.json index 7ced8ec40f..87a8ca154e 100644 --- a/stats/pwc-master-stats.json +++ b/stats/pwc-master-stats.json @@ -38,7 +38,7 @@ "Khalid", "Kian-Meng Ang", "Kivanc Yazan", - "Lars Balkar", + "Lars Balker", "Laurent Rosenfeld", "Magnus Woldrich", "Mark Senn", -- cgit From fb5baa498339510d26dceb5363ea841203dddf16 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 15:42:16 +0100 Subject: - Added blog by Jo Christian Oterhals for challenge 002. --- challenge-002/jo-christian-oterhals/blog.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-002/jo-christian-oterhals/blog.txt diff --git a/challenge-002/jo-christian-oterhals/blog.txt b/challenge-002/jo-christian-oterhals/blog.txt new file mode 100644 index 0000000000..a345f7c3fa --- /dev/null +++ b/challenge-002/jo-christian-oterhals/blog.txt @@ -0,0 +1 @@ +https://medium.com/@jcoterhals/perl-6-small-stuff-16-all-your-base-are-belong-to-us-266763713d64 -- cgit From 1a9efd4d05baba135fdb2ef912bbf53589ad2b60 Mon Sep 17 00:00:00 2001 From: ohmycloud Date: Tue, 2 Apr 2019 23:07:07 +0800 Subject: add user ohmycloud --- challenge-002/ohmycloud/README | 1 + challenge-002/ohmycloud/perl6/ch-1.p6 | 3 +++ challenge-002/ohmycloud/perl6/ch-2.p6 | 13 +++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 challenge-002/ohmycloud/README create mode 100644 challenge-002/ohmycloud/perl6/ch-1.p6 create mode 100644 challenge-002/ohmycloud/perl6/ch-2.p6 diff --git a/challenge-002/ohmycloud/README b/challenge-002/ohmycloud/README new file mode 100644 index 0000000000..e993fafea7 --- /dev/null +++ b/challenge-002/ohmycloud/README @@ -0,0 +1 @@ +Solution by Ohmycloud diff --git a/challenge-002/ohmycloud/perl6/ch-1.p6 b/challenge-002/ohmycloud/perl6/ch-1.p6 new file mode 100644 index 0000000000..6cd4ddd03c --- /dev/null +++ b/challenge-002/ohmycloud/perl6/ch-1.p6 @@ -0,0 +1,3 @@ +for <00040 03.5 00.002 .02 .3 0.03> -> $n { + say ($n ~~ /^ 0* %% /).postmatch; +} diff --git a/challenge-002/ohmycloud/perl6/ch-2.p6 b/challenge-002/ohmycloud/perl6/ch-2.p6 new file mode 100644 index 0000000000..fb61967308 --- /dev/null +++ b/challenge-002/ohmycloud/perl6/ch-2.p6 @@ -0,0 +1,13 @@ +# convert from base35 to base10 +sub decimal-to-base35(Str $n) { + :35($n.Str) +} + +say decimal-to-base35("OOM"); + +# convert from base10 to base35 +sub base35-to-decimal(Int $n) { + $n.base(35) +} + +say base35-to-decimal(30262); \ No newline at end of file -- cgit From dd6f7bb1e41cc74a25ef8e005d6718a2b87878b6 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 16:40:05 +0100 Subject: - Added blog by Dave Jacoby. --- challenge-002/dave-jacoby/blog.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-002/dave-jacoby/blog.txt diff --git a/challenge-002/dave-jacoby/blog.txt b/challenge-002/dave-jacoby/blog.txt new file mode 100644 index 0000000000..4861cfc681 --- /dev/null +++ b/challenge-002/dave-jacoby/blog.txt @@ -0,0 +1 @@ +https://jacoby.github.io//2019/04/02/converting-to-and-from-base35.html -- cgit From 7ff3cc85683b1ac53966648703f9825b86d21daf Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 17:26:58 +0100 Subject: - Added solutions by Bob Kleemann. --- challenge-002/bob-kleemann/perl5/ch-1.sh | 1 + challenge-002/bob-kleemann/perl5/ch-2.pl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 challenge-002/bob-kleemann/perl5/ch-1.sh create mode 100644 challenge-002/bob-kleemann/perl5/ch-2.pl diff --git a/challenge-002/bob-kleemann/perl5/ch-1.sh b/challenge-002/bob-kleemann/perl5/ch-1.sh new file mode 100644 index 0000000000..461df04b26 --- /dev/null +++ b/challenge-002/bob-kleemann/perl5/ch-1.sh @@ -0,0 +1 @@ +perl -pE 's/^\+?0*(?=\d+)//' diff --git a/challenge-002/bob-kleemann/perl5/ch-2.pl b/challenge-002/bob-kleemann/perl5/ch-2.pl new file mode 100644 index 0000000000..fe45855195 --- /dev/null +++ b/challenge-002/bob-kleemann/perl5/ch-2.pl @@ -0,0 +1,16 @@ +#! /usr/bin/env perl + +use v5.18.0; +use warnings; + +my $base = 0; +my %digits = map { $_ => $base++ } "0" .. "9", "a" .. "y"; +my $base_chars = join( "" => keys(%digits) ); + +while (<>) { + s/^[^$base_chars]*//i; # Remove leading junk + ($_) = split /[^$base_chars]/i; # Remove trailing junk + my $n = 0; + $n = $base * $n + $digits{ lc() } foreach split //; + say "base$base(", $_, ') == ', $n; +} -- cgit From c8edb9612b44910fa26c19e11f3f845e47691d84 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 17:45:36 +0100 Subject: - Added solutions by Simon Proctor. --- challenge-002/simon-proctor/perl5/ch-1.sh | 1 + challenge-002/simon-proctor/perl5/ch-2.pl | 16 ++++++++++++++++ challenge-002/simon-proctor/perl5/to-base-35.pl | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 challenge-002/simon-proctor/perl5/ch-1.sh create mode 100644 challenge-002/simon-proctor/perl5/ch-2.pl create mode 100644 challenge-002/simon-proctor/perl5/to-base-35.pl diff --git a/challenge-002/simon-proctor/perl5/ch-1.sh b/challenge-002/simon-proctor/perl5/ch-1.sh new file mode 100644 index 0000000000..6055088ce0 --- /dev/null +++ b/challenge-002/simon-proctor/perl5/ch-1.sh @@ -0,0 +1 @@ +perl -E 'my $v = shift @ARGV;$v =~ s!^0+!!;say $v' diff --git a/challenge-002/simon-proctor/perl5/ch-2.pl b/challenge-002/simon-proctor/perl5/ch-2.pl new file mode 100644 index 0000000000..7354af499c --- /dev/null +++ b/challenge-002/simon-proctor/perl5/ch-2.pl @@ -0,0 +1,16 @@ +use strict; +use v5.10; + +my @in = split "", ( shift @ARGV ); +my $out = 0; + +my $c = 0; +my %map = map { $_ => $c++ } (0..9,"A".."Y"); + +my $mult = 1; +for my $char ( reverse @in ) { + $out += ( $mult * $map{$char} ); + $mult *= 35; +} + +say $out; diff --git a/challenge-002/simon-proctor/perl5/to-base-35.pl b/challenge-002/simon-proctor/perl5/to-base-35.pl new file mode 100644 index 0000000000..4bee1b597d --- /dev/null +++ b/challenge-002/simon-proctor/perl5/to-base-35.pl @@ -0,0 +1,18 @@ +use strict; +use v5.10; + +my $in = shift @ARGV; +my @out = (); + +my $c = 0; +my %map = map { $c++ => $_ } (0..9,"A".."Y"); + +while ( $in ) { + my $rem = $in % 35; + push @out, $map{$rem}; + $in = $in - $rem; + $in = $in / 35; +} + +say join( "", reverse @out ); + -- cgit From 253327bfe96ba85cd8b9672b0eba8525b9e7396c Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 17:53:46 +0100 Subject: - Added solutions by Laurent Rosenfeld. --- challenge-002/laurent-rosenfeld/perl5/ch-1.sh | 4 ++++ challenge-002/laurent-rosenfeld/perl5/ch-2.pl | 17 +++++++++++++++++ challenge-002/laurent-rosenfeld/perl6/ch-1.p6 | 2 ++ challenge-002/laurent-rosenfeld/perl6/ch-2.p6 | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 challenge-002/laurent-rosenfeld/perl5/ch-1.sh create mode 100644 challenge-002/laurent-rosenfeld/perl5/ch-2.pl create mode 100644 challenge-002/laurent-rosenfeld/perl6/ch-1.p6 create mode 100644 challenge-002/laurent-rosenfeld/perl6/ch-2.p6 diff --git a/challenge-002/laurent-rosenfeld/perl5/ch-1.sh b/challenge-002/laurent-rosenfeld/perl5/ch-1.sh new file mode 100644 index 0000000000..23800dcfce --- /dev/null +++ b/challenge-002/laurent-rosenfeld/perl5/ch-1.sh @@ -0,0 +1,4 @@ +echo '0456' | perl -pe 's/^0+//' +echo '0007865' | perl -pe 's/^0+//' +echo '8976' | perl -pe 's/^0+//' +echo '0000123456' | perl -pe 's/^0+//' diff --git a/challenge-002/laurent-rosenfeld/perl5/ch-2.pl b/challenge-002/laurent-rosenfeld/perl5/ch-2.pl new file mode 100644 index 0000000000..1be487623f --- /dev/null +++ b/challenge-002/laurent-rosenfeld/perl5/ch-2.pl @@ -0,0 +1,17 @@ +use strict; +use warnings; +use feature "say"; +use constant lookup => ('0'..'9','A'..'Z'); + +sub convert_base { + my ($num, $base) = @_; + my $result = ""; + do { + $result .= (lookup)[$num % $base]; + $num = int ($num/$base); + } while $num > 0; + $result = reverse $result; +} +for my $number (0..45, qw/1757 533 658467/) { + say "$number\t:\t", convert_base $number, 35; +} diff --git a/challenge-002/laurent-rosenfeld/perl6/ch-1.p6 b/challenge-002/laurent-rosenfeld/perl6/ch-1.p6 new file mode 100644 index 0000000000..eb183d5b63 --- /dev/null +++ b/challenge-002/laurent-rosenfeld/perl6/ch-1.p6 @@ -0,0 +1,2 @@ +use v6; +say +$_ for qw /0456 0007865 8976 0000123456/; diff --git a/challenge-002/laurent-rosenfeld/perl6/ch-2.p6 b/challenge-002/laurent-rosenfeld/perl6/ch-2.p6 new file mode 100644 index 0000000000..81d6f7766c --- /dev/null +++ b/challenge-002/laurent-rosenfeld/perl6/ch-2.p6 @@ -0,0 +1,2 @@ +use v6; +say $_.base(35) for flat(0..45, 1757, 533, 658467); -- cgit From 6ae112afebde8db2802426d8f84ae2262558c245 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 18:02:34 +0100 Subject: - Added new member Robert Gratza. --- members.json | 1 + 1 file changed, 1 insertion(+) diff --git a/members.json b/members.json index c0d9ffdd31..691f122452 100755 --- a/members.json +++ b/members.json @@ -44,6 +44,7 @@ "pete-houston" : "Pete Houston", "philippe-bruhat" : "Philippe Bruhat", "prajith-p" : "Prajith P", + "rob4t" : "Robert Gratza", "ruben-westerberg" : "Ruben Westerberg", "sean-meininger" : "Sean Meininger", "simon-proctor" : "Simon Proctor", -- cgit From 67c231623ba6f1bf954f247dc717272945a0fab0 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 18:06:17 +0100 Subject: Moved script to the correct folder. --- challenge-002/sean-meininger/ch-1.p6 | 5 ----- challenge-002/sean-meininger/perl6/ch-1.p6 | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 challenge-002/sean-meininger/ch-1.p6 create mode 100644 challenge-002/sean-meininger/perl6/ch-1.p6 diff --git a/challenge-002/sean-meininger/ch-1.p6 b/challenge-002/sean-meininger/ch-1.p6 deleted file mode 100644 index 3a4fd0b259..0000000000 --- a/challenge-002/sean-meininger/ch-1.p6 +++ /dev/null @@ -1,5 +0,0 @@ -my @numbers = <01 002 000 008 0234 55 03 1780>; #test cases for reference -for @numbers { -say "0" and next unless $_ ~~ /<-[0]> +/; #in case of zero(es) -$_ ~~ /^^0+/ ?? say $/.postmatch !! put $_; -} diff --git a/challenge-002/sean-meininger/perl6/ch-1.p6 b/challenge-002/sean-meininger/perl6/ch-1.p6 new file mode 100644 index 0000000000..3a4fd0b259 --- /dev/null +++ b/challenge-002/sean-meininger/perl6/ch-1.p6 @@ -0,0 +1,5 @@ +my @numbers = <01 002 000 008 0234 55 03 1780>; #test cases for reference +for @numbers { +say "0" and next unless $_ ~~ /<-[0]> +/; #in case of zero(es) +$_ ~~ /^^0+/ ?? say $/.postmatch !! put $_; +} -- cgit From 1a4b6a31486c3cc891dc96b7b50934e649e3c05d Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 2 Apr 2019 18:48:20 +0100 Subject: Added how to contribute instructions. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fcf64aab94..3d38c6349a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ -## Perl Weekly Challenge Club +# Perl Weekly Challenge Club This is the central repository for the members of **Perl Weekly Challenge**. The members can submit the solution to the challenge each week under version control. + +## How to contribute? +First find out the latest challenge folder, more likely the highest numbered folder is the latest challenge folder e.g. challenge-002. If you are an existing member, you would probably find a folder by your name. For example, if your name is "Job Blog" then there would be a folder called "joe-blog". Under your named folder, you would find a file **README**. Depending on your choice of language, you should create a folder here e.g. **perl5** for Perl 5 and **perl6** for Perl 6. Inside each of these folders you can save your solutions. If it is perl5 script for challenge 1 then call it **ch-1.pl**. Similarly if it is perl5 script for challenge 2 then call it **ch-2.pl**. For perl6 solutions, call it **ch-1.p6** and **ch-2.p6** respectively. And if you are writing one-liner then call it **ch-1.sh** or **ch-2.sh**. If you are contributing for the first time, please create your named folder as described above. Also let us know what name you would like us to use? + +In case you have created a blog about your solutions, then create a file called **blog.txt** and add the link to it. -- cgit From 4606c1fea1d63e7fcda943f7f1a34932d97b1983 Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 11:14:44 +0200 Subject: add solution for week 1, ch-01 --- challenge-001/ailbhe-tweedie/README | 1 + challenge-001/ailbhe-tweedie/perl5/ch-01.pl | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 challenge-001/ailbhe-tweedie/README create mode 100755 challenge-001/ailbhe-tweedie/perl5/ch-01.pl diff --git a/challenge-001/ailbhe-tweedie/README b/challenge-001/ailbhe-tweedie/README new file mode 100644 index 0000000000..36d4034b70 --- /dev/null +++ b/challenge-001/ailbhe-tweedie/README @@ -0,0 +1 @@ +Solution by Ailbhe Tweedie diff --git a/challenge-001/ailbhe-tweedie/perl5/ch-01.pl b/challenge-001/ailbhe-tweedie/perl5/ch-01.pl new file mode 100755 index 0000000000..22c1d97107 --- /dev/null +++ b/challenge-001/ailbhe-tweedie/perl5/ch-01.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +# +# Write a script to replace the character ‘e’ with ‘E’ in the string +# ‘Perl Weekly Challenge’. Also print the number of times the +# character ‘e’ is found in the string. + +my $string = 'Perl Weekly Challenge'; +my $numberOfEs; +while ($string =~ /\G[^e]*e/g) { + $numberOfEs++; +} +print "Es: $numberOfEs\n"; +my $replaced = $string =~ s/e/E/g; +print "replaced: $replaced"; -- cgit From c70540c41e15aadbed7cf3df04a6a982f94059c1 Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 11:20:25 +0200 Subject: 002-p5-01: add initial solution --- challenge-002/ailbhe-tweedie/perl5/ch-01.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 challenge-002/ailbhe-tweedie/perl5/ch-01.pl diff --git a/challenge-002/ailbhe-tweedie/perl5/ch-01.pl b/challenge-002/ailbhe-tweedie/perl5/ch-01.pl new file mode 100755 index 0000000000..645d671986 --- /dev/null +++ b/challenge-002/ailbhe-tweedie/perl5/ch-01.pl @@ -0,0 +1,11 @@ +#!/usr/bin/env perl +# +# Solution to challenge #1 of the Perl Weekly Challenge 002. +# +# TODO: I would like to add some automated testing to this solution. + +$number = '001'; + +$number =~ s/^0+//; + +print "$number\n"; -- cgit From 2fb6c2e357732c020209ea130df2b96290a36844 Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 11:29:31 +0200 Subject: 002-p5-01: read from STDIN --- challenge-002/ailbhe-tweedie/perl5/ch-01.pl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/challenge-002/ailbhe-tweedie/perl5/ch-01.pl b/challenge-002/ailbhe-tweedie/perl5/ch-01.pl index 645d671986..e4a72a65e9 100755 --- a/challenge-002/ailbhe-tweedie/perl5/ch-01.pl +++ b/challenge-002/ailbhe-tweedie/perl5/ch-01.pl @@ -1,11 +1,9 @@ #!/usr/bin/env perl # # Solution to challenge #1 of the Perl Weekly Challenge 002. -# -# TODO: I would like to add some automated testing to this solution. -$number = '001'; - -$number =~ s/^0+//; - -print "$number\n"; +while (<>) { + chomp; + $_ =~ s/^0+//; + print "$_\n"; +} -- cgit From 91245b2c0f12df8f7d919350611bcbfe28396618 Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 12:35:13 +0200 Subject: 002-p5-02: write initial version of toBase35() --- challenge-002/ailbhe-tweedie/perl5/ch-02.pl | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 challenge-002/ailbhe-tweedie/perl5/ch-02.pl diff --git a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl new file mode 100755 index 0000000000..ac6174c6bd --- /dev/null +++ b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl @@ -0,0 +1,54 @@ +#!/usr/bin/env perl +# +# Solution to challenge #2 of the Perl Weekly Challenge 002. +# +# Task: Write a script that can convert integers to and from a base35 +# representation, using the characters 0-9 and A-Y. +# +# Prerequisites: cpan install Scalar::Util::Numeric + +use strict; +use warnings; +use Scalar::Util::Numeric qw(isint); +use Data::Dump; + +my $BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXY"; + +while (<>) { + chomp; + my $input = $_; + next unless isint $input; + my $output = convertToBase35($input); + print "output: $output\n"; +} + +sub convertToBase35 { + my $input = shift; + my $orig = $input; + my @base = split "", $BASE; + my @convert; + my $baseNum = @base; + print "$baseNum\n"; + my $max = 0; + while (1) { + last unless $baseNum ** ++$max < $input; + } + while ($max > 0) { + my $exp = $max - 1; + print "$baseNum to the $exp is ", $baseNum ** $exp, " which is smaller than $input\n"; + my $pow = $baseNum ** $exp; + my $place = 0; + while ($pow <= $input) { + $input -= $pow; + $place++; + print "$input; $place\n"; + } + push @convert, $place; + $max--; + } + dd @convert; + foreach my $b (@base) { + print "-$b-\n"; + } + my $output = join "", @base[@convert]; +} -- cgit From b049d80592001dca6e06b2219915eeab8fedda2d Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 12:55:09 +0200 Subject: 002-p5-02: correct output up to 99 --- challenge-002/ailbhe-tweedie/perl5/ch-02.pl | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl index ac6174c6bd..f701e59a25 100755 --- a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl +++ b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl @@ -6,6 +6,8 @@ # representation, using the characters 0-9 and A-Y. # # Prerequisites: cpan install Scalar::Util::Numeric +# +# Usage: echo {0.999} | ./ch-02.pl use strict; use warnings; @@ -16,39 +18,39 @@ my $BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXY"; while (<>) { chomp; - my $input = $_; - next unless isint $input; - my $output = convertToBase35($input); - print "output: $output\n"; + # TODO: find out how to stream input, instead of saving it to an array first + my @input = split; + for my $i (@input) { + next unless isint $i; + my $output = toBase35($i); + printf "%-4s\t==>\t%-4s\n", $i, $output; + } } -sub convertToBase35 { +sub toBase35 { my $input = shift; - my $orig = $input; my @base = split "", $BASE; my @convert; my $baseNum = @base; - print "$baseNum\n"; my $max = 0; while (1) { - last unless $baseNum ** ++$max < $input; + last unless $baseNum ** ++$max <= $input; } while ($max > 0) { my $exp = $max - 1; - print "$baseNum to the $exp is ", $baseNum ** $exp, " which is smaller than $input\n"; + #print "$baseNum to the $exp is ", $baseNum ** $exp, " which is smaller than $input\n"; my $pow = $baseNum ** $exp; my $place = 0; while ($pow <= $input) { $input -= $pow; $place++; - print "$input; $place\n"; + #print "input $input; place $place\n"; } push @convert, $place; $max--; } - dd @convert; - foreach my $b (@base) { - print "-$b-\n"; - } + #print "@convert: "; + #dd @convert; + #print "\n"; my $output = join "", @base[@convert]; } -- cgit From b1821c448c78b8855f3ff8bde18f6cd1268b825c Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 12:56:47 +0200 Subject: README: add boilerplate --- challenge-002/ailbhe-tweedie/README | 1 + 1 file changed, 1 insertion(+) create mode 100644 challenge-002/ailbhe-tweedie/README diff --git a/challenge-002/ailbhe-tweedie/README b/challenge-002/ailbhe-tweedie/README new file mode 100644 index 0000000000..36d4034b70 --- /dev/null +++ b/challenge-002/ailbhe-tweedie/README @@ -0,0 +1 @@ +Solution by Ailbhe Tweedie -- cgit From 296ac1fd5918ee411beefb03dade953ed28526fe Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 13:02:03 +0200 Subject: 002-p5-02: add TODO --- challenge-002/ailbhe-tweedie/perl5/ch-02.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl index f701e59a25..2624bd7aba 100755 --- a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl +++ b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl @@ -16,6 +16,8 @@ use Data::Dump; my $BASE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXY"; +# TODO: add command-line switch to pick between converting TO and FROM + while (<>) { chomp; # TODO: find out how to stream input, instead of saving it to an array first -- cgit From 176896c928aa3ad1cd7ad98c96f9a010394e1949 Mon Sep 17 00:00:00 2001 From: Ailbhe Tweedie Date: Tue, 2 Apr 2019 14:01:44 +0200 Subject: 002-p5-02: write fromBase35() --- challenge-002/ailbhe-tweedie/perl5/ch-02.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl index 2624bd7aba..83c63a5eb2 100755 --- a/challenge-002/ailbhe-tweedie/perl5/ch-02.pl +++ b/challenge-002/ailbhe-tweedie/perl5/ch-02.pl @@ -56,3 +56,23 @@ sub toBase35 { #print "\n"; my $output = join "", @base[@convert]; } + +sub fromBase35 { + my $input = shift; # APX + + # create a hash converting a base35 alphanumeric character to a base10 value + my %hash; + my @base = split "", $BASE; + for my $i (0..@base-1) { + $hash{$base[$i]} = $i; + } + + my @based = split "", $input; #