Posts

Showing posts from August, 2025

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

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-08-25 through 2025-08-31 is #336 The tasks for challenge #336 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 336-1: Equal Group Submitted by: Mohammad Sajid Anwar You are given an array of integers. Write a script to return true if the given array can be divided into one or more groups: each group must be of the same size as the others, with at least two members, and with all members having the same value. Example #1: Input: @ints = (1,1,2,2,2,2) Output: true Groups: (1,1), (2,2), (2,2) Example #2: Input: @ints = (1,1,1,2,2,2,3,3) Output: false Groups: (1,1,1), (2,2,2), (3,3) Example #3: Input: @ints = (5,5,5,5,5,5,7,7,7,7,7,7) Output: true Groups: (5,5,5,5,5,5), (7,7,7,7,7,7) Example #4: Input: @ints ...

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #335 (“Common Characters” and “TicTacToe”)

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-08-18 through 2025-08-24 is #335 The tasks for challenge #335 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 335-1: Common Characters Submitted by: Mohammad Sajid Anwar You are given an array of words. Write a script to return all characters that is in every word in the given array including duplicates. Example #1: Input: @words = ("bella", "label", "roller") Output: ("e", "l", "l") Example #2: Input: @words = ("cool", "lock", "cook") Output: ("c", "o") Example #3: Input: @words = ("hello", "world", "pole") Output: ("l", "o") Example #4: Input: ...

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

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-08-11 through 2025-08-17 is #334 The tasks for challenge #334 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 334-1: Range Sum Submitted by: Mohammad Sajid Anwar You are given a list integers and pair of indices. Write a script to return the sum of integers between the given indices (inclusive). Example #1: Input: @ints = (-2, 0, 3, -5, 2, -1), $x = 0, $y = 2 Output: 1 Example #2: Input: @ints = (1, -2, 3, -4, 5), $x = 1, $y = 3 Output: -3 Example #3: Input: @ints = (1, 0, 2, -1, 3), $x = 3, $y = 4 Output: 2 Example #4: Input: @ints = (-5, 4, -3, 2, -1, 0), $x = 0, $y = 3 Output: -2 Example #5: Input: @ints = (-1, 0, 2, -3, -2, 1), $x = 0, $y = 2 Output: 1 This is just a matter of using "sum0...

Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #333 (“Straight Line” and “Duplicate Zeros”)

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-08-04 through 2025-08-10 is #333 The tasks for challenge #333 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 333-1: Straight Line Submitted by: Mohammad Sajid Anwar You are given a list of co-ordinates. Write a script to find out if the given points make a straight line. Example 1 Input: @list = ([2, 1], [2, 3], [2, 5]) Output: true Example 2 Input: @list = ([1, 4], [3, 4], [10, 4]) Output: true Example 3 Input: @list = ([0, 0], [1, 1], [2, 3]) Output: false Example 4 Input: @list = ([1, 1], [1, 1], [1, 1]) Output: true Example 5 Input: @list = ([1000000, 1000000], [2000000, 2000000], [3000000, 3000000]) Output: true I'll consider points A, B, C to be collinear if...