žGçU|€SXζζD"εγεDgDisëXи]"©.V˜sø®.V€Sø˜‚øʒË}ʒXå≠}gq
žGçU|€SXζζD"εγεDgDisëXи]"©.V˜sø®.V€Sø˜‚øʒË}ʒXå≠}gq
Çevrimiçi deneyin.
Bu şimdiye kadar yazdığım en çirkin ve en uzun 05AB1E programlarından biri ..>.> Bu zorluk 05AB1E'de aldatıcı bir şekilde zor. Bayt sayımının farklı bir yaklaşım (hatta benzer bir yaklaşımla) kullanarak en azından yarıya, hatta üç / dört kat daha küçük olabileceğine hiç şüphe yok, ama şu anda nasıl olduğunu göremiyorum. Şu anda çalıştığına sevindim .. Birisi bazı akıllı hilelerle çok daha kısa bir 05AB1E yanıtı gönderirse, muhtemelen bu cevabı utançtan sileceğim ... xD
Açıklama:
ž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)