RECAP - Perl Weekly Challenge - 039

Monday, Dec 23, 2019| Tags: Perl, Raku


HEADLINES



Advent Calendar 2019 is in the last leg. We have had some very interesting solutions by respected members of the team.

Day 1: Word Ladder Puzzle by Laurent Rosenfeld
Day 2: Ranking by Dave Jacoby
Day 3: Encode/Decode Roman Numerals by Joelle Maslak
Day 4: Hoftadter Female and Male Sequence by E. Choroba
Day 5: Longest english word using US state postal abbreviation by Neil Bowers
Day 6: Pythagoras Pie Puzzle by Arne Sommer
Day 7: Ackermann Function by Jaldhar H. Vyas
Day 8: Priority Queue by Adam Russell
Day 9: Five Weekends by Dave Cross
Day 10: Split on change of character by Mark Senn
Day 11: Sexy Primes by Yet Ebreo
Day 12: nth Order Difference Series by Laurent Rosenfeld
Day 13: Demonstrate Array/Hash Slices by Burkhard Nickels
Day 14: Pascal Triangle by Scimon Proctor
Day 15: Dynamic Variable by Javier Luque
Day 16: Vigenere Cipher by Yozen Hernandez
Day 17: Bitcoin Validation by Athanasius
Day 18: FizzBuzz by Philippe Bruhat
Day 19: Trim leading zeros by Khalid
Day 20: Word Game by Roger Bell_West
Day 21: Base35 Representation by Gustavo Chaves
Day 22: Replace character and count by JJ Merelo
Day 23: Perfect Numbers by Francis J Whittle

Ryan Thompson shared his solutions to the past challenges in Perl and Raku.

Challenge - 001

Challenge - 002

Challenge - 003

Challenge - 004

Challenge - 005


Fernando Correa de Oliveira shared solution to Perl Weekly Challenge - 039 as below in Raku:

Task #1


sub to-min(Str $str) {
    do given $str.comb(/\d+/) {
       60*.[0] + .[1]
    }
}

proto calc(Int $count,  Int $prev, @in,               @out --> Int) {*}
multi calc(0,           Int,       [],                []   --> 0)   {}
multi calc(Int,         Int,       [],                [])           { die "Finished with guest inside house" }
multi calc(0,           Int $prev, [Int $in, *@in],   @out where $in <= *.head)        { calc 1, $in, @in, @out }
multi calc(Int $count,  Int $prev, [Int $in, *@in],   @out where $in <= *.head)        { $in  - $prev + calc $count + 1, $in,  @in, @out }
multi calc(Int $count,  Int $prev, @in (Int $in, *@), [Int $out where $in > *, *@out]) { $out - $prev + calc $count - 1, $out, @in, @out }
multi calc(Int $count,  Int $prev, [],                [Int $out, *@out])               { $out - $prev + calc $count - 1, $out, [],  @out }

my (@in, @out) := ([[],[]], |lines).reduce: -> (@in, @out), $_ {
   my ($in, $out) = .comb(/\d+":"\d+/);
   [ |@in, to-min $in, ], [ |@out, to-min $out ]
}

say calc 0, 0, @in.sort, @out.sort

Task #2


multi calc(@mem,                        Int $num) { [ $num, |@mem ]   }
multi calc([Int() $x, Int() $y, *@mem], "+"     ) { [ $y + $x, |@mem] }
multi calc([Int() $x, Int() $y, *@mem], "-"     ) { [ $y - $x, |@mem] }
multi calc([Int() $x, Int() $y, *@mem], "−"     ) { [ $y - $x, |@mem] }
multi calc([Int() $x, Int() $y, *@mem], "*"     ) { [ $y * $x, |@mem] }
multi calc([Int() $x, Int() $y, *@mem], "×"     ) { [ $y * $x, |@mem] }
multi calc([Int() $x, Int() $y, *@mem], "/"     ) { [ $y / $x, |@mem] }
multi calc([Int() $x, Int() $y, *@mem], "÷"     ) { [ $y / $x, |@mem] }
multi calc(@mem (Int() $x, *@),         "="     ) { @mem              }

my @mem;
for words() {
    @mem = calc @mem, .&val;
    say @mem.head
}



CENTURION CLUB



1) Laurent Rosenfeld (488)

2) Joelle Maslak (330)

3) Jaldhar H. Vyas (326)

4) Ruben Westerberg (308)

5) Adam Russell (262)

6) Arne Sommer (240)

7) Athanasius (208)

8) E. Choroba (202)

9) Roger Bell_West (200)

10) Kian-Meng Ang (160)

11) Andrezgz (152)

12) Scimon Proctor (148)

13) Duncan C. White (136)

14) Dave Jacoby (132)

15) Steven Wilson (120)

16) Yet Ebreo (114)

17) Kevin Colyer (108)



DAMIAN’s CORNER



Checkout the masterpiece collection of blogs by Damian Conway solving “Perl Weekly Challenge”.



PERL SOLUTIONS



Adam Russell

Adam Russell

[PERL #1] [PERL #2] [BLOG #1] [BLOG #2]


Andrezgz

Andrezgz

[PERL #1] [PERL #2]


Burkhard Nickels

Burkhard Nickels

[PERL #1] [PERL #2] [BLOG #1]


Colin Crain

Colin Crain

[PERL #1] [PERL #2]


Duane Powell

Duane Powell

[PERL #1] [PERL #2]


Duncan C. White

Duncan C. White

[PERL #1]


Nazareno Delucca

Nazareno Delucca

[PERL #1] [PERL #2]


Saif Ahmed

Saif Ahmed

[PERL #1] [PERL #2] [BLOG #1]


Steven Wilson

Steven Wilson

[PERL #1] [PERL #2]



RAKU SOLUTIONS



Arne Sommer

Arne Sommer

[RAKU #1] [RAKU #2] [BLOG #1]


Daniel Mita

Daniel Mita

[RAKU #1]


Kevin Colyer

Kevin Colyer

[RAKU #1] [RAKU #2]


Noud

Noud

[RAKU #1] [RAKU #2]


Ulrich Rieke

Ulrich Rieke

[RAKU #1] [RAKU #2]



PERL & RAKU SOLUTIONS



Javier Luque

Javier Luque

[PERL #1] [PERL #2] [RAKU #1] [RAKU #2] [BLOG #1]


Laurent Rosenfeld

Laurent Rosenfeld

[PERL #1] [PERL #2] [RAKU #1] [RAKU #2] [BLOG #1]


Roger Bell_West

Roger Bell_West

[PERL #1] [PERL #2] [RAKU #1] [RAKU #2]


Ruben Westerberg

Ruben Westerberg

[PERL #1] [PERL #2] [RAKU #1] [RAKU #2]


Ryan Thompson

Ryan Thompson

[PERL #1] [PERL #2] [RAKU #1] [RAKU #2] [BLOG #1]



Last but not the least, I would like to request all members, please send us your photo, that you already use on some other web platform, to use in the weekly blog, if not already sent.



SO WHAT DO YOU THINK ?

If you have any suggestions or ideas then please do share with us.

Contact with me