If your girlfriend has been kidnapped by Gollum and the Evil One, and there's nothing you can do, perhaps console yourself with a small programming problem while you listen to Ramble On or Ramblin' Man' .
PWC 370 Task 2: Scramble String
The Task
You are given two strings A and B of the same length. Write a script to return true if string B is a scramble of string A otherwise return false. String B is a scramble of string A if A can be transformed into B by a single (recursive) scramble operation. A scramble operation is:
If the string consists of only one character, return the string.
Divide the string X into two non-empty parts.
Optionally, exchange the order of those parts.
Optionally, scramble each of those parts.
Concatenate the scrambled parts to return a single string.
Examples
Input: $str1 = "abc" , $str2 = "acb" Output: true
split: ["a", "bc"]
split: ["a", ["b", "c"]]
swap: ["a", ["c", "b"]]
concatenate: "acb"
Input: $str1 = "abcd" , $str2 = "cdba" Output: true
split: ["ab",…