Robbie Hatley’s Solutions, in Perl, for The Weekly Challenge #373 (“Equal List” and “List Division”)

For those not familiar with "The Weekly Challenge", it is a weekly programming puzzle with two parts, with a new pair of tasks each Monday. You can find it here: The Weekly Challenge

The Weekly Challenge for the week of 2026-05-11 through 2026-05-17 is #373. The tasks for challenge #373 are as follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Task 373-1: Equal List
Submitted by: Mohammad Sajid Anwar
You are given two arrays of strings. Write a script to return
true if the two given array yield the same strings when joined;
otherwise return false.

I've reworded the above "description" to be much more unambiguous than the version on the web site. This is just a matter of joining and comparing.

Robbie Hatley's Perl Solution to The Weekly Challenge 373-1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Task 373-2: List Division
Submitted by: Mark Anderson
You are given a list and a non-negative integer. Write a script
to divide the given list into given non-negative integer equal
parts. Return -1 if the integer is more than the size of the
list.

The description allows a number-of-list of 0, yet this is impossible, hence I'll return -1 if the input integer is either < 1 or > n (where n is the size of the list). To get the odd clusterings show in the examples, I'll have to abandon the idea of using modular arithmetic and use a method of "quotients and remainders" instead. (Would make more sense to me to treat this as a poker deal, not a cake cut; but that's how this problem is structured.)

Robbie Hatley's Perl Solution to The Weekly Challenge 373-2

That's it for challenge 373; see you on challenge 374!

Comments

Popular posts from this blog

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #334 (“Range Sum” and “Nearest Valid Point”)

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #336 (“Equal Group” and “Final Score”)

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #326 (“Day of Year” and “Decompressed List”)