žGçU|€SXζζD"εγεDgDisëXи]"©.V˜sø®.V€Sø˜‚øʒË}ʒXå≠}gq
žGçU|€SXζζD"εγεDgDisëXи]"©.V˜sø®.V€Sø˜‚øʒË}ʒXå≠}gq
オンラインでお試しください。
これは、私がこれまでに書いた中で最もuくて長い05AB1Eプログラムの1つです。..>。> 05AB1Eでは、この課題は非常に困難です。バイトカウントは、別のアプローチ(または同様のアプローチでも)を使用することで、少なくとも半減するか、3/4倍小さくできることを心に留めていますが、現時点ではわかりません。私はちょうどそれが今働いていることをうれしく思います..誰かがいくつかのスマートなトリックではるかに短い05AB1Eの回答を投稿した場合、私はおそらく恥からこの回答を削除します... xD
説明:
žGç # Character with unicode 32768 ('耀')
U # Pop and store it in variable `X`
# (This character is not part of the printable ASCII, nor of my 05AB1E code)
| # Take the multi-line input as list
# i.e. "Ybb\nYH%\n%%%%" → ["Ybb","YH%","%%%%"]
€S # Convert each string to a list of characters
# i.e. ["Ybb","YH%","%%%%"] → [["Y","b","b"],["Y","H","%"],["%","%","%","%"]]
Xζζ # Zip with character `X` as filler twice to make the lines of equal length
# i.e. [["Y","b","b"],["Y","H","%"],["%","%","%","%"]]
# → [["Y","b","b","耀"],["Y","H","%","耀"],["%","%","%","%"]]
D # Duplicate this list
" " # Create a string
© # Which we store in the register (without popping)
.V # And execute that string as 05AB1E code
ε # Map each inner list to:
γ # Split in chunks of the same characters
# i.e. [["Y","b","b"],["Y","H","%"],["%","%","%","%"]]
# → [[["Y"],["b","b"]],[["Y"],["H"],["%"]],[["%","%","%","%"]]]
ε # Map each of those to:
D # Duplicate the current inner list
gDi # If its length is exactly 1:
s # Swap so the mapping keeps the duplicated single character (as list)
ë # Else:
Xи # Take character `X` repeated the length amount of times
# i.e. ["%","%","%","%"] (length 4) → ["耀","耀","耀","耀"]
] # Close the if-else and both maps
˜ # Flatten the list to a single list of characters
# i.e. [[["Y"],["耀","耀"],["耀"]],[["Y"],["H"],["%"],["耀"]],[["耀","耀","耀","耀"]]]
# → ["Y","耀","耀","耀","Y","H","%","耀","耀","耀","耀","耀"]
s # Swap so the duplicate list is at the top of the stack
ø # Swap its rows and columns
# i.e. [["Y","b","b","耀"],["Y","H","%","耀"],["%","%","%","%"]]
# → [["Y","Y","%"],["b","H","%"],["b","%","%"],["耀","耀","%"]]
®.V # Execute the same piece of code again that we've stored in the register
€S # Convert each to a list of characters
# i.e. [[["耀","耀"],["%"]],[["b"],["H"],["%"]],[["b"],["耀","耀"]],[["耀","耀"],["%"]]]
# → [["耀","耀","%"],["b","H","%"],["b","耀","耀"],["耀","耀","%"]]
ø # Swap its rows and columns back again
# i.e. [["耀","b","b","耀"],["耀","H","耀","耀"],["%","%","耀","%"]]
˜ # Flatten this list as well
‚ # Pair both lists together
# i.e. [["Y","耀","耀","耀","Y","H","%","耀","耀","耀","耀","耀"],
# ["耀","b","b","耀","耀","H","耀","耀","%","%","耀","%"]]
ø # Swap its rows and columns to create pairs
# i.e. [["Y","耀"],["耀","b"],["耀","b"],["耀","耀"],["Y","耀"],["H","H"],["%","耀"],["耀","耀"],["耀","%"],["耀","%"],["耀","耀"],["耀","%"]]
ʒË} # Filter out any inner lists where both characters are not equal
# i.e. [["耀","耀"],["H","H"],["耀","耀"],["耀","耀"]]
ʒXå≠} # Filter out any inner lists that contain the character `X`
# i.e. [["H","H"]]
g # Take the length as result
# i.e. [["H","H"]] → 1
q # Stop the program, making all other characters no-ops
# (and output the length above implicitly)