Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #297 ("Contiguous Sub-Arrays" and "Semi-Ordered Permutations")
For those not familiar with "The Weekly Challenge", it is a weekly programming puzzle with two parts, cycling every Sunday. You can find it here: The Weekly Challenge The Weekly Challenge for the week of 2024-11-24 through 2024-11-30 is #297. The tasks for challenge #297 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 297-1: Contiguous Sub-Arrays Submitted by: Mohammad Sajid Anwar Write a script which, given an array of 1-digit-binary integers (0s and 1s), determines the maximum length of contiguous sub-arrays with equal numbers of 0s and 1s. Example #1: Input: @binary = (1, 0) Output: 2 (1, 0) is the longest contiguous subarray with an equal number of 0 and 1. Example #2: Input: @binary = (0, 1, 0) Output: 2 (1, 0) or (0, 1) is the longest contiguous subarray with an equal number of 0 and 1. Example #3: Input: @binary = (0, 0, 0, 0, 0) Output: 0 Example #4: Input: @binary = (0, 1, 0, 0, 1, 0) Output: 4 (1,0,0,1) I'll ...