Robbie Hatley’s Solutions, in Perl, for The Weekly Challenge #385 (“Uncommon Words” and “Outermost Parentheses”)
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-03 through 2026-08-09 is #385.
The tasks for challenge #385 are as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 385-1: Uncommon Words Submitted by: Mohammad Sajid Anwar You are given two sentences. Write a script to return a list of all uncommon words. Order is not important.
Judging by the answers given to the examples, I see that the word "uncommon" is being used to mean "used once only", not "not in-common between sentences". So I use a hash to keep track of total occurrences of words, and I return only those words which occur exactly once.
Robbie Hatley's Perl Solution to The Weekly Challenge 385-1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Task 385-2: Outermost Parentheses Submitted by: Mohammad Sajid Anwar You are given a valid parentheses string. Write a script to return the string after removing the outermost parentheses of every primitive string in the primitive decomposition of the given string.
This is just a matter of keeping track of parenthetical depth in an integer variable.
Robbie Hatley's Perl Solution to The Weekly Challenge 385-2
That's it for challenge 385; see you on challenge 386!
Comments
Post a Comment