Ćü)€é©εćDš«s`g∍}®€¤‚ø€ζ€€Ë_Oà
在线尝试或验证所有测试用例。
字节数很有可能减半,但是它可以工作。
说明:
Ć # Enclose the input-list (adding the first item to the end of the list)
# i.e. ['ABC1','abcD','abCd32e'] → ['ABC1','abcD','abCd32e','ABC1']
ü) # Pair-vectorize each of them
# i.e. ['ABC1','abcD','abCd32e','ABC1']
# → [['ABC1','abcD'],['abcD','abCd32e'],['abCd32e','ABC1']]
ێ # Sort each pair by length
# i.e. [['ABC1','abcD'],['abcD','abCd32e'],['abCd32e','ABC1']]
# → [['ABC1','abcD'],['abcD','abCd32e'],['ABC1','abCd32e']]
© # Store this list in the register to re-use later on
ε } # Map each inner list in this list to:
ć # Head extracted
# i.e. ['abcD','abCd32e'] → 'abcD' and ['abCd32e']
Dš # Duplicate it, and swap the capitalization of the copy
# i.e. 'abcD' → 'ABCd'
« # Then merge it together
# i.e. 'abcD' and 'ABCd' → 'abcDABCd'
s` # Swap so the tail-list is at the top of the stack, and get it's single item
# i.e. ['abCd32e'] → 'abCd32e'
g # Get the length of that
# i.e. 'abCd32e' → 7
∍ # Extend/shorten the string to that length
# i.e. 'abcDABCd' and 7 → 'abcDABC'
® # Get the saved list from the register again
€¤ # Get the tail from each
# i.e. [['ABC1','abcD'],['abcD','abCd32e'],['abCd32e','ABC1']]
# → ['abcD','abCd32e','abCd32e']
‚ # Pair it with the other list
# i.e. ['ABC1','abcDABC','ABC1abc'] and ['abcD','abCd32e','abCd32e']
# → [['ABC1','abcDABC','ABC1abc'],['abcD','abCd32e','abCd32e']]
ø # Zip it, swapping rows / columns
# i.e. [['ABC1','abcDABC','ABC1abc'],['abcD','abCd32e','abCd32e']]
# → [['ABC1','abcD'],['abcDABC','abCd32e'],['ABC1abc','abCd32e']]
€ζ # And then zip each pair again
# i.e. [['ABC1','abcD'],['abcDABC','abCd32e'],['ABC1abc','abCd32e']]
# → [['Aa','Bb','Cc','1D'],['aa','bb','cC','Dd','A3','B2','Ce'],['Aa','Bb','CC','1d','a3','b2','ce']]
€ # Then for each inner list
€ # And for each inner string
Ë # Check if all characters are the same
# i.e. 'aa' → 1
# i.e. 'cC' → 0
_ # And inverse the booleans
# i.e. [['Aa','Bb','Cc','1D'],['aa','bb','cC','Dd','A3','B2','Ce'],['Aa','Bb','CC','1d','a3','b2','ce']]
# → [[1,1,1,1],[0,0,1,1,1,1,1],[1,1,0,1,1,1,1]]
O # Then sum each inner list
# i.e. [[1,1,1,1],[0,0,1,1,1,1,1],[1,1,0,1,1,1,1]] → [4,5,6]
à # And take the max as result
# i.e. [4,5,6] → 6