Robbie Hatley’s Solutions, in Perl, for The Weekly Challenge #375 (“Single Common Word” and “Find K-Beauty”)

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-25 through 2026-05-31 is #375. The tasks for challenge #375 are as follows:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Task 375-1: Single Common Word
Submitted by: Mohammad Sajid Anwar
You are given two arrays of strings. Write a script to return the
number of strings that appear exactly once in each of the two
given arrays. String comparison is case sensitive.

This looks like a job for "scalar grep {$_ eq $s} @a".

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Task 375-2: Find K-Beauty
Submitted by: Mohammad Sajid Anwar
You are given a positive integer and a digit K. Write a script
to find the K-Beauty of the given integer. The K-Beauty of a
positive integer is defined as the number of substrings of the
given positive integer which both have length K and are divisors
of the given positive integer.

This problem is easily solved using a 3-part loop.

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

That's it for challenge 375; see you on challenge 376!

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”)