## RECAP - Perl Weekly Challenge - 039

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

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

##### Day 23: Perfect Numbers by Francis J Whittle

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

#### Challenge - 005

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

``````
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

``````

``````
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;
}

``````

# DAMIAN’s CORNER

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

# PERL SOLUTIONS

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

### Andrezgz

[PERL #1] [PERL #2]

### Burkhard Nickels

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

### Colin Crain

[PERL #1] [PERL #2]

### Duane Powell

[PERL #1] [PERL #2]

[PERL #1]

### Nazareno Delucca

[PERL #1] [PERL #2]

### Saif Ahmed

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

### Steven Wilson

[PERL #1] [PERL #2]

# RAKU SOLUTIONS

### Arne Sommer

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

[RAKU #1]

### Kevin Colyer

[RAKU #1] [RAKU #2]

### Noud

[RAKU #1] [RAKU #2]

### Ulrich Rieke

[RAKU #1] [RAKU #2]

# PERL & RAKU SOLUTIONS

### Javier Luque

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

### Laurent Rosenfeld

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

### Roger Bell_West

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

### Ruben Westerberg

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

### 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.