The Weekly Challenge - 344

Monday, Oct 20, 2025| Tags: Perl, Raku

TABLE OF CONTENTS


  1. HEADLINES

  2. SPONSOR

  3. RECAP

  4. PERL REVIEW

  5. RAKU REVIEW

  6. CHART

  7. NEW MEMBERS

  8. GUESTS

  9. TASK #1: Array Form Compute

10. TASK #2: Array Formation


HEADLINES


Welcome to the Week #344 of The Weekly Challenge.

Thank you, Conor Hoekstra, for introducing a new guest language CUDA. Please checkout both solutions.

Thank you, Ryan Thompson, for being regular contributors again. Please checkout the contributions.

My contributions in Perl, Raku and Python listed below.

Perl


#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use List::Util qw/min/;

my @examples = (
    { input => [4, 2, -1, 3, -2],     exp => 1 },
    { input => [-5, 5, -3, 3, -1, 1], exp => 1 },
    { input => [7, -3, 0, 2, -8],     exp => 0 },
    { input => [-2, -5, -1, -8],      exp => 1 },
    { input => [-2, 2, -4, 4, -1, 1], exp => 1 },
);

foreach (@examples) {
    is(zero_friend($_->{input}), $_->{exp});
}

done_testing;

sub zero_friend { my ($nums) = @_; return min map abs, @$nums }

Raku


#!/usr/bin/env raku

use Test;

my @examples = (
    { input => [4, 2, -1, 3, -2],     exp => 1 },
    { input => [-5, 5, -3, 3, -1, 1], exp => 1 },
    { input => [7, -3, 0, 2, -8],     exp => 0 },
    { input => [-2, -5, -1, -8],      exp => 1 },
    { input => [-2, 2, -4, 4, -1, 1], exp => 1 },
);

for @examples -> %example {
    is(zero_friend(%example<input>), %example<exp>);
}

done-testing;

sub zero_friend($nums) { return min $nums.map(&abs); }

Python


#!/usr/bin/env python3

import unittest

def zero_friend(nums):
    return min(map(abs, nums))

class TestZeroFriend(unittest.TestCase):
    def test_examples(self):
        examples = [
            {'input': [4, 2, -1, 3, -2],     'exp': 1},
            {'input': [-5, 5, -3, 3, -1, 1], 'exp': 1},
            {'input': [7, -3, 0, 2, -8],     'exp': 0},
            {'input': [-2, -5, -1, -8],      'exp': 1},
            {'input': [-2, 2, -4, 4, -1, 1], 'exp': 1},
        ]

        for example in examples:
            with self.subTest(input=example['input']):
                self.assertEqual(zero_friend(example['input']), example['exp'])

if __name__ == '__main__':
    unittest.main()

Thank you Team PWC, once again.

Happy Hacking!!


Last 5 weeks mainstream contribution stats. Thank you Team PWC for your support and encouragements.

  Week      Perl       Raku       Blog   
   339       47       23       15   
   340       51       25       13   
   341       57       25       25   
   342       51       22       15   
   343       44       19       13   

Last 5 weeks guest contribution stats. Thank you each and every guest contributors for your time and efforts.

  Week      Guests       Contributions       Languages   
   339       13       64       21   
   340       13       55       17   
   341       15       67       19   
   342       14       46       14   
   343       14       59       19   

TOP 10 Guest Languages


Do you see your favourite language in the Top #10? If not then why not contribute regularly and make it to the top.

 1. Python     (3673)
 2. Rust       (1020)
 3. Ruby       (838)
 4. Haskell    (823)
 5. Lua        (779)
 6. C++        (659)
 7. C          (596)
 8. JavaScript (594)
 9. Go         (561)
10. BQN        (476)

Blogs with Creative Title


1. Team Zero by Arne Sommer.

2. Friendly Champions by Jorg Sommrey.

3. The Zero Champion by Matthias Muth.

4. Ze-ro the CHAMPIONS! by Packy Anderson.

5. No friends among the champions by Peter Campbell Smith.

6. Zero to Champion by Roger Bell_West.

7. It’s hard to make friends when you’re a zero by Ryan Thompson.

8. Absolute Champion by Simon Green.


GitHub Repository Stats


1. Commits: 45,826 (+128)

2. Pull Requests: 12,833 (+41)

3. Contributors: 264

4. Fork: 337

5. Stars: 198



With start of Week #268, we have a new sponsor Lance Wicks until the end of year 2025. Having said we are looking for more sponsors so that we can go back to weekly winner. If anyone interested please get in touch with us at perlweeklychallenge@yahoo.com. Thanks for your support in advance.


RECAP


Quick recap of The Weekly Challenge - 343 by Mohammad Sajid Anwar.


PERL REVIEW


If you missed any past reviews then please check out the collection.


RAKU REVIEW


If you missed any past reviews then please check out the collection.


CHART


Please take a look at the charts showing interesting data.

I would like to THANK every member of the team for their valuable suggestions. Please do share your experience with us.


NEW MEMBERS


Please find out How to contribute?, if you have any doubts.

Please try the excellent tool EZPWC created by respected member Saif Ahmed of Team PWC.


GUESTS


Please check out the guest contributions for the Week #343.

Please find past solutions by respected guests. Please share your creative solutions in other languages.


Task 1: Array Form Compute

Submitted by: Mohammad Sajid Anwar

You are given an array of integers, @ints and an integer, $x.

Write a script to add $x to the integer in the array-form.

The array form of an integer is a digit-by-digit representation stored as an array, where the most significant digit is at the 0th index.


Example 1

Input: @ints = (1, 2, 3, 4), $x = 12
Output: (1, 2, 4, 6)

Example 2

Input: @ints = (2, 7, 4), $x = 181
Output: (4, 5, 5)

Example 3

Input: @ints = (9, 9, 9), $x = 1
Output: (1, 0, 0, 0)

Example 4

Input: @ints = (1, 0, 0, 0, 0), $x = 9999
Output: (1, 9, 9, 9, 9)

Example 5

Input: @ints = (0), $x = 1000
Output: (1, 0, 0, 0)

Task 2: Array Formation

Submitted by: Mohammad Sajid Anwar

You are given two list: @source and @target.

Write a script to see if you can build the exact @target by putting these smaller lists from @source together in some order. You cannot break apart or change the order inside any of the smaller lists in @source.


Example 1

Input: @source = ([2,3], [1], [4])
       @target = (1, 2, 3, 4)
Output: true

Use in the order: [1], [2,3], [4]

Example 2

Input: @source = ([1,3], [2,4])
       @target = (1, 2, 3, 4)
Output: false

Example 3

Input: @source = ([9,1], [5,8], [2])
       @target = (5, 8, 2, 9, 1)
Output: true

Use in the order: [5,8], [2], [9,1]

Example 4

Input: @source = ([1], [3])
       @target = (1, 2, 3)
Output: false

Missing number: 2

Example 5

Input: @source = ([7,4,6])
       @target = (7, 4, 6)
Output: true

Use in the order: [7, 4, 6]


Last date to submit the solution 23:59 (UK Time) Sunday 26th October 2025.


SO WHAT DO YOU THINK ?

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

Contact with me