ü)Jε©žVćRs`.ιJ«D«Œʒg≠yн®нQyθ®θQ**}yªн¨}JIθ«
他の回答のように正規表現を使用できないため、この課題には適切な言語ではありません。
オンラインそれを試してみたり、すべてのテストケースを確認してください。
説明:
ü) # Split the input into overlapping pairs
# i.e. "poll" → ["p","o"],["o","l"],["l","l"]]
J # Join each inner list together
# i.e. ["p","o"],["o","l"],["l","l"]] → ["po","ol","ll"]
ε # Map each to:
© # Store the current value in the register
žV # Push ["qwertyuiop","asdfghjkl","zxcvbnm"]
ćR # Extract the head, and reverse it
# i.e. ["qwertyuiop","asdfghjkl","zxcvbnm"] → "poiuytrewq"
s` # Swap to take the remainder, and push them to the stack
.ι # And then interweave them with each other
# i.e. ["asdfghjkl","zxcvbnm"]
# → ["a","z","s","x","d","c","f","v","g","b","h","n","j","m","k","l"]
J # Join the list to a single string
# i.e. → "azsxdcfvgbhnjmkl"
« # Merge them together
# i.e. "qwertyuiop" and "azsxdcfvgbhnjmkl"
# → "poiuytrewqazsxdcfvgbhnjmkl"
D« # Duplicate it, and append it to itself
# i.e. "poiuytrewqazsxdcfvgbhnjmkl"
# → "poiuytrewqazsxdcfvgbhnjmklpoiuytrewqazsxdcfvgbhnjmkl"
Œ # Get all substrings of this strings
# i.e. → ["p","po","poi",...,"k","kl","l"]
ʒ } # Filter this list by:
g≠ # Where the length is NOT 1 (otherwise pair "ll" would result in "l")
* # and
yн®нQ # Where the first character of the substring and pair are the same
* # and
yθ®θQ # Where the last character of the substring and pair are the same
# i.e. "po" → []
# i.e. "ll" → ["lazsxdcfvgbhnjmkl"]
yª # After filtering, append the current pair to the filtered list
# i.e. [] → ["po"]
# i.e. ["lazsxdcfvgbhnjmkl"] → ["lazsxdcfvgbhnjmkl","ll"]
н # Get the first item
# ["po"] → "po"
# ["lazsxdcfvgbhnjmkl","ll"] → "lazsxdcfvgbhnjmkl"
¨ # Remove the last character
# i.e. "po" → "p"
# i.e. "lazsxdcfvgbhnjmkl" → "lazsxdcfvgbhnjmk"
} # Close the map
J # Join everything together
# i.e. ["p","o","lazsxdcfvgbhnjmk"] → "polazsxdcfvgbhnjmk"
Iθ« # And append the last character of the input
# (and output the result implicitly)
# i.e. "polazsxdcfvgbhnjmk" and "poll" → "polazsxdcfvgbhnjmkl"