ŽF¯L.XIå
ing -52字节 谢谢 @Adnan,因为显然05AB1E的罗马数字内置文件没有记录,哈哈.. xD
在线尝试或验证所有测试用例。
说明:
ŽF¯ # Push comressed integer 3999
L # Create a list in the range [1,3999]
.X # Convert each integer in this list to a roman number string
Iå # Check if the input is in this list
# (and output the result implicitly)
请参阅我的05AB1E技巧(如何压缩大整数部分)以了解原因ŽF¯
是3999
。
原始61字节答案:
•1∞Γ'иÛnuÞ\₂…•Ž8вв€SÐ)v.•6#&‘нδ•u3ôNèyè}'M3L×)Rεõš}`3Fâ}€˜JIå
在线尝试或验证所有测试用例。
说明:
•1∞Γ'иÛnuÞ\₂…• '# Push compressed integer 397940501547566186191992778
Ž8в # Push compressed integer 2112
в # Convert the integer to Base-2112 as list:
# [1,11,111,12,2,21,211,2111,10]
€S # Convert each number to a list of digits
Ð # Triplicate this list
) # And wrap it into a list of lists (of lists)
v # Loop `y` over each these three lists:
.•6#&‘нδ• # Push compressed string "xivcxlmcd"
u # Uppercased
3ô # And split into parts of size 3: ["XIV","CXL","MCD"]
Nè # Use the loop index to get the current part
yè # And index the list of lists of digits into this string
}'M '# After the loop: push "M"
3L # Push list [1,2,3]
× # Repeat the "M" that many times: ["M","MM","MMM"]
) # Wrap all lists on the stack into a list:
# [[["I"],["I","I"],["I","I","I"],["I","V"],["V"],["V","I"],["V","I","I"],["V","I","I","I"],["I","X"]],[["X"],["X","X"],["X","X","X"],["X","L"],["L"],["L","X"],["L","X","X"],["L","X","X","X"],["X","C"]],[["C"],["C","C"],["C","C","C"],["C","D"],["D"],["D","C"],["D","C","C"],["D","C","C","C"],["C","M"]],["M","MM","MMM"]]
R # Reverse this list
εõš} # Prepend an empty string "" before each inner list
` # Push the four lists onto the stack
3F # Loop 3 times:
â # Take the cartesian product of the two top lists
}€˜ # After the loop: flatten each inner list
J # Join each inner list together to a single string
Iå # And check if the input is in this list
# (after which the result is output implicitly)
请参阅我的05AB1E技巧(各节如何压缩不属于字典的字符串?,如何压缩大整数?和如何压缩整数列表?)以了解原因:
•1∞Γ'иÛnuÞ\₂…•
是 397940501547566186191992778
Ž8в
是 2112
•1∞Γ'иÛnuÞ\₂…•Ž8вв
是 [1,11,111,12,2,21,211,2111,10]
.•6#&‘нδ•
是 "xivcxlmcd"