Posts

Showing posts from December, 2025

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #353 (“Max Words” and “Validate Coupon”)

Image
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 2025-12-22 through 2025-12-28 is #353. The tasks for challenge #353 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 353-1: Max Words Submitted by: Mohammad Sajid Anwar You are given an array of sentences. Write a script to return the maximum number of words that appear in a single sentence. Example #1: Input: ("Hello world", "This is a test", "Perl is great") Output: 4 Example #2: Input: ("Single") Output: 1 Example #3: Input: ("Short", "This sentence has six words in total", "A B C", "Just four words here") Output: 7 (The second sentence lied.) Example #4: Input: ("One", ...

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #352 (“Match String” and “Binary Prefix”)

Image
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 2025-12-15 through 2025-12-21 is #352. The tasks for challenge #352 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 352-1: Match String Submitted by: Mohammad Sajid Anwar You are given an array of strings. Write a script to return all strings that are a substring of another word in the given array in the order they occur. Example #1: Input: ("cat", "cats", "dog", "dogcat", "dogcat", "rat", "ratcatdogcat") Output: ("cat", "dog", "dogcat", "rat") Example #2: Input: ("hello", "hell", "world", "wor", "ellow", "elloworld") Output: ("hell", ...

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #351 (“Special Average” and “Arithmetic Progression”)

Image
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 2025-12-08 through 2025-12-14 is #351. The tasks for challenge #351 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 351-1: Special Average Submitted by: Mohammad Sajid Anwar You are given an array of integers. Write a script to return the average excluding the minimum and maximum of the given array. Example #1: Input: @ints = (8000, 5000, 6000, 2000, 3000, 7000) Output: 5250 Min: 2000 Max: 8000 Avg: (3000+5000+6000+7000)/4 = 21000/4 = 5250 Example #2: Input: @ints = (100_000, 80_000, 110_000, 90_000) Output: 95_000 Min: 80_000 Max: 110_000 Avg: (100_000 + 90_000)/2 = 190_000/2 = 95_000 Example #3: Input: @ints = (2500, 2500, 2500, 2500) Output: 0 Min: 2500 Max: 2500 Avg: 0 Example #4: Input: @ints = (2000) Output...

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #350 (“Good Substrings” and “Shuffle Pairs”)

Image
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 2025-12-01 through 2025-12-07 is #350. The tasks for challenge #350 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 350-1: Good Substrings Submitted by: Mohammad Sajid Anwar You are given a string. Write a script to return the number of good substrings of length three in the given string. A string is good if there are no repeated characters. Example #1: Input: $str = "abcaefg" Output: 5 Good substrings of length 3: abc, bca, cae, aef and efg Example #2: Input: $str = "xyzzabc" Output: 3 Good substrings of length 3: "xyz", "zab" and "abc" Example #3: Input: $str = "aababc" Output: 1 Good substrings of length 3: "abc" Example #4: Input: $str = ...