Posts

Showing posts from September, 2026

Robbie Hatley’s Solutions, in Perl, for The Weekly Challenge #389 (“Reorder Notes” and “ZigZag Subarray”)

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 2026-08-31 through 2026-09-07 is #389. The tasks for challenge #389 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 389-1: Reorder Notes Submitted by: Reinier Maliepaard You are given an array [composer, notes, permutation]. Reconstruct the melody by using each permutation value as the destination position of the corresponding note. Use no explicit for, foreach, or while loops. Output each result as "COMPOSER => reordered notes". ASSUMPTION: Input is valid; the notes array and permutation array have identical lengths, and the permutation contains each position from 1 to N exactly once. I solved this by assigning the original array to an initially-empty array "sliced" by the permutation numb...