Robbie Hatley’s Solutions, in Perl, for The Weekly Challenge #388 (“Dyck Words” and “Secret Santa”)
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-24 through 2026-08-30 is #388. The tasks for challenge #388 are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 388-1: Dyck Words Submitted by: Mohammad S Anwar A Dyck Word of order $n is a string of length 2x$n consisting of $n ‘U’ (Up) characters and $n ‘D’ (Down) characters such that no initial prefix of the string contains more ‘D’s than ‘U’s. Write a script to return a list of all valid Dyck words of length 2x$n, sorted in lexicographical (alphabetical) order. I first generate likely candidate equivalent integers (with the correct number of binary digits, beginning with 1 and ending with 0). I then check each candidate to see if it actually is a Dyck number. For each Dyck number, I sprintf it as a binar...