ü)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"