Robbie Hatley's Solutions, in Perl, for The Weekly Challenge #345 (“Peak Positions” and “Last Visitor”)
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-10-27 through 2025-11-02 is #345. The tasks for challenge #345 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 345-1: Peak Positions Submitted by: Mohammad Sajid Anwar You are given an array of real numbers. Find all the peaks in the array. (A "peak" is an element that is strictly greater than its left and right neighbours.) Return the indices of all such peak positions. Example #1: Input: (1, 3, 2) Output: (1) Example #2: Input: (2, 4, 6, 5, 3) Output: (2) Example #3: Input: (1, 2, 3, 2, 4, 1) Output: (2, 4) Example #4: Input: (5, 3, 1) Output: () Example #5: Input: (1, 5, 1, 5, 1, 5, 1) Output: (1, 3, 5) To solve this problem, I riffle through the middle ...